Skip to content

Commit

Permalink
basic collision detection added
Browse files Browse the repository at this point in the history
  • Loading branch information
nmichalov committed Apr 3, 2012
1 parent ad68c20 commit c7a4ed2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions main.lua
Expand Up @@ -32,24 +32,24 @@ end

function love.keypressed(key)
if love.keyboard.isDown("down") then
player.img = player.imgD
if testMap(0, 2) then
player.grid_y = player.grid_y + 32
player.img = player.imgD
end
elseif key == "up" then
player.img = player.imgU
if testMap(0, 0) then
player.grid_y = player.grid_y - 32
player.img = player.imgU
end
elseif key == "left" then
player.img = player.imgL
if testMap(-1, 1) then
player.grid_x = player.grid_x - 32
player.img = player.imgL
end
elseif key == "right" then
player.img = player.imgR
if testMap(1, 1) then
player.grid_x = player.grid_x + 32
player.img = player.imgR
end
end
print(player.grid_x, player.grid_y, player.grid_x/32, player.grid_y/32)
Expand Down

0 comments on commit c7a4ed2

Please sign in to comment.