Commit 1dc2cce5f340337a8c66739a9cbdb240dfa3bf43

Authored by Geoffrey PREUD'HOMME
1 parent 71899fcf

Jeu redémarre

Showing 3 changed files with 115 additions and 104 deletions   Show diff stats
@@ -25,108 +25,6 @@ function love.load() @@ -25,108 +25,6 @@ function love.load()
25 require "bird" 25 require "bird"
26 26
27 love.graphics.setIcon( love.graphics.newImage("graphics/icon.png") ) 27 love.graphics.setIcon( love.graphics.newImage("graphics/icon.png") )
28 - imagelist = {"title", "cloud1", "cloud2", "ground", "bush1", "bush2", "powerup", "rocket", "star", "asteroid-big1", "sunglasses", "awesome", "arrow", "groundwin",  
29 - "asteroid-big2", "asteroid-small1", "asteroid-small2", "bullet", "littleexplosion", "warning", "wheatley", "alert", "randomshit", "bird"}  
30 -  
31 - for i = 1, #imagelist do  
32 - _G[imagelist[i] .. "img"] = love.graphics.newImage("graphics/" .. imagelist[i] .. ".png")  
33 - end  
34 -  
35 - fontimage = love.graphics.newImage("graphics/font.png")  
36 -  
37 - fontglyphs = "0123456789abcdefghijklmnopqrstuvwxyz.:/,'C-_>* !{}?"  
38 - fontquads = {}  
39 - for i = 1, string.len(fontglyphs) do  
40 - fontquads[string.sub(fontglyphs, i, i)] = love.graphics.newQuad((i-1)*8, 0, 8, 8, 408, 8)  
41 - end  
42 -  
43 - playerimg = love.graphics.newImage("graphics/trosh.png")  
44 - playerquad = {love.graphics.newQuad(0, 0, 14, 25, 54, 25), love.graphics.newQuad(14, 0, 14, 25, 54, 25), love.graphics.newQuad(28, 0, 26, 12, 54, 25), love.graphics.newQuad(28, 12, 26, 12, 54, 25)}  
45 -  
46 - winplayerimg = love.graphics.newImage("graphics/troshwin.png")  
47 - winplayerquad = {}  
48 - for x = 1, 4 do  
49 - winplayerquad[x] = love.graphics.newQuad((x-1)*11, 0, 11, 26, 44, 26)  
50 - end  
51 -  
52 - enemyimg = love.graphics.newImage("graphics/enemy.png")  
53 - enemyquad = {}  
54 - for y = 1, 4 do  
55 - for x = 1, 4 do  
56 - enemyquad[(y-1)*4+x] = love.graphics.newQuad((x-1)*100, (y-1)*96, 100, 96, 400, 384)  
57 - end  
58 - end  
59 -  
60 - explosionimg = love.graphics.newImage("graphics/explosion.png")  
61 - explosionquad = {}  
62 - for y = 1, 5 do  
63 - for x = 1, 5 do  
64 - explosionquad[(y-1)*5+x] = love.graphics.newQuad((x-1)*66, (y-1)*81, 66, 81, 330, 405)  
65 - end  
66 - end  
67 -  
68 - bigexplosionimg = love.graphics.newImage("graphics/bigexplosion.png")  
69 - bigexplosionquad = {}  
70 - for y = 1, 5 do  
71 - for x = 1, 5 do  
72 - bigexplosionquad[(y-1)*5+x] = love.graphics.newQuad((x-1)*108, (y-1)*121, 108, 121, 540, 605)  
73 - end  
74 - end  
75 -  
76 - splatterimg = love.graphics.newImage("graphics/splatter.png")  
77 - splatterquad = {}  
78 - for x = 1, 6 do  
79 - splatterquad[x] = love.graphics.newQuad((x-1)*64, 0, 64, 64, 384, 64)  
80 - end  
81 -  
82 - birdquad = {love.graphics.newQuad(0, 0, 29, 16, 29, 32), love.graphics.newQuad(0, 16, 29, 16, 29, 32)}  
83 -  
84 - scale = 8  
85 - local w, h = love.graphics.getMode()  
86 - if w ~= 100*scale or h ~= 80*scale then  
87 - love.graphics.setMode(100*scale, 80*scale, false, true, 0)  
88 - end  
89 - love.graphics.setIcon( love.graphics.newImage("graphics/icon.png") )  
90 -  
91 - bgmusic = love.audio.newSource("audio/trosong.ogg")  
92 - bgmusic:setLooping(true)  
93 - lasersound = love.audio.newSource("audio/laser.wav")  
94 - bigexplosionsound = love.audio.newSource("audio/bigexplosion.ogg")  
95 - explosionsound = love.audio.newSource("audio/explosion.wav")  
96 - launchsound = love.audio.newSource("audio/launch.ogg")  
97 - gunfire = love.audio.newSource("audio/gunfire.wav")  
98 - space = love.audio.newSource("audio/space.ogg")  
99 - sunglassessound = love.audio.newSource("audio/sunglasses.ogg")  
100 - splat = love.audio.newSource("audio/splat.ogg")  
101 - ding = love.audio.newSource("audio/ding.ogg")  
102 - credits = love.audio.newSource("audio/credits.ogg")  
103 - approach = love.audio.newSource("audio/approach.ogg")  
104 - credits:setLooping(true)  
105 -  
106 - skipupdate = true  
107 - shakeamount = 0  
108 - shake = 0  
109 - fade = 0  
110 - playerframe = 1  
111 - scoreanim = 1  
112 - rainbowi = 0.5  
113 - sini = 0  
114 - sini2 = math.pi/2  
115 - scrollx = 0  
116 - points = 0  
117 - machinedelay = 0.05  
118 - stars = {}  
119 - explosions = {}  
120 - backgroundstripes = 10  
121 - sunrot = 0  
122 -  
123 - lasers = {}  
124 -  
125 - realasteroiddelay = 1  
126 - movement1speed = 100  
127 - laserdelay = 0  
128 - reallaserdelay = 0.4  
129 - starttimer = 0  
130 changegamestate("menu") 28 changegamestate("menu")
131 end 29 end
132 30
@@ -237,6 +135,7 @@ end @@ -237,6 +135,7 @@ end
237 135
238 function changegamestate(i) 136 function changegamestate(i)
239 gamestate = i 137 gamestate = i
  138 + print("-- " .. gamestate)
