gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Collision detection

#35458 - bobb - Fri Feb 04, 2005 11:24 pm

Hello,

Im trying to make a little game and i made a tiled background with a sprite on it.

I want to know, is it possible for the sprite to detect if it bumps against some place in the background (pixels) or is it usual to place sprites on the map and easy detect if the x & y of the two sprites are the same. Because if i wanted some trees on my map, like I do now in the background, i should make sprites of them to detect the character (sprite) walking against the trees, 20 trees, so that means 20 sprites what seems bad to me because it uses memory?

Thanks a lot.

#35487 - blinky465 - Sat Feb 05, 2005 1:13 pm

There may be others who sucessfully use screen-data for sprite collision, but I always use sprites purely as visual aids. All my collision detection is done against values in memory.
For all the objects you want to interact with, you could create a common struct with x/y height/width properties and create a new instance of it for every on screen object.
This way, you won't hit problems when two or more objects overlap.

#35494 - bobb - Sat Feb 05, 2005 3:11 pm

Ok, thanks ill try it.

One other question, I use some wave effect but I can only get it working on text backgrounds and not on rotbg's, is there a reason it wont work on rotbg?

(its the water_effect example)

#112832 - sirpoonga - Wed Dec 20, 2006 7:12 pm

I thought I hit new instead of replay....

#114255 - QuantumDoja - Fri Jan 05, 2007 9:27 pm

Quote:
I always use sprites purely as visual aids. All my collision detection is done against values in memory.


the way it should be! :-) I think it's easier to get a clearer visualization like that.
_________________
Chris Davis

#114257 - keldon - Fri Jan 05, 2007 10:12 pm

A bit of a delayed response, 'eh'!