Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Over-Lapping Collision Commands

Author
Message
Hurryingcheese
14
Years of Service
User Offline
Joined: 3rd Jul 2012
Location:
Posted: 3rd Jul 2012 08:36
Hey guys, this is the first of probably many posts of mine...I'm relatively new to DB and I'm trying to program a large, open world 2-D game. The best explaination I have for it is a mix between pokemon and skyrim (pokemon in the way of camera position and sprite style and skyrim in terms of the story).

ANYWAYS...to the point, I'm having trouble with overlapping sprites. I want to use a generic subprocedure to check for collision between the main character and sprites like houses, trees, etc. The problem is, the sprites I want to check for collision for are sitting on grass which I'm loading as a sprite. If I try to load it as anything other than a sprite (such as an image) it draws to the screen at the wrong time and appears to flash when the character moves. I have a lot of code so I'll only put up what I think contains the problem.



As you can see, I told the program to only set 'sn' as the sprite the player was colliding with if 'sprite hit(1, 0)' didn't return a 2, which is the sprite number of the grass. The problem is, because the grass is below all of my sprites, the player will always be colliding with it, therefore sn will never be able to be set to 'sprite hit(1, 0).' I hope I have been clear in trying to explain my problem and I'd like to thank anybody who can help me in advance. If you need another piece of the code, please just tell me.

-Live to code-
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 3rd Jul 2012 13:18
IF NOT sprite hit(1, 0)=2


I've never actually tried IF NOT before. I usually write...

IF sprite hit(1, 0)<>2

Maybe IF NOT doesn't work.

BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 4th Jul 2012 19:26 Edited at: 4th Jul 2012 19:26
IIRC, SPRITE HIT only returns true on the first frame the sprites collide. It returns false after that even if the sprites continue to collide. You might want to try SPRITE COLLISION instead.

There are probably better ways to do this, it feels like a bit of a hack. I'll try to post back later when I have time...

Login to post a reply

Server time is: 2026-07-07 15:10:17
Your offset time is: 2026-07-07 15:10:17