Code: Select all
function love.load()
ranposX = love.math.random(0, 500)
x = 250
y = 400
movey = 0
end
function love.update(dt)
if love.keyboard.isDown("right") then
x = x + 2
end
if love.keyboard.isDown("left") then
x = x - 2
end
if love.keyboard.isDown("left") and love.keyboard.isDown("s") then
x = x - 4
end
if love.keyboard.isDown("right") and love.keyboard.isDown("s") then
x = x + 4
end
if x < 0 then
x = 0
elseif (x + 30) > 500 then
x = 500 - 30
end
repeat
movey = movey + 3
until movey == 500
end
function love.draw()
love.graphics.rectangle("fill", ranposX, movey, 25, 25)
love.graphics.setBackgroundColor(39, 77, 126)
love.graphics.rectangle("fill", x, y, 30, 30)
end