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 Masks and Animated Sprites

Author
Message
replax
14
Years of Service
User Offline
Joined: 25th Oct 2009
Location:
Posted: 1st May 2010 12:14
hey guys,

in my 2d game, i use pixel perfect collision. i build the sprite masks for it with another tool for each image file that I use in my game. then upon game start, those sprite masks (stored in a txt like file with 0s for non collidable and 1s for collidable) are being loaded into memory and associated with the corresponding sprite object. then whenever a rectangle collision takes place i check each sprite mask for pixel perfect collision. it works very well, even with a lot of objects on screen.
i just got one problem, it does not work with animated sprites.
the sprite masks always look like the image itself, for animated images they look like the whole image though.
however, a displayed animated sprite is just as big as one tile of the image. now, i could create individual sprite masks for each frame, which would result in a total mess.
the spritemasks are stored in a vector<int>.
are you guys aware of an efficient method of how to test a frame against the corresponding sprite mask without having to jump across the spritemask 60 times a sek for each frame?

yours sincerely,

replax
bloodmage2
15
Years of Service
User Offline
Joined: 14th Jun 2009
Location:
Posted: 26th May 2010 18:40
you could have a separate file that contains the spritemasks for each frame (similar to how you disect an image to form an animated sprite) that is refrenced when the spritemask file encounters it.

-to the optimist, the glass is half full. to the pessimist, it is half empty, to the engineer, it is twice as big as it needs to be.
http://www.lionsbloodstudios.justinman.net/index.htm

Login to post a reply

Server time is: 2024-07-07 00:32:38
Your offset time is: 2024-07-07 00:32:38