Collisions with scenery
Blitz3D Forums/Blitz3D Beginners Area/Collisions with scenery
| ||
I'm being a bit lazy, I haven't tried this out yet in either way, as I figured other people would have come across this problem. I'm writing some code which will draw a tunnel which a ship must attempt to fly through - a bit like thrust if anyone remembers that. Although I'll be using tiles in order to draw out my map - I wondered what was the correct way to check for a collision. Looking at the help screens, I can use ImagesCollide, but it means checking with every tile that make up my map every frame. Alternatively I can work out exactly where my ship will be drawn and read the pixels to checkif I would draw the ship over the map - and blow it up if appropriate. Neither one seems brilliantly efficient - any suggestions ? |
| ||
ImagesCollide or ImagesOverlap are both efficient methods when used properly. You don't have to check your sprite against every tile, only the ones surrounding it. So do a little math or keep track of the ships position to figure out which tiles your sprite is closest to and check against only them. |