Game Development Community

Bitmap Collision

by Trent · in Torque X 2D · 12/11/2006 (9:11 pm) · 9 replies

Seeing that XNA supports sprites, does TX support bitmap collisions?

I am finding it near impossible to make a pacman style game using TGB, and I was about to start again using XNA, but I'm really hoping I can do basic collision without all the bits that get jittery on me with TGB.

#1
12/11/2006 (9:24 pm)
In TGB are you using a tilemap for your level and setting the boundaries walls etc with the collision check box so you can collide against it? Not sure what you mean by bitmap collisions. Do you mean per pixel collision? As far as I know there isn't that support however whatever kind of convex bounds you can create you can collide with.
#2
12/11/2006 (10:12 pm)
As a suggestion, try turning on collisions for your tiles (per Matthew's suggestion) and then make sure you don't have any physics enables on your player sprite. Instead, simply handle the "onCollision" callback and handle the result there (which would typically be to just stop the object).
#3
12/11/2006 (10:30 pm)
I am using a tilemap and I have set the collisions, but I'm getting strange behaviour, such as going into an object by 1 pixel, and the jitters...

Someone told me to use paths instead, but that just isnt practical.

I first tried to just use sprites, then I found tilemaps, but I have the same issues with both. I did see some posts in the TGB Collisions forum about inherent problems brought on by the CLAMP system and that collision system is all physics.

Yes, by bitmap I do mean pixel collisions, ie if (p.x >= t.x && p.x < t.x + t.width)

I'm just looking to make an old style game that has power of 2 image widths thing going on.
#4
12/11/2006 (10:31 pm)
@Jason,

I've tried so many options now that I'll give anything a try even if I've already tried it.

Will give it a shot soon.
#5
12/11/2006 (11:31 pm)
I don't believe that XNA supports per-pixel collisions, especially if it's largely a rewrite of the TGB engine. That said, I've had success in the past with getting collisions to work and do exactly what you are asking for. BUT, I never allowed the built-in collision responses to run. I just handled the onCollision myself and created my own collision responses. I never had any issues with "jittering" in my scripts.
#6
12/12/2006 (12:29 am)
Interesting... I thought I had tried this in the past, but I guess I hadn't.

It's not perfect, I still get stuck, but its the best result I've had so far.
#7
12/14/2006 (2:35 pm)
I remember a while back in the beginning days of XNA there was an example of a perpixel collision class done in XNA. It was somewhere on LearnXNA. I'm sure you could get it to work in TorqueX.
#8
12/14/2006 (9:20 pm)
This was my point... I know per pixel can be done in XNA, and I know how to do it. It's in the docs no less. But whether I can grab a Texture2D and just whack it on a TX screen or not is something I don't as yet know. I'm currently way too busy with work to find time to even try it atm :(
#9
12/16/2006 (10:17 am)
Anything's possible. It's just code. TorqueX does not implement pixel-collision. But you could.