Checking pixels in tmx files
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Checking pixels in tmx files
Hi. I am working on an engine for my later games and I'm using getPixel on a map image for collision detection, but have I realised that if my image would be larger, it would take more time to check for collisions. So I came up with the idea of checking pixels in tmx maps. Is that possible? If so, please tell me how to do it. Thanks in advance.
All your code are belong to us.
Re: Checking pixels in tmx files
Checking individual pixels in a map for collision detection is a rather slow way of doing things. Why not use a collision layer? As in, an invisible layer with a bunch of shapes denoting where the collisions are. Something like this:
(from here)
(from here)
Re: Checking pixels in tmx files
I know, but I want to experiment a bit with the different kinds of collision systems, starting with the easiest ones to implement. I have tried tile based so far, but I didn't like it, because it didn't give me enough freedom.
All your code are belong to us.
Re: Checking pixels in tmx files
Uh what? This is a bad idea for checking collision detection )szmol96 wrote:Hi. I am working on an engine for my later games and I'm using getPixel on a map image for collision detection, but have I realised that if my image would be larger, it would take more time to check for collisions. So I came up with the idea of checking pixels in tmx maps. Is that possible? If so, please tell me how to do it. Thanks in advance.
Twitter: https://twitter.com/Murii5
Re: Checking pixels in tmx files
Ok, I will listen to you guys, pixel collision may be slow, but i don't know how to make any other collision system, except tile based. The one with polygons sounds good, but I have no idea how to implement it. Can somebody explain it, including the details?
All your code are belong to us.
Re: Checking pixels in tmx files
I wouldn't say, that pixel based collision is bad per se. But it is probably not easy to implement.
The same goes for vector based collision. It is not easy to implement. I would rather use a library that does it for me, such as the love.physics module.
This article gives a nice comparison of the general approaches to collision detection.
In the Free Game Resources Section of the wiki you finde some in depth tutorials on collision detection with different approaches.
The same goes for vector based collision. It is not easy to implement. I would rather use a library that does it for me, such as the love.physics module.
This article gives a nice comparison of the general approaches to collision detection.
In the Free Game Resources Section of the wiki you finde some in depth tutorials on collision detection with different approaches.
Check out my blog on gamedev
Re: Checking pixels in tmx files
Pixel collision will be fine for me, but how can I make it faster if I plan on making huge levels?
All your code are belong to us.
- HugoBDesigner
- Party member
- Posts: 403
- Joined: Mon Feb 24, 2014 6:54 pm
- Location: Above the Pocket Dimension
- Contact:
Re: Checking pixels in tmx files
The problem with pixel collision is that it is slow under most circumstances. Making the computer check thousands of pixels everytime is slow. Are you checking them every frame? If you are, just compare the pixels in an area close to the player (for example, pixels in a radius of 50 pixels around the player). Depending on what you have this can work very well
Re: Checking pixels in tmx files
That's pretty much the tradeoff of using such an expensive algorithm. Either keep your levels small, use polygons, or don't use LOVE.szmol96 wrote:Pixel collision will be fine for me, but how can I make it faster if I plan on making huge levels?
Depending on the level of detail and intricacy in your game, a good method for you would be to use the love.physics module along with using tiled maps with a library like STI, then using object layers in Tiled for collision zones.
Re: Checking pixels in tmx files
I only check pixels around the player and at some bullets' position. Is that still slow?HugoBDesigner wrote:The problem with pixel collision is that it is slow under most circumstances. Making the computer check thousands of pixels everytime is slow. Are you checking them every frame? If you are, just compare the pixels in an area close to the player (for example, pixels in a radius of 50 pixels around the player). Depending on what you have this can work very well
All your code are belong to us.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot], Majestic-12 [Bot] and 165 guests