-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
61 lines (50 loc) · 1.56 KB
/
main.lua
File metadata and controls
61 lines (50 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
_G.love = love
local bito8 = require("bito8")
local player = {
x = 100,
y = 100,
image = nil,
angle = 0
}
function love.load()
player.image = bito8.imageConvertor("player.png")
end
function love.update(dt)
if love.keyboard.isDown("a") or love.keyboard.isDown("left") then
player.x = player.x - 60 * dt
end
if love.keyboard.isDown("d") or love.keyboard.isDown("right") then
player.x = player.x + 60 * dt
end
if love.keyboard.isDown("w") or love.keyboard.isDown("up") then
player.y = player.y - 60 * dt
end
if love.keyboard.isDown("s") or love.keyboard.isDown("down") then
player.y = player.y + 60 * dt
end
player.angle = player.angle + 2 * dt
end
function love.draw()
bito8.graphics.clear(0, 0, 0)
bito8.graphics.setColor(255, 255, 255)
bito8.graphics.scale(1)
bito8.graphics.text(10, 10, "FPS: "..love.timer.getFPS())
bito8.graphics.push()
bito8.graphics.setColor(255, 255, 0)
bito8.graphics.scale(2)
bito8.graphics.rotate(player.angle)
bito8.graphics.image(player.x, player.y, player.image)
bito8.graphics.pop()
bito8.graphics.push()
bito8.graphics.setColor(255, 0, 0)
bito8.graphics.rectangle(200, 150, 50, 50, false)
bito8.graphics.pop()
bito8.graphics.fill(210, 160, {0, 255, 0})
bito8.graphics.setColor(0, 255, 0)
bito8.graphics.line(0, 0, 400, 300)
bito8.graphics.push()
bito8.graphics.setColor(255, 255, 255)
bito8.graphics.circle(100, 100, 50, true)
bito8.graphics.pop()
bito8.draw()
end