240 if _G[gamestate .. "_load"] then 139 if _G[gamestate .. "_load"] then
241 _G[gamestate .. "_load"]() 140 _G[gamestate .. "_load"]()
242 end 141 end
1 function menu_load() 1 function menu_load()
  2 + imagelist = {"title", "cloud1", "cloud2", "ground", "bush1", "bush2", "powerup", "rocket", "star", "asteroid-big1", "sunglasses", "awesome", "arrow", "groundwin",
  3 + "asteroid-big2", "asteroid-small1", "asteroid-small2", "bullet", "littleexplosion", "warning", "wheatley", "alert", "randomshit", "bird"}
  4 +
  5 + for i = 1, #imagelist do
  6 + _G[imagelist[i] .. "img"] = love.graphics.newImage("graphics/" .. imagelist[i] .. ".png")
  7 + end
  8 +
  9 + fontimage = love.graphics.newImage("graphics/font.png")
  10 +
  11 + fontglyphs = "0123456789abcdefghijklmnopqrstuvwxyz.:/,'C-_>* !{}?"
  12 + fontquads = {}
  13 + for i = 1, string.len(fontglyphs) do
  14 + fontquads[string.sub(fontglyphs, i, i)] = love.graphics.newQuad((i-1)*8, 0, 8, 8, 408, 8)
  15 + end
  16 +
  17 + playerimg = love.graphics.newImage("graphics/trosh.png")
  18 + playerquad = {love.graphics.newQuad(0, 0, 14, 25, 54, 25), love.graphics.newQuad(14, 0, 14, 25, 54, 25), love.graphics.newQuad(28, 0, 26, 12, 54, 25), love.graphics.newQuad(28, 12, 26, 12, 54, 25)}
  19 +
  20 + winplayerimg = love.graphics.newImage("graphics/troshwin.png")
  21 + winplayerquad = {}
  22 + for x = 1, 4 do
  23 + winplayerquad[x] = love.graphics.newQuad((x-1)*11, 0, 11, 26, 44, 26)
  24 + end
  25 +
  26 + enemyimg = love.graphics.newImage("graphics/enemy.png")
  27 + enemyquad = {}
  28 + for y = 1, 4 do
  29 + for x = 1, 4 do
  30 + enemyquad[(y-1)*4+x] = love.graphics.newQuad((x-1)*100, (y-1)*96, 100, 96, 400, 384)
  31 + end
  32 + end
  33 +
  34 + explosionimg = love.graphics.newImage("graphics/explosion.png")
  35 + explosionquad = {}
  36 + for y = 1, 5 do
  37 + for x = 1, 5 do
  38 + explosionquad[(y-1)*5+x] = love.graphics.newQuad((x-1)*66, (y-1)*81, 66, 81, 330, 405)
  39 + end
  40 + end
  41 +
  42 + bigexplosionimg = love.graphics.newImage("graphics/bigexplosion.png")
  43 + bigexplosionquad = {}
  44 + for y = 1, 5 do
  45 + for x = 1, 5 do
  46 + bigexplosionquad[(y-1)*5+x] = love.graphics.newQuad((x-1)*108, (y-1)*121, 108, 121, 540, 605)
  47 + end
  48 + end
  49 +
  50 + splatterimg = love.graphics.newImage("graphics/splatter.png")
  51 + splatterquad = {}
  52 + for x = 1, 6 do
  53 + splatterquad[x] = love.graphics.newQuad((x-1)*64, 0, 64, 64, 384, 64)
  54 + end
  55 +
  56 + birdquad = {love.graphics.newQuad(0, 0, 29, 16, 29, 32), love.graphics.newQuad(0, 16, 29, 16, 29, 32)}
  57 +
  58 + scale = 8
  59 + local w, h = love.graphics.getMode()
  60 + if w ~= 100*scale or h ~= 80*scale then
  61 + love.graphics.setMode(100*scale, 80*scale, false, true, 0)
  62 + end
  63 + love.graphics.setIcon( love.graphics.newImage("graphics/icon.png") )
  64 +
  65 + bgmusic = love.audio.newSource("audio/trosong.ogg")
  66 + bgmusic:setLooping(true)
  67 + lasersound = love.audio.newSource("audio/laser.wav")
  68 + bigexplosionsound = love.audio.newSource("audio/bigexplosion.ogg")
  69 + explosionsound = love.audio.newSource("audio/explosion.wav")
  70 + launchsound = love.audio.newSource("audio/launch.ogg")
  71 + gunfire = love.audio.newSource("audio/gunfire.wav")
  72 + space = love.audio.newSource("audio/space.ogg")
  73 + sunglassessound = love.audio.newSource("audio/sunglasses.ogg")
  74 + splat = love.audio.newSource("audio/splat.ogg")
  75 + ding = love.audio.newSource("audio/ding.ogg")
  76 + credits = love.audio.newSource("audio/credits.ogg")
  77 + approach = love.audio.newSource("audio/approach.ogg")
  78 + credits:setLooping(true)
  79 +
  80 + skipupdate = true
  81 + shakeamount = 0
  82 + shake = 0
  83 + fade = 0
  84 + playerframe = 1
  85 + scoreanim = 1
  86 + rainbowi = 0.5
  87 + sini = 0
  88 + sini2 = math.pi/2
  89 + scrollx = 0
  90 + points = 0
  91 + machinedelay = 0.05
  92 + stars = {}
  93 + explosions = {}
  94 + backgroundstripes = 10
  95 + sunrot = 0
  96 +
  97 + lasers = {}
  98 +
  99 + realasteroiddelay = 1
  100 + movement1speed = 100
  101 + laserdelay = 0
  102 + reallaserdelay = 0.4
  103 + starttimer = 0
  104 +
  105 + rockets = nil
  106 + jumped = nil
  107 + landing = nil
  108 + sunglasses = nil
  109 + massenemies = nil
  110 +
2 love.graphics.setBackgroundColor(153, 217, 234) 111 love.graphics.setBackgroundColor(153, 217, 234)
3 clouds = {} 112 clouds = {}
4 bushes = {} 113 bushes = {}
@@ -176,12 +176,15 @@ function scene6_draw() @@ -176,12 +176,15 @@ function scene6_draw()
176 end 176 end
177 177
178 if ended and starttimer % (5/12) > (5/24) then 178 if ended and starttimer % (5/12) > (5/24) then
179 - properprint("appuie sur espace pour recommencer", 15, 50, scale/4); 179 + properprint("appuie sur espace pour recommencer", 15, 50, scale/4)
180 end 180 end
181 end 181 end
182 182
183 function scene6_keypressed(key, unicode) 183 function scene6_keypressed(key, unicode)
184 if ended then 184 if ended then
185 - love.event.quit() 185 + credits:pause()
  186 + changegamestate("menu")
  187 + -- love.load()
  188 + -- love.event.quit()
186 end 189 end
187 end 190 end