/
spotify.lua
104 lines (85 loc) · 3.27 KB
/
spotify.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
function spotify_init()
spotify = {}
spotify.back = love.graphics.newImage("/sprites/Spotify/Spotify_Background.png")
spotify.cd = {}
spotify.cd.off = {}
spotify.cd.on = {}
spotify.cd.statut = {false, false, false, false}
table.insert(spotify.cd.off, love.graphics.newImage("/sprites/Spotify/Spotify_CD1.png"))
table.insert(spotify.cd.off, love.graphics.newImage("/sprites/Spotify/Spotify_CD3.png"))
table.insert(spotify.cd.off, love.graphics.newImage("/sprites/Spotify/Spotify_CD5.png"))
table.insert(spotify.cd.off, love.graphics.newImage("/sprites/Spotify/Spotify_CD7.png"))
table.insert(spotify.cd.on, love.graphics.newImage("/sprites/Spotify/Spotify_CD2.png"))
table.insert(spotify.cd.on, love.graphics.newImage("/sprites/Spotify/Spotify_CD4.png"))
table.insert(spotify.cd.on, love.graphics.newImage("/sprites/Spotify/Spotify_CD6.png"))
table.insert(spotify.cd.on, love.graphics.newImage("/sprites/Spotify/Spotify_CD8.png"))
spotify.note = {}
spotify.tic = 60
spotify_generate_note()
spotify.demo_rank = 1
spotify_demo(spotify.demo_rank)
spotify.on_demo = true
end
function spotify_update()
if spotify.tic ~= 0 then spotify.tic = spotify.tic - 1 end
if spotify.on_demo then
if spotify.tic == 0 then
spotify_demo(spotify.demo_rank)
end
end
end
function spotify_draw()
love.graphics.draw(spotify.back, 20, 60)
love.graphics.print(spotify.tic)
if spotify.cd.statut[1] then
love.graphics.draw(spotify.cd.on[1], 30, 70)
else
love.graphics.draw(spotify.cd.off[1], 30, 70)
end
if spotify.cd.statut[2] then
love.graphics.draw(spotify.cd.on[2], 160, 70)
else
love.graphics.draw(spotify.cd.off[2], 160, 70)
end
if spotify.cd.statut[3] then
love.graphics.draw(spotify.cd.on[3], 30, 200)
else
love.graphics.draw(spotify.cd.off[3], 30, 200)
end
if spotify.cd.statut[4] then
love.graphics.draw(spotify.cd.on[4], 160, 200)
else
love.graphics.draw(spotify.cd.off[4], 160, 200)
end
end
function spotify_generate_note()
table.insert(spotify.note, math.floor(math.random(4)))
end
function spotify_demo(rank)
if spotify.note[rank] == 1 then
spotify.cd.statut[1] = true
spotify.cd.statut[2] = false
spotify.cd.statut[3] = false
spotify.cd.statut[4] = false
elseif spotify.note[rank] == 2 then
spotify.cd.statut[2] = true
spotify.cd.statut[1] = false
spotify.cd.statut[3] = false
spotify.cd.statut[4] = false
elseif spotify.note[rank] == 3 then
spotify.cd.statut[3] = true
spotify.cd.statut[1] = false
spotify.cd.statut[2] = false
spotify.cd.statut[4] = false
elseif spotify.note[rank] == 4 then
spotify.cd.statut[4] = true
spotify.cd.statut[1] = false
spotify.cd.statut[2] = false
spotify.cd.statut[4] = false
end
if spotify.demo_rank == table.getn(spotify.note) then
spotify.on_demo = false
else
spotify.demo_rank = spotify.demo_rank + 1
end
end