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 / Sprite collition 2d

Author
Message
Linuus
13
Years of Service
User Offline
Joined: 16th Jul 2010
Location:
Posted: 18th Jul 2010 19:02
So, I'm new to both c++ and DarkGDK and I have a question.
I've just started to make my first game, some kind of platformer.
The gravity and collition is handled like this (inside the While LoopGDK)



This works great except that the dbSpriteCollision returns 1 as soon as the Sprites touch each other, but I want the sprite 3 (player) to stop a little inside the sprite 2 (ground). Soo it looks like both feet are on the ground. (See the image and you will understand the problem)

So is there any way to make the dbSpriteCollision check a box smaller then the image itself?[img]null[/img]


HEre's the whole code if that helps.
Linuus
13
Years of Service
User Offline
Joined: 16th Jul 2010
Location:
Posted: 18th Jul 2010 21:25
Also, here is an more important issue.
When testing collision with more then one sprite (dbSpriteCollision(x, 0) it always returns the Sprite# of the background instead of the platform. How do I make dbSpriteCollision ignore certain sprites?
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 19th Jul 2010 11:21
Quote: "So is there any way to make the dbSpriteCollision check a box smaller then the image itself?"


Could you not change the sprite in some external editor(photoshop, paint etc) so its feet are at the bottom of the sprite image?


Quote: "When testing collision with more then one sprite (dbSpriteCollision(x, 0) it always returns the Sprite# of the background instead of the platform. How do I make dbSpriteCollision ignore certain sprites? "


Using 0 as the second parameter is a bad idea, its fine to start with but it wastes cpu by checking against everything. You should call this function for each sprite you actually want to check collisions with.

Keto
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location:
Posted: 20th Jul 2010 07:26
Or there is another way but I have not tested it. You could use some like: if(dbSpriteCollision(x, 0) != #OfBackgroundSprite). This is because... I think, dbSpriteCollision(x, 0) returns the number of the sprite hit... however this may just make the sprite not react with anything. I hope this helps!

I do only what is not required of me.

Login to post a reply

Server time is: 2024-07-04 09:22:37
Your offset time is: 2024-07-04 09:22:37