-
Notifications
You must be signed in to change notification settings - Fork 0
/
tutorial.lua
executable file
·64 lines (54 loc) · 1.34 KB
/
tutorial.lua
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
62
63
64
--lua/love notes:
function love.load()
image = love.graphics.newImage("cake.jpg")
love.graphics.setNewFont(12)
love.graphics.setColor(0,0,0)
love.graphics.setBackgroundColor(255,255,255)
end
function love.update(dt)
if love.keyboad.isDown("up") then
num = num + 100*dt -- this would increment num by 100 per second
end
end
function love.draw()
love.graphics.draw(image,imgx,imgy)
love.graphics.print("Click and drag the cake around of use the arrow keys.", 10, 10)
end
-- called continuously
function love.mousepressed(x,y,button)
if button == 'l' then
imgx = x -- move image to where mouse clicked
imgy = y -- move image to where mouse clicked
end
end
function love.mousereleased(x,y,button)
if button == 'l' then
fireSlingshot(x,y) -- this would be defined somewhere else
end
end
function love.keypressed(key)
if key == 'b' then
text = "the B key was pressed."
elseif key == 'a' then
a_down = true
end
end
function love.keyreleased(key)
if key == 'b' then
text = "the B key was released."
elseif key == 'a' then
a_down = false
end
end
function love.focus(f)
if not f then
print("Lost focus")
else
print("GAINED FOCUS")
end
end
--f is true when the player is focused on the LOVE window and not, say the internet browser
function love.quit()
print("THANKS FOR PLAYING!")
end
--called when the window is closed by the player