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 / How to Ignore Collision with the Color Key of a Sprite

Author
Message
TokenFlyer
12
Years of Service
User Offline
Joined: 22nd Apr 2012
Location:
Posted: 24th Apr 2012 23:56
My question is just what the title says. How do I make more complex sprites and have their wrapping only around the edges. Is it possible? I was thinking I could maybe somehow ignore collision with the color keyed part of the sprite, but I don't know how one would do that. The only solution I could think of is to put multiple sprites on top of each other, but this is a really clunky solution.

adsfffffdscsdd
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 25th Apr 2012 04:05
Something like that you've got at least these few options:

1. Pixel perfect collision (slow)
2. Multiple images/sprites to make one object
3. Collision boxes within the sprite and check collision that way instead of the built in way (recommended alternative)

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
TokenFlyer
12
Years of Service
User Offline
Joined: 22nd Apr 2012
Location:
Posted: 25th Apr 2012 07:54
how would I make collision boxes within the sprite? Im doing all my sprites in paint as I'm only making a fairly basic 2d game.

adsfffffdscsdd
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 25th Apr 2012 13:33
You would need to set up the more complex sprites yourself for handling box collision:



Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 26th Apr 2012 02:21
If you are making a side-scroller, you could make custom pixil collisions from each sprite. To do this, you would want to make a structure to hold the info:

As promissed, here is the "findfree" stuff:

The same process is used to find a free sprite or object or whatever....
I assume you already have a method for making the map..... If not, just make an array for the "ground sprites" (I assume you need to collide with the ground). When moving along the ground, check to see where you are in your array of ground sprites and test the height of your character with respect to the ground height.

Here is the process I would use:
Make all your ground sprites the same width. This is the easiest mathematical approach. Place them sequentually from left to right, butting each one up to the previous one (this is not completely necessary because you could have gaps to fall through if you want). Because you are pasting sprites, you can use the same sprite as many times as you want without duplicating it in memory-- you loose one key funtionallity though: sprite collision. This won't be a problem, because you aren't using it anyway. As I said, you would put them in sequence, but you don't have to have them at the same Y value. This could be used to make slopes and walls.

This bit of info should spark some thought. If you need more detail, I will be happy to give you more.

The fastest code is the code never written.

Login to post a reply

Server time is: 2024-11-19 02:41:15
Your offset time is: 2024-11-19 02:41:15