39 lines
811 B
Lua
39 lines
811 B
Lua
player = {
|
|
x = 100,
|
|
y = 100,
|
|
angle = 0
|
|
}
|
|
speed = 200
|
|
|
|
function love.load()
|
|
end
|
|
|
|
function love.update(dt)
|
|
if love.keyboard.isDown("space") then
|
|
player.x = player.x + dt * math.sin(player.angle) * speed
|
|
player.y = player.y - dt * math.cos(player.angle) * speed
|
|
end
|
|
if love.keyboard.isDown("left") then
|
|
player.angle = player.angle - dt
|
|
elseif love.keyboard.isDown("right") then
|
|
player.angle = player.angle + dt
|
|
end
|
|
end
|
|
|
|
FRONT_SIZE = 20
|
|
BACK_SIZE = 20
|
|
ship_shape = {
|
|
0, -FRONT_SIZE,
|
|
-10, BACK_SIZE,
|
|
10, BACK_SIZE
|
|
}
|
|
|
|
function love.draw()
|
|
love.graphics.setColor(0, 0.6, 0.0)
|
|
love.graphics.push()
|
|
love.graphics.translate(player.x, player.y)
|
|
love.graphics.rotate(player.angle)
|
|
love.graphics.polygon('line', ship_shape)
|
|
love.graphics.pop()
|
|
end
|