stage 1
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
local screen_width, screen_height = love.graphics.getDimensions()
|
||||
|
||||
local player_ship = {
|
||||
position_x = screen_width / 2,
|
||||
position_y = screen_height / 2,
|
||||
velocity_x = 0,
|
||||
velocity_y = 0,
|
||||
acceleration = 100,
|
||||
radar_size = 10,
|
||||
}
|
||||
|
||||
function love.update(dt)
|
||||
if love.keyboard.isDown("w") then
|
||||
player_ship.velocity_y = player_ship.velocity_y - player_ship.acceleration * dt
|
||||
end
|
||||
if love.keyboard.isDown("a") then
|
||||
player_ship.velocity_x = player_ship.velocity_x - player_ship.acceleration * dt
|
||||
end
|
||||
if love.keyboard.isDown("s") then
|
||||
player_ship.velocity_y = player_ship.velocity_y + player_ship.acceleration * dt
|
||||
end
|
||||
if love.keyboard.isDown("d") then
|
||||
player_ship.velocity_x = player_ship.velocity_x + player_ship.acceleration * dt
|
||||
end
|
||||
|
||||
player_ship.position_x = player_ship.position_x + player_ship.velocity_x * dt
|
||||
player_ship.position_y = player_ship.position_y + player_ship.velocity_y * dt
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
-- love.graphics.circle("fill", player_ship.position_x, player_ship.position_y, 5)
|
||||
love.graphics.rectangle("line", player_ship.position_x - player_ship.radar_size / 2, player_ship.position_y - player_ship.radar_size / 2, player_ship.radar_size, player_ship.radar_size)
|
||||
end
|
||||
|
||||
function love.keypressed(key)
|
||||
if key == "escape" then
|
||||
love.event.quit()
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user