Pages: 1
|
Posted on 10-02-11, 08:37 pm
|
![]() Karma: 4021 Posts: 743/2722 Since: 06-26-11 |
Yeah, like the titels says, I want to know, how I can create Sprite Collision. I tried now many things and also USED GOOGLE, but couldnt find anything. Only something about OBJSHAPE_TALL/WIDE -> Dont understand. I spent now 3 hours for trying
See a lots of creative DS Hacking here![]() So how can I create collision? Hope for help ![]() _________________________ If you want to support me, you might check out my Patreon Page : ) |
|
Posted on 10-03-11, 08:25 am
|
Karma: 3772 Posts: 469/2112 Since: 06-28-11 |
I am not good in C, but I probably know the algorithm.
![]() You write the coordinates of the different sprites into variables. Everytime the sprites are moving, you overwrite the old coordinates in the variables with the newer ones. And everytime the sprites are moving, you also compare the values inside the variables. If the values in the two variables are the same, do the image of the collision. ![]() ![]() ![]() |
|
Posted on 10-03-11, 08:28 am
|
![]() Karma: 4021 Posts: 746/2722 Since: 06-26-11 |
Yeah, I know how to make collision, because I already created a Jump'n run in Pascal, but I dont know how to get the Top/Left from sprites in C++ for DS
See a lots of creative DS Hacking here![]() _________________________ If you want to support me, you might check out my Patreon Page : ) |
Nadia |
Posted on 10-03-11, 01:16 pm
|
Karma: 673 Posts: 61/583 Since: 07-02-11 |
Check if it's in the range of the sprite's position AND the sprite's position plus its width.
|
|
Posted on 10-03-11, 01:28 pm
|
![]() Karma: 4021 Posts: 747/2722 Since: 06-26-11 |
Thats the problem. I dont know how to check th width
See a lots of creative DS Hacking here![]() ![]() _________________________ If you want to support me, you might check out my Patreon Page : ) |
|
Posted on 10-03-11, 02:48 pm
|
![]() ( ͡° ͜ʖ ͡°) Karma: 10141 Posts: 944/4458 Since: 06-08-11 |
Hmm those sprites are 16x16, so the width and height is 16. Easy.
|
|
Posted on 10-03-11, 02:57 pm (rev. 1)
|
![]() Karma: 4021 Posts: 748/2722 Since: 06-26-11 |
Uhm... yes... But that doesnt help...
See a lots of creative DS Hacking hereHere's what I've written yesterday: I know thats fail, but I dont know another way ![]() _________________________ If you want to support me, you might check out my Patreon Page : ) |
|
Posted on 10-03-11, 02:59 pm (rev. 1)
|
![]() ( ͡° ͜ʖ ͡°) Karma: 10141 Posts: 945/4458 Since: 06-08-11 |
You could do
if(PlX >= Spr1X && PlX <= Spr1X+16) if(PlY >= Spr1Y && PlY <= Spr1Y+16) falling = false; |
|
Posted on 10-03-11, 03:19 pm
|
![]() Karma: 4021 Posts: 749/2722 Since: 06-26-11 |
I had to add "}/{" And then it worked a bit... I can now stand on Sprite2 not 1
See a lots of creative DS Hacking here![]() ![]() _________________________ If you want to support me, you might check out my Patreon Page : ) |
|
Posted on 10-03-11, 03:22 pm
|
![]() ( ͡° ͜ʖ ͡°) Karma: 10141 Posts: 946/4458 Since: 06-08-11 |
if(PlX >= Spr1X && PlX <= Spr1X+16)
{ if(PlY >= Spr1Y && PlY <= Spr1Y+16) { falling = false; } } |
|
Posted on 10-03-11, 04:09 pm
|
![]() Karma: 4021 Posts: 750/2722 Since: 06-26-11 |
Yeah, thats what I added ... <_<
See a lots of creative DS Hacking here_________________________ If you want to support me, you might check out my Patreon Page : ) |
|
Posted on 10-03-11, 04:10 pm
|
![]() ( ͡° ͜ʖ ͡°) Karma: 10141 Posts: 947/4458 Since: 06-08-11 |
Then you're doing something else wrong....
|
|
Posted on 10-03-11, 04:13 pm
|
![]() Karma: 4021 Posts: 751/2722 Since: 06-26-11 |
Does the source help?
See a lots of creative DS Hacking here_________________________ If you want to support me, you might check out my Patreon Page : ) |
coolas1 |
Posted on 10-05-11, 02:47 am (rev. 1)
|
![]() Did you win the game? Karma: 226 Posts: 118/322 Since: 06-28-11 |
Well I'll upload a sprite colision file to the svn.
Here you are: int spritecol(int fx,int fy,int sx,int sy,int fSizex,int fSizey,int sSizex,int sSizey){
if ((fx + fSizex > sx )&& (fx < sx+sSizex) && (sy + sSizey > fy) && (sy < fy+fSizey))
return 1;
else
return 0;
return 0;
} For example to test whether sprite1 at a x of 1 and a y of 1 with a width of 16x16 colides with sprite2 at 5x and 8y which also has a width of 16x16: if (spritecol(1,1,5,8,16,16,16,16)
falling=false;
else
falling=true; I'm now uploading the function to svn... |
Pages: 1