The way I'm using collision for walls so far is this. I've made a function which is:
Code:
function wallcollision(x1,x2,y1,y2)
if x > x1 and x < x2 and y > y1 and y < y2 then
x = oldx
y = oldy
end
end
So basicly it creates a square or rectangle area which cannot be walked through by the player. It is called in the game like so:
Code:
wallcollision(0,450,0,14) -- top wall
wallcollision(87,123,0,93) -- top up and down left side
wallcollision(337,374,0,92) -- top up and down right side
wallcollision(0,15,0,271) -- left side wall
wallcollision(0,166,162,196) -- mid wall left to right left side
wallcollision(0,470,243,271) -- bottom wall
wallcollision(224,262,56,97) -- middle square piece
wallcollision(205,275,95,182) -- middle round piece
wallcollision(447,480,0,280) -- right side wall
The annoying part is that for every single wall I have to manually get the coordinates to make collision for that wall. I'm sure someone has a better and quicker way, if so I'd like to know.