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.

2D All the way! / Theory -> Tile Collision?

Author
Message
Kanzure
21
Years of Service
User Offline
Joined: 19th Feb 2003
Location:
Posted: 21st Jul 2003 04:18
I hate Tile by Tile collision in Tile Engines. Is there any other ways?

I recently have been playing Legacy of Goku 2 for the GBA, and the collision their seems to be amazing -- maybe a pixel barrier or something..but I have no clue how to do that O.o
~Morph/Kanzure
CodeNation
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 21st Jul 2003 20:37
I have no idea how *they* do it, but I might do it something like this:

Have two tile layers:

The first layer would be graphical only with no transparency and no collision detection.

The second layer would have transparent areas with an alpha level of 0, and graphical areas with an alpha level of 255.

I would then use a modified version of my pixel perfect sprite collision routine to detect collisions between the sprite, and the images under and bordering the sprite to check for collisions of pixels with alpha values.

If the collision occurs, I would move the sprite back towards its original location a pixel at a time until no collision occurs.

Assuming that the sprite is the same size as the tile, this only means 4 collision checks per frame when no collision occurs (assuming tiles that can be collided with are in contact with the sprite), and 4 + number of pixels moved when a collision does occur - easily within the reach of any machine running DBPro.
LuciferX
20
Years of Service
User Offline
Joined: 16th May 2003
Location: United States
Posted: 21st Jul 2003 21:01
thank you Kanzure
for bringing up a very good point,

good luck

Do or do not, there is no try. -Yoda
Kanzure
21
Years of Service
User Offline
Joined: 19th Feb 2003
Location:
Posted: 21st Jul 2003 21:22
Somebody suggested @ allegro.cc that I have bitmasks..or something..and I make each pixel either 0 or 1 for walkable/not..And then I make this in a map editor of course.....but my problem is I don't know how to make a map editor do this..(fyi - its in c/c++!)

~Morph/Kanzure
CodeNation
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 21st Jul 2003 22:05
well, it would be easy with the point command but it's just too damn slow in DBPro, might be ok in DB? otherwise, You need to create a arraymap of each tile and base all movement off of the array. still shouldn't to hard to do.

IanMs methode might be easier, but I think a mapmask would be faster. I made a little something like this a while back but never made it into a scrolling map function, it was just a background picture with a movement mask underlay. I belive it will work pretty good.

CTP
Kanzure
21
Years of Service
User Offline
Joined: 19th Feb 2003
Location:
Posted: 21st Jul 2003 22:42
Eh, I know what I'm going to do now - just bitmasks w/ 1 or 0...I guess thats an okay method, I'm just worried it will take too much processing time...

~Morph/Kanzure
CodeNation
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 21st Jul 2003 23:02
I never really considered using the point function to detect collision:

1) It's too slow
2) What colours can be collided with? Either black is OK (plain black background anyone?) or a set range of colours are used for no-go areas (plain graphics).

Using the array variation would speed things up, but would require at least a doubling of memory (if using 32 bit graphics)

I also dismissed bit-maps/masks:

1) More memory storage required
2) Collision is more complex
3) No editor available unless you write your own

Of course, you can always implement a bit-map collision later if you find that the existing collision is too slow, generating the bit-maps directly from your images (from the alpha value). But unless you are checking for thousands of collisions per frame, you won't get a great boost in speed.


Basically, the original way I suggested is definitely not the only way to do it and is definitely not the best way to do it, but it is a way that gives you full control over the graphics that you can see, can be done without creating any new tools, will use no memory beyond what is used for the images themselves, and is fast enough for the job.
Kanzure
21
Years of Service
User Offline
Joined: 19th Feb 2003
Location:
Posted: 21st Jul 2003 23:32
Like I said, I'm using the array method. every other way sounds too hard to code in C or too time consuming ...

All I need now is a quick way of making the array ... maybe I can cook up a quick Map Editor in DBP...

~Morph/Kanzure
CodeNation
BobCat
20
Years of Service
User Offline
Joined: 1st Jun 2003
Location:
Posted: 23rd Jul 2003 00:36 Edited at: 23rd Jul 2003 00:37
I use the point command on a pasted image and gets the data from the colors eg.Red=Block,Blue=Pass.

It means you can edit a map in a few second, just by changin an image.

>^..^< >^..^<
Kanzure
21
Years of Service
User Offline
Joined: 19th Feb 2003
Location:
Posted: 23rd Jul 2003 00:54
Thats an interesting way, but even in only 256 mode that bitmap may be a bit big..(hah..bit big..)...I got my problem solved, and collision works .. go into the General Forum and to "DragonBall V RPG" topic to read about it.

~Morph/Kanzure
CodeNation

Login to post a reply

Server time is: 2024-03-02 19:54:52
Your offset time is: 2024-03-02 19:54:52