collision problems

BlitzPlus Forums/BlitzPlus Programming/collision problems

Nice one, Henrik.

Another couple of ideas for you, Zarwan....

Using something like the above code, you can just think of your player's position in terms of x and y on a big (larger than screen) play area. Makes things a lot less melon twisting.

To keep your player centre, screen;

map\x=player\x-screenwidth/2
mapy\y=player\y-screenheight/2
origin 0,0
render_map(map\x,map\y)
origin -map\x,-map\y
draw your player and all the baddies at their x,y positions.

Now all the game objects scroll with the map for little effort. You could also write a function to test a graphic for a precise collision with the map. Function figures out which map blocks the graphic will overlap with (e.g: if graphic has same side length as map blocks, it will overlap max 4 blocks) then do the images collide bit.