diff options
author | Aki <nthirtyone@gmail.com> | 2016-05-13 15:00:13 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2016-05-13 15:00:13 +0200 |
commit | 0506e2dd9cb9641486bbfc7908c0399b26e1ce3c (patch) | |
tree | 1d673944ed31946959f4b08c9c412cc8f2df12d5 /main.lua | |
parent | 7d4251e3a9c08b89d25ef724270752f36649f765 (diff) | |
download | roflnauts-0506e2dd9cb9641486bbfc7908c0399b26e1ce3c.zip roflnauts-0506e2dd9cb9641486bbfc7908c0399b26e1ce3c.tar.gz roflnauts-0506e2dd9cb9641486bbfc7908c0399b26e1ce3c.tar.bz2 |
Basic camera added
Diffstat (limited to 'main.lua')
-rw-r--r-- | main.lua | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -3,6 +3,7 @@ require "ground" require "player" +require "camera" debug = false @@ -15,7 +16,7 @@ function love.load () love.physics.setMeter(64) world = love.physics.newWorld(0, 9.81*64, true) world:setCallbacks(beginContact, endContact, preSolve, postSolve) - + -- Platforms (`Ground`) Platforms = {} table.insert(Platforms, Ground:new(world, 290/2, 180/2, {-91,0, 90,0, 90,10, 5,76, -5,76, -91,10}, "assets/platform_big.png")) @@ -36,11 +37,15 @@ function love.load () Nauts[2].key_down = "s" Nauts[2].key_jump = "h" Nauts[2].key_hit = "g" + + -- Camera + camera = Camera:new() end function love.update (dt) -- Put world in motion! world:update(dt) + camera:moveFollow() -- Players for k,naut in pairs(Nauts) do naut:update(dt) @@ -73,14 +78,15 @@ function love.draw () love.graphics.setColor(179, 82, 80, 255) love.graphics.rectangle("fill", 0, 160, love.graphics.getWidth(), 40) + local offset_x, offset_y = camera:getOffsets() -- Draw ground for k,platform in pairs(Platforms) do - platform:draw(0, 0, debug) + platform:draw(offset_x, offset_y, debug) end -- Draw player for k,naut in pairs(Nauts) do - naut:draw(0, 0, debug) + naut:draw(offset_x, offset_y, debug) end end |