game/src/main.lua

40 lines
1.1 KiB
Lua

_G.CONFIG = require("conf").properties
local player = {x=0,y=0,s=4}
function love.load()
_G.scr = love.graphics.newCanvas(256,240)
end
function move(coordinate,amount)
player[coordinate] = player[coordinate]+amount
end
function update()
if love.keyboard.isDown("left") then move("x",-(player.s/2)) end
if love.keyboard.isDown("right") then move("x",(player.s/2)) end
if love.keyboard.isDown("up") then move("y",-(player.s/2)) end
if love.keyboard.isDown("down") then move("y",(player.s/2)) end
if love.keyboard.isDown("a") then move("s",1) end
if love.keyboard.isDown("z") then move("s",-1) end
end
local t = 0
function love.update(dt)
t = t + dt
while t>(1/30) do
t = t - (1/30)
update()
end
end
function love.draw()
love.graphics.setCanvas(scr)
love.graphics.setColor(0,0,0)
love.graphics.rectangle("fill",0,0,256,240)
love.graphics.setColor(1,0,0)
love.graphics.rectangle("fill",player.x,player.y,player.s,player.s)
love.graphics.setCanvas()
love.graphics.setBackgroundColor(0,0,0)
love.graphics.setColor(1,1,1)
love.graphics.draw(scr,0,0,0,2.5,2.5)
end