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.

Dark GDK / Collision

Author
Message
ketchup mustard
16
Years of Service
User Offline
Joined: 31st Jan 2008
Location:
Posted: 17th Jul 2010 00:33 Edited at: 17th Jul 2010 00:40
hi. i am working on a 2D sidescroller. I am using a switch type deal:


First off, when the statement detects whether the main sprite's mX matches FloorlvlX belonging to the floor under the main sprite, I would like the detection to extend the entire length of the floor - not just the the one pixel at the top right of the image.

Secondly, is this an ideal implementation for a collision? Will it bog down my memory? Is there a better way? Please note that the switch statement will find its way into the main game loop (LoopGDK()) through a set of functions it presides in.

Don't Clap, Just Throw Money!
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 17th Jul 2010 00:44
Have checked out dbSpriteCollision() yet? I'm not sure, but it sounds like what you need to me...

JTK
ketchup mustard
16
Years of Service
User Offline
Joined: 31st Jan 2008
Location:
Posted: 17th Jul 2010 01:57
OMG JTK D:
dbSpriteCollision(); is a gift from God. I exchanged a whole 34 lines of code for just ~6 lines XD its a miracle~!

Don't Clap, Just Throw Money!
ketchup mustard
16
Years of Service
User Offline
Joined: 31st Jan 2008
Location:
Posted: 17th Jul 2010 02:24
my only problem now is that the main sprite will temporarily freeze in the air below a floor and a little to the side of it when i walk off the platform floor only until i issue the main sprite to move right or left. D% halp

Don't Clap, Just Throw Money!
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 17th Jul 2010 04:50
For that, I would have to see code (and maybe a screen-shot or two) as I can't even invision what you are trying to describe.

Sorry,

JTK
ketchup mustard
16
Years of Service
User Offline
Joined: 31st Jan 2008
Location:
Posted: 26th Jul 2010 06:28
the floor is the pink box, the main sprite is mega man. He will freeze in thin air, but then fall when i tap either left or right...

Don't Clap, Just Throw Money!

Attachments

Login to view attachments
Greg_C
14
Years of Service
User Offline
Joined: 22nd May 2010
Location:
Posted: 26th Jul 2010 10:23
Looks weird I think some code would help.
Unseen Machine
13
Years of Service
User Offline
Joined: 23rd Jul 2010
Location:
Posted: 27th Jul 2010 02:25
How do you get that dbSpriteCollision command to only work when a sprite, not its background overlaps another sprite? Or does that require something else?
ketchup mustard
16
Years of Service
User Offline
Joined: 31st Jan 2008
Location:
Posted: 28th Jul 2010 23:27
//length of X = 11
//length of Y = 35
void NoTouchy();
int Collision;

void NoTouchy()
{
if ( dbSpriteCollision ( FloorCollisionID, 1 || 2 ) )//Floor is 35px below main sprite?
{
mY = ( FloorlvlY - 21 );
}
else
FreeFall();
dot dot dot...

Don't Clap, Just Throw Money!
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 29th Jul 2010 00:10
@unseen: do a search for pixel perfect collisions. That sounds like what you're looking for.

@ketchup: to me that looks like an incomplete snippet. Not enough information to tell what's really going on. However, your sprite collision (floorid, 1||2) would seem like its always checking floorid and 1 - is that your intention?

JTK
Unseen Machine
13
Years of Service
User Offline
Joined: 23rd Jul 2010
Location:
Posted: 29th Jul 2010 01:02
Yeh i figured there was no easy way, but its a nice command for simple collisions. I'm working on a Asteroid style game that utilises it. I'll post a dropbox link when it's nearer completion.

Login to post a reply

Server time is: 2024-07-02 09:09:42
Your offset time is: 2024-07-02 09:09:42