Pages: 1
Posted on 10-02-11, 08:37 pm
Roy Koopa


Karma: 4011
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

So how can I create collision?
Hope for help
_________________________
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, 08:25 am


Karma: 3752
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
Roy Koopa


Karma: 4011
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 And I tried with the coordinates, but then, I can only stand on ONE Pixel xD
_________________________
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, 01:16 pm
AxewAxew

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
Roy Koopa


Karma: 4011
Posts: 747/2722
Since: 06-26-11
Thats the problem. I dont know how to check th width In Pascal its sooo easy ("ImageName".Width) But how does it work in DS Dev?
_________________________
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
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 9979
Posts: 944/4456
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)
Roy Koopa


Karma: 4011
Posts: 748/2722
Since: 06-26-11
Uhm... yes... But that doesnt help...
Here's what I've written yesterday:


I know thats fail, but I dont know another way
_________________________
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:59 pm (rev. 1)
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 9979
Posts: 945/4456
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
Roy Koopa


Karma: 4011
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 And I'll stop falling if I'm on the X coordinates. Doesnt matter if in the air or on the block
_________________________
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
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 9979
Posts: 946/4456
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
Roy Koopa


Karma: 4011
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
Super Mario
( ͡° ͜ʖ ͡°)

Karma: 9979
Posts: 947/4456
Since: 06-08-11
Then you're doing something else wrong....
Posted on 10-03-11, 04:13 pm
Roy Koopa


Karma: 4011
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 : )
Posted on 10-05-11, 02:47 am (rev. 1)
Porcupo
Did you win the game?

Karma: 211
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