blob: 35aacbc8ced441a4514d264c2bb6989275c2faca (
plain)
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
65
66
67
68
|
function love.load()
-- window --
love.window.setMode(250, 250)
-- animation --
delta = 0
fps = 1
a_animation = 1
a_frames = 7
a_draw = 'A'
b_animation = 1
b_frames = 3
b_draw = 'B'
animation = a_animation
frames = a_frames
draw = a_draw
end
function love.keypressed(key, scancode)
-- exit --
if scancode == 'q' or scancode == 'escape' then
love.event.quit()
end
-- animation --
if scancode == 'a' then
animationKey = true
animation = b_animation
frames = b_frames
end
end
function love.keyreleased(key, scancode)
-- animation --
if scancode == 'a' then
animationKey = false
animation = a_animation
frames = a_frames
end
end
function love.update(dt)
-- animation --
delta = delta + dt
if delta >= (1 / fps) then
delta = delta - (1 / fps)
if animation < frames then
animation = animation + 1
else
animation = 1
end
end
if animationKey == true then
draw = b_draw
elseif animationKey == false then
draw = a_draw
end
end
function love.draw()
-- animation --
love.graphics.print(draw, 0)
love.graphics.print(animation, 10)
end
|