diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 9042c25..0000000 --- a/LICENSE.txt +++ /dev/null @@ -1,13 +0,0 @@ - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - Version 2, December 2004 - - Copyright (C) 2004 Sam Hocevar - - Everyone is permitted to copy and distribute verbatim or modified - copies of this license document, and changing it is allowed as long - as the name is changed. - - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/asteroid.lua b/asteroid.lua deleted file mode 100644 index 9f221b6..0000000 --- a/asteroid.lua +++ /dev/null @@ -1,84 +0,0 @@ -asteroid = class:new() - -function asteroid:init(x, y, size) - self.x = x or math.random(80)+10 - self.y = y or -10 - self.r = math.random(math.pi*20)/10 - self.size = size or 1 - self.rspeed = (math.random()*2-1)*10 - self.speedx = math.random(5)+20 - self.speedy = math.random(5)+10 - self.i = math.random(2) - self.direction = math.random(2) - if self.direction == 2 then - self.direction = -1 - end - - if self.size == 1 then - self.hp = 12*realasteroiddelay - else - self.hp = 6*realasteroiddelay - end -end - -function asteroid:update(dt) - self.x = self.x + self.speedx*dt*self.direction - self.y = self.y + self.speedy*dt - - if self.x > 90 then - self.direction = -1 - elseif self.x < 10 then - self.direction = 1 - end - - if self.y > 40 then - self.speedy = 100 - self.direction = 0 - end - - self.r = self.r + self.rspeed*dt - - if self.y > 120 then - self.dead = true - end - - return self.dead -end - -function asteroid:hit() - self.hp = self.hp - 1 - if self.hp <= 0 then - if self.size == 1 then - table.insert(asteroids, asteroid:new(self.x, self.y, 2)) - table.insert(asteroids, asteroid:new(self.x, self.y, 2)) - pointsget(10) - else - pointsget(10) - end - lastexplosion = {self.x, self.y} - self.dead = true - table.insert(explosions, explosion:new(self.x-12, self.y-16)) - backgroundwhite = 1 - end -end - -function asteroid:checkcol(x, y) - if self.size == 1 then --big - if math.abs(self.x-x) < 9 and math.abs(self.y-y) < 9 then - return true - end - else - if math.abs(self.x-x) < 6 and math.abs(self.y-y) < 6 then - return true - end - end - return false -end - -function asteroid:draw() - if self.size == 1 then - draw(_G["asteroid-big" .. self.i .. "img"], self.x, self.y, self.r, 1, 1, 11, 9) - else - draw(_G["asteroid-small" .. self.i .. "img"], self.x, self.y, self.r, 1, 1, 11, 9) - end -end \ No newline at end of file diff --git a/audio/approach.ogg b/audio/approach.ogg deleted file mode 100644 index f2639a7..0000000 Binary files a/audio/approach.ogg and /dev/null differ diff --git a/audio/bigexplosion.ogg b/audio/bigexplosion.ogg deleted file mode 100644 index 0a487e3..0000000 Binary files a/audio/bigexplosion.ogg and /dev/null differ diff --git a/audio/credits.ogg b/audio/credits.ogg deleted file mode 100644 index 12033ef..0000000 Binary files a/audio/credits.ogg and /dev/null differ diff --git a/audio/ding.ogg b/audio/ding.ogg deleted file mode 100644 index 4c6b83a..0000000 Binary files a/audio/ding.ogg and /dev/null differ diff --git a/audio/explosion.wav b/audio/explosion.wav deleted file mode 100644 index 067b99f..0000000 Binary files a/audio/explosion.wav and /dev/null differ diff --git a/audio/gunfire.wav b/audio/gunfire.wav deleted file mode 100644 index a905579..0000000 Binary files a/audio/gunfire.wav and /dev/null differ diff --git a/audio/laser.wav b/audio/laser.wav deleted file mode 100644 index e2094bf..0000000 Binary files a/audio/laser.wav and /dev/null differ diff --git a/audio/launch.ogg b/audio/launch.ogg deleted file mode 100644 index bebea90..0000000 Binary files a/audio/launch.ogg and /dev/null differ diff --git a/audio/space.ogg b/audio/space.ogg deleted file mode 100644 index 7e41cab..0000000 Binary files a/audio/space.ogg and /dev/null differ diff --git a/audio/space.wav b/audio/space.wav deleted file mode 100644 index 902deef..0000000 Binary files a/audio/space.wav and /dev/null differ diff --git a/audio/splat.ogg b/audio/splat.ogg deleted file mode 100644 index 8bfbb4d..0000000 Binary files a/audio/splat.ogg and /dev/null differ diff --git a/audio/sunglasses.ogg b/audio/sunglasses.ogg deleted file mode 100644 index 9cec021..0000000 Binary files a/audio/sunglasses.ogg and /dev/null differ diff --git a/audio/trosong.ogg b/audio/trosong.ogg deleted file mode 100644 index eec0f34..0000000 Binary files a/audio/trosong.ogg and /dev/null differ diff --git a/bigexplosion.lua b/bigexplosion.lua deleted file mode 100644 index 6e6a53d..0000000 --- a/bigexplosion.lua +++ /dev/null @@ -1,30 +0,0 @@ -bigexplosion = class:new() - -function bigexplosion:init(x, y) - self.x = x - self.y = y - self.quad = 1 - self.quadtimer = 0 -end - -function bigexplosion:update(dt) - self.quadtimer = self.quadtimer + dt*3 - while self.quadtimer > 1 do - self.quadtimer = self.quadtimer - 1 - self.quad = self.quad + 1 - if self.quad == 26 then - return true - end - end -end - -function bigexplosion:draw() - local r, g, b = love.graphics.getColor() - if starttimer > 0 then - love.graphics.setColor(255, 255, 255, 255*math.min(1, math.max(0, (1-starttimer/7)))) - end - if self.quad <= 25 then - love.graphics.drawq(bigexplosionimg, bigexplosionquad[self.quad], self.x*scale, self.y*scale, 0, scale, scale) - end - love.graphics.setColor(r, g, b) -end \ No newline at end of file diff --git a/bird.lua b/bird.lua deleted file mode 100644 index 69fa2b6..0000000 --- a/bird.lua +++ /dev/null @@ -1,52 +0,0 @@ -bird = class:new() - -function bird:init(x, y) - self.x = math.random(100) - self.y = 90 - self.quad = 1 - self.quadtimer = 0 - self.speedx = (math.random()*2-1)*50 - self.speedy = math.random(30)+10 - - self.dir = math.random(2) - if self.dir == 2 then - self.dir = -1 - end -end - -function bird:update(dt) - self.quadtimer = self.quadtimer + dt*5 - if self.quadtimer > 1 then - self.quadtimer = self.quadtimer - 1 - if self.quad == 1 then - self.quad = 2 - else - self.quad = 1 - end - end - - self.x = self.x + self.speedx*dt*self.dir - self.y = self.y - self.speedy*dt - - if self.x > 100 then - self.dir = -1 - elseif self.x < 0 then - self.dir = 1 - end - - if self.y < -10 or self.dead then - return true - end -end - -function bird:checkcol(x, y) - if math.abs(self.x-x) < 7 and math.abs(self.y-y) < 4 then - self.dead = true - return true - end - return false -end - -function bird:draw() - love.graphics.drawq(birdimg, birdquad[self.quad], self.x*scale, self.y*scale, 0, scale/2, scale/2, 14, 8) -end \ No newline at end of file diff --git a/bullet.lua b/bullet.lua deleted file mode 100644 index f55c323..0000000 --- a/bullet.lua +++ /dev/null @@ -1,41 +0,0 @@ -bullet = class:new() - -function bullet:init(x, y, r) - self.x = x - self.y = y - self.r = r - gunfire:stop() - gunfire:play() -end - -function bullet:update(dt) - if not self.kill then - self.x = self.x + math.sin(self.r)*500*dt - self.y = self.y - math.cos(self.r)*300*dt - - for i, v in pairs(asteroids) do - if v:checkcol(self.x, self.y) and not v.dead then - v:hit() - self.kill = 0 - end - end - end - - if self.kill then - self.kill = self.kill + dt - end - - if self.kill and self.kill >= 0.2 then - return true - end -end - -function bullet:draw() - if self.kill then - love.graphics.setColor(255, 255, 255, (1-self.kill/0.2)*255) - draw(littleexplosionimg, self.x, self.y, self.r, 1, 1, 8, 4) - love.graphics.setColor(255, 255, 255, 255) - else - draw(bulletimg, self.x, self.y, self.r, 1, 1, 6, 4) - end -end \ No newline at end of file diff --git a/bush.lua b/bush.lua deleted file mode 100644 index acfc729..0000000 --- a/bush.lua +++ /dev/null @@ -1,25 +0,0 @@ -bush = class:new() - -function bush:init() - self.x = math.random()*100 - self.y = math.random()*20+57 - self.i = math.random(2) - self.speed = 50 -end - -function bush:update(dt) - if not rockets or rockets[1].x > 50 then - self.x = self.x - self.speed*dt - end - - if self.x < - _G["bush" .. self.i .. "img"]:getWidth() then - self.x = 100 - self.y = math.random()*20+57 - self.i = math.random(2) - self.speed = 50 - end -end - -function bush:draw() - draw(_G["bush" .. self.i .. "img"], self.x, self.y) -end \ No newline at end of file diff --git a/class.lua b/class.lua deleted file mode 100644 index c42e794..0000000 --- a/class.lua +++ /dev/null @@ -1,44 +0,0 @@ ---[[ -Copyright (c) 2009 Bart van Strien - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. -]] - -__HAS_SECS_COMPATIBLE_CLASSES__ = true - -local class_mt = {} - -function class_mt:__index(key) - return self.__baseclass[key] -end - -class = setmetatable({ __baseclass = {} }, class_mt) - -function class:new(...) - local c = {} - c.__baseclass = self - setmetatable(c, getmetatable(self)) - if c.init then - c:init(...) - end - return c -end \ No newline at end of file diff --git a/cloud.lua b/cloud.lua deleted file mode 100644 index 9dd6c56..0000000 --- a/cloud.lua +++ /dev/null @@ -1,30 +0,0 @@ -cloud = class:new() - -function cloud:init(random, y) - if y then - self.starty = y - end - self.x = math.random()*100 - self.y = y or math.random()*20+3 - self.i = math.random(2) - self.speed = math.random()*20+50 -end - -function cloud:update(dt) - if not rockets or rockets[1].x > 50 then - self.x = self.x - self.speed*dt - else - self.x = self.x - self.speed*0.3*dt - end - - if self.x < - _G["cloud" .. self.i .. "img"]:getWidth() then - self.x = 100 - self.y = self.starty or math.random()*20+3 - self.i = math.random(2) - self.speed = math.random()*20+50 - end -end - -function cloud:draw() - draw(_G["cloud" .. self.i .. "img"], self.x, self.y) -end \ No newline at end of file diff --git a/cloud2.lua b/cloud2.lua deleted file mode 100644 index 4cc984a..0000000 --- a/cloud2.lua +++ /dev/null @@ -1,22 +0,0 @@ -cloud2 = class:new() - -function cloud2:init(y) - self.x = math.random()*100 - self.y = 120+y - self.i = math.random(2) - self.speed = -500 -end - -function cloud2:update(dt) - self.y = self.y + self.speed*dt - - if self.y < -20 then - self.y = self.y+140 - self.x = math.random()*100 - self.i = math.random(2) - end -end - -function cloud2:draw() - draw(_G["cloud" .. self.i .. "img"], self.x, self.y, 0, 1, 1, 15) -end \ No newline at end of file diff --git a/conf.lua b/conf.lua deleted file mode 100644 index 0bdaf1a..0000000 --- a/conf.lua +++ /dev/null @@ -1,9 +0,0 @@ -function love.conf(t) - t.title = "TROSH: The Movie: The Game" - t.author = "Maurice" - t.console = false - t.screen.vsync = true - t.screen.width = 800 - t.screen.height = 640 - t.screen.fsaa = 0 -end \ No newline at end of file diff --git a/enemy.lua b/enemy.lua deleted file mode 100644 index abf285e..0000000 --- a/enemy.lua +++ /dev/null @@ -1,64 +0,0 @@ -enemy = class:new() - -function enemy:init() - self.quad = 1 - self.x = 100 - self.y = math.random()*20+40 - self.quadtimer = 0 - self.movement = math.random(7)-4 - if self.movement > 0 then - self.movement = 1 - elseif self.movement < 0 then - self.movement = -1 - end - self.speed = math.random(30)+40 - self.dead = false -end - -function enemy:update(dt) - self.quadtimer = self.quadtimer + dt*30 - if self.quadtimer > 1 then - self.quadtimer = self.quadtimer - 1 - self.quad = self.quad + 1 - if self.quad == 17 then - self.quad = 1 - end - end - - if self.movement == 1 then - self.y = self.y - dt*30 - if self.y < 40 then - self.movement = -1 - end - elseif self.movement == -1 then - self.y = self.y + dt*30 - if self.y > 70 then - self.movement = 1 - end - end - - self.x = self.x - self.speed*dt - - if self.dead then - return true - end -end - -function enemy:explode() - self.dead = true - table.insert(explosions, explosion:new(self.x-5, self.y-10)) - pointsget(1) - skycolor = getrainbowcolor(math.random()) - love.graphics.setBackgroundColor(skycolor) -end - -function enemy:checkcol(x, y, newx) - if x < self.x+4 and newx > self.x+4 and math.abs(self.y+7-y) < 6 then - return true - end - return false -end - -function enemy:draw() - love.graphics.drawq(enemyimg, enemyquad[self.quad], self.x*scale, self.y*scale, 0, 0.1875*scale, 0.1875*scale) -end \ No newline at end of file diff --git a/explosion.lua b/explosion.lua deleted file mode 100644 index 419ebe5..0000000 --- a/explosion.lua +++ /dev/null @@ -1,25 +0,0 @@ -explosion = class:new() - -function explosion:init(x, y) - self.x = x - self.y = y - self.quad = 1 - self.quadtimer = 0 - explosionsound:stop() - explosionsound:play() -end - -function explosion:update(dt) - self.quadtimer = self.quadtimer + dt*60 - if self.quadtimer > 1 then - self.quadtimer = self.quadtimer - 1 - self.quad = self.quad + 1 - if self.quad == 26 then - return true - end - end -end - -function explosion:draw() - love.graphics.drawq(explosionimg, explosionquad[self.quad], self.x*scale, self.y*scale, 0, 0.375*scale, 0.375*scale) -end \ No newline at end of file diff --git a/game/LICENSE.txt b/game/LICENSE.txt new file mode 100644 index 0000000..9042c25 --- /dev/null +++ b/game/LICENSE.txt @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/game/asteroid.lua b/game/asteroid.lua new file mode 100644 index 0000000..9f221b6 --- /dev/null +++ b/game/asteroid.lua @@ -0,0 +1,84 @@ +asteroid = class:new() + +function asteroid:init(x, y, size) + self.x = x or math.random(80)+10 + self.y = y or -10 + self.r = math.random(math.pi*20)/10 + self.size = size or 1 + self.rspeed = (math.random()*2-1)*10 + self.speedx = math.random(5)+20 + self.speedy = math.random(5)+10 + self.i = math.random(2) + self.direction = math.random(2) + if self.direction == 2 then + self.direction = -1 + end + + if self.size == 1 then + self.hp = 12*realasteroiddelay + else + self.hp = 6*realasteroiddelay + end +end + +function asteroid:update(dt) + self.x = self.x + self.speedx*dt*self.direction + self.y = self.y + self.speedy*dt + + if self.x > 90 then + self.direction = -1 + elseif self.x < 10 then + self.direction = 1 + end + + if self.y > 40 then + self.speedy = 100 + self.direction = 0 + end + + self.r = self.r + self.rspeed*dt + + if self.y > 120 then + self.dead = true + end + + return self.dead +end + +function asteroid:hit() + self.hp = self.hp - 1 + if self.hp <= 0 then + if self.size == 1 then + table.insert(asteroids, asteroid:new(self.x, self.y, 2)) + table.insert(asteroids, asteroid:new(self.x, self.y, 2)) + pointsget(10) + else + pointsget(10) + end + lastexplosion = {self.x, self.y} + self.dead = true + table.insert(explosions, explosion:new(self.x-12, self.y-16)) + backgroundwhite = 1 + end +end + +function asteroid:checkcol(x, y) + if self.size == 1 then --big + if math.abs(self.x-x) < 9 and math.abs(self.y-y) < 9 then + return true + end + else + if math.abs(self.x-x) < 6 and math.abs(self.y-y) < 6 then + return true + end + end + return false +end + +function asteroid:draw() + if self.size == 1 then + draw(_G["asteroid-big" .. self.i .. "img"], self.x, self.y, self.r, 1, 1, 11, 9) + else + draw(_G["asteroid-small" .. self.i .. "img"], self.x, self.y, self.r, 1, 1, 11, 9) + end +end \ No newline at end of file diff --git a/game/audio/approach.ogg b/game/audio/approach.ogg new file mode 100644 index 0000000..f2639a7 Binary files /dev/null and b/game/audio/approach.ogg differ diff --git a/game/audio/bigexplosion.ogg b/game/audio/bigexplosion.ogg new file mode 100644 index 0000000..0a487e3 Binary files /dev/null and b/game/audio/bigexplosion.ogg differ diff --git a/game/audio/credits.ogg b/game/audio/credits.ogg new file mode 100644 index 0000000..12033ef Binary files /dev/null and b/game/audio/credits.ogg differ diff --git a/game/audio/ding.ogg b/game/audio/ding.ogg new file mode 100644 index 0000000..4c6b83a Binary files /dev/null and b/game/audio/ding.ogg differ diff --git a/game/audio/explosion.wav b/game/audio/explosion.wav new file mode 100644 index 0000000..067b99f Binary files /dev/null and b/game/audio/explosion.wav differ diff --git a/game/audio/gunfire.wav b/game/audio/gunfire.wav new file mode 100644 index 0000000..a905579 Binary files /dev/null and b/game/audio/gunfire.wav differ diff --git a/game/audio/laser.wav b/game/audio/laser.wav new file mode 100644 index 0000000..e2094bf Binary files /dev/null and b/game/audio/laser.wav differ diff --git a/game/audio/launch.ogg b/game/audio/launch.ogg new file mode 100644 index 0000000..bebea90 Binary files /dev/null and b/game/audio/launch.ogg differ diff --git a/game/audio/space.ogg b/game/audio/space.ogg new file mode 100644 index 0000000..7e41cab Binary files /dev/null and b/game/audio/space.ogg differ diff --git a/game/audio/space.wav b/game/audio/space.wav new file mode 100644 index 0000000..902deef Binary files /dev/null and b/game/audio/space.wav differ diff --git a/game/audio/splat.ogg b/game/audio/splat.ogg new file mode 100644 index 0000000..8bfbb4d Binary files /dev/null and b/game/audio/splat.ogg differ diff --git a/game/audio/sunglasses.ogg b/game/audio/sunglasses.ogg new file mode 100644 index 0000000..9cec021 Binary files /dev/null and b/game/audio/sunglasses.ogg differ diff --git a/game/audio/trosong.ogg b/game/audio/trosong.ogg new file mode 100644 index 0000000..eec0f34 Binary files /dev/null and b/game/audio/trosong.ogg differ diff --git a/game/bigexplosion.lua b/game/bigexplosion.lua new file mode 100644 index 0000000..6e6a53d --- /dev/null +++ b/game/bigexplosion.lua @@ -0,0 +1,30 @@ +bigexplosion = class:new() + +function bigexplosion:init(x, y) + self.x = x + self.y = y + self.quad = 1 + self.quadtimer = 0 +end + +function bigexplosion:update(dt) + self.quadtimer = self.quadtimer + dt*3 + while self.quadtimer > 1 do + self.quadtimer = self.quadtimer - 1 + self.quad = self.quad + 1 + if self.quad == 26 then + return true + end + end +end + +function bigexplosion:draw() + local r, g, b = love.graphics.getColor() + if starttimer > 0 then + love.graphics.setColor(255, 255, 255, 255*math.min(1, math.max(0, (1-starttimer/7)))) + end + if self.quad <= 25 then + love.graphics.drawq(bigexplosionimg, bigexplosionquad[self.quad], self.x*scale, self.y*scale, 0, scale, scale) + end + love.graphics.setColor(r, g, b) +end \ No newline at end of file diff --git a/game/bird.lua b/game/bird.lua new file mode 100644 index 0000000..69fa2b6 --- /dev/null +++ b/game/bird.lua @@ -0,0 +1,52 @@ +bird = class:new() + +function bird:init(x, y) + self.x = math.random(100) + self.y = 90 + self.quad = 1 + self.quadtimer = 0 + self.speedx = (math.random()*2-1)*50 + self.speedy = math.random(30)+10 + + self.dir = math.random(2) + if self.dir == 2 then + self.dir = -1 + end +end + +function bird:update(dt) + self.quadtimer = self.quadtimer + dt*5 + if self.quadtimer > 1 then + self.quadtimer = self.quadtimer - 1 + if self.quad == 1 then + self.quad = 2 + else + self.quad = 1 + end + end + + self.x = self.x + self.speedx*dt*self.dir + self.y = self.y - self.speedy*dt + + if self.x > 100 then + self.dir = -1 + elseif self.x < 0 then + self.dir = 1 + end + + if self.y < -10 or self.dead then + return true + end +end + +function bird:checkcol(x, y) + if math.abs(self.x-x) < 7 and math.abs(self.y-y) < 4 then + self.dead = true + return true + end + return false +end + +function bird:draw() + love.graphics.drawq(birdimg, birdquad[self.quad], self.x*scale, self.y*scale, 0, scale/2, scale/2, 14, 8) +end \ No newline at end of file diff --git a/game/bullet.lua b/game/bullet.lua new file mode 100644 index 0000000..f55c323 --- /dev/null +++ b/game/bullet.lua @@ -0,0 +1,41 @@ +bullet = class:new() + +function bullet:init(x, y, r) + self.x = x + self.y = y + self.r = r + gunfire:stop() + gunfire:play() +end + +function bullet:update(dt) + if not self.kill then + self.x = self.x + math.sin(self.r)*500*dt + self.y = self.y - math.cos(self.r)*300*dt + + for i, v in pairs(asteroids) do + if v:checkcol(self.x, self.y) and not v.dead then + v:hit() + self.kill = 0 + end + end + end + + if self.kill then + self.kill = self.kill + dt + end + + if self.kill and self.kill >= 0.2 then + return true + end +end + +function bullet:draw() + if self.kill then + love.graphics.setColor(255, 255, 255, (1-self.kill/0.2)*255) + draw(littleexplosionimg, self.x, self.y, self.r, 1, 1, 8, 4) + love.graphics.setColor(255, 255, 255, 255) + else + draw(bulletimg, self.x, self.y, self.r, 1, 1, 6, 4) + end +end \ No newline at end of file diff --git a/game/bush.lua b/game/bush.lua new file mode 100644 index 0000000..acfc729 --- /dev/null +++ b/game/bush.lua @@ -0,0 +1,25 @@ +bush = class:new() + +function bush:init() + self.x = math.random()*100 + self.y = math.random()*20+57 + self.i = math.random(2) + self.speed = 50 +end + +function bush:update(dt) + if not rockets or rockets[1].x > 50 then + self.x = self.x - self.speed*dt + end + + if self.x < - _G["bush" .. self.i .. "img"]:getWidth() then + self.x = 100 + self.y = math.random()*20+57 + self.i = math.random(2) + self.speed = 50 + end +end + +function bush:draw() + draw(_G["bush" .. self.i .. "img"], self.x, self.y) +end \ No newline at end of file diff --git a/game/class.lua b/game/class.lua new file mode 100644 index 0000000..c42e794 --- /dev/null +++ b/game/class.lua @@ -0,0 +1,44 @@ +--[[ +Copyright (c) 2009 Bart van Strien + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. +]] + +__HAS_SECS_COMPATIBLE_CLASSES__ = true + +local class_mt = {} + +function class_mt:__index(key) + return self.__baseclass[key] +end + +class = setmetatable({ __baseclass = {} }, class_mt) + +function class:new(...) + local c = {} + c.__baseclass = self + setmetatable(c, getmetatable(self)) + if c.init then + c:init(...) + end + return c +end \ No newline at end of file diff --git a/game/cloud.lua b/game/cloud.lua new file mode 100644 index 0000000..9dd6c56 --- /dev/null +++ b/game/cloud.lua @@ -0,0 +1,30 @@ +cloud = class:new() + +function cloud:init(random, y) + if y then + self.starty = y + end + self.x = math.random()*100 + self.y = y or math.random()*20+3 + self.i = math.random(2) + self.speed = math.random()*20+50 +end + +function cloud:update(dt) + if not rockets or rockets[1].x > 50 then + self.x = self.x - self.speed*dt + else + self.x = self.x - self.speed*0.3*dt + end + + if self.x < - _G["cloud" .. self.i .. "img"]:getWidth() then + self.x = 100 + self.y = self.starty or math.random()*20+3 + self.i = math.random(2) + self.speed = math.random()*20+50 + end +end + +function cloud:draw() + draw(_G["cloud" .. self.i .. "img"], self.x, self.y) +end \ No newline at end of file diff --git a/game/cloud2.lua b/game/cloud2.lua new file mode 100644 index 0000000..4cc984a --- /dev/null +++ b/game/cloud2.lua @@ -0,0 +1,22 @@ +cloud2 = class:new() + +function cloud2:init(y) + self.x = math.random()*100 + self.y = 120+y + self.i = math.random(2) + self.speed = -500 +end + +function cloud2:update(dt) + self.y = self.y + self.speed*dt + + if self.y < -20 then + self.y = self.y+140 + self.x = math.random()*100 + self.i = math.random(2) + end +end + +function cloud2:draw() + draw(_G["cloud" .. self.i .. "img"], self.x, self.y, 0, 1, 1, 15) +end \ No newline at end of file diff --git a/game/conf.lua b/game/conf.lua new file mode 100644 index 0000000..0bdaf1a --- /dev/null +++ b/game/conf.lua @@ -0,0 +1,9 @@ +function love.conf(t) + t.title = "TROSH: The Movie: The Game" + t.author = "Maurice" + t.console = false + t.screen.vsync = true + t.screen.width = 800 + t.screen.height = 640 + t.screen.fsaa = 0 +end \ No newline at end of file diff --git a/game/enemy.lua b/game/enemy.lua new file mode 100644 index 0000000..abf285e --- /dev/null +++ b/game/enemy.lua @@ -0,0 +1,64 @@ +enemy = class:new() + +function enemy:init() + self.quad = 1 + self.x = 100 + self.y = math.random()*20+40 + self.quadtimer = 0 + self.movement = math.random(7)-4 + if self.movement > 0 then + self.movement = 1 + elseif self.movement < 0 then + self.movement = -1 + end + self.speed = math.random(30)+40 + self.dead = false +end + +function enemy:update(dt) + self.quadtimer = self.quadtimer + dt*30 + if self.quadtimer > 1 then + self.quadtimer = self.quadtimer - 1 + self.quad = self.quad + 1 + if self.quad == 17 then + self.quad = 1 + end + end + + if self.movement == 1 then + self.y = self.y - dt*30 + if self.y < 40 then + self.movement = -1 + end + elseif self.movement == -1 then + self.y = self.y + dt*30 + if self.y > 70 then + self.movement = 1 + end + end + + self.x = self.x - self.speed*dt + + if self.dead then + return true + end +end + +function enemy:explode() + self.dead = true + table.insert(explosions, explosion:new(self.x-5, self.y-10)) + pointsget(1) + skycolor = getrainbowcolor(math.random()) + love.graphics.setBackgroundColor(skycolor) +end + +function enemy:checkcol(x, y, newx) + if x < self.x+4 and newx > self.x+4 and math.abs(self.y+7-y) < 6 then + return true + end + return false +end + +function enemy:draw() + love.graphics.drawq(enemyimg, enemyquad[self.quad], self.x*scale, self.y*scale, 0, 0.1875*scale, 0.1875*scale) +end \ No newline at end of file diff --git a/game/explosion.lua b/game/explosion.lua new file mode 100644 index 0000000..419ebe5 --- /dev/null +++ b/game/explosion.lua @@ -0,0 +1,25 @@ +explosion = class:new() + +function explosion:init(x, y) + self.x = x + self.y = y + self.quad = 1 + self.quadtimer = 0 + explosionsound:stop() + explosionsound:play() +end + +function explosion:update(dt) + self.quadtimer = self.quadtimer + dt*60 + if self.quadtimer > 1 then + self.quadtimer = self.quadtimer - 1 + self.quad = self.quad + 1 + if self.quad == 26 then + return true + end + end +end + +function explosion:draw() + love.graphics.drawq(explosionimg, explosionquad[self.quad], self.x*scale, self.y*scale, 0, 0.375*scale, 0.375*scale) +end \ No newline at end of file diff --git a/game/graphics/alert.png b/game/graphics/alert.png new file mode 100644 index 0000000..3eb5a30 Binary files /dev/null and b/game/graphics/alert.png differ diff --git a/game/graphics/arrow.png b/game/graphics/arrow.png new file mode 100644 index 0000000..b03b4ca Binary files /dev/null and b/game/graphics/arrow.png differ diff --git a/game/graphics/asteroid-big1.png b/game/graphics/asteroid-big1.png new file mode 100644 index 0000000..f0bb236 Binary files /dev/null and b/game/graphics/asteroid-big1.png differ diff --git a/game/graphics/asteroid-big2.png b/game/graphics/asteroid-big2.png new file mode 100644 index 0000000..eef1742 Binary files /dev/null and b/game/graphics/asteroid-big2.png differ diff --git a/game/graphics/asteroid-small1.png b/game/graphics/asteroid-small1.png new file mode 100644 index 0000000..69ad435 Binary files /dev/null and b/game/graphics/asteroid-small1.png differ diff --git a/game/graphics/asteroid-small2.png b/game/graphics/asteroid-small2.png new file mode 100644 index 0000000..193d710 Binary files /dev/null and b/game/graphics/asteroid-small2.png differ diff --git a/game/graphics/awesome.png b/game/graphics/awesome.png new file mode 100644 index 0000000..97f54bf Binary files /dev/null and b/game/graphics/awesome.png differ diff --git a/game/graphics/bigexplosion.png b/game/graphics/bigexplosion.png new file mode 100644 index 0000000..ff5e33a Binary files /dev/null and b/game/graphics/bigexplosion.png differ diff --git a/game/graphics/bird.png b/game/graphics/bird.png new file mode 100644 index 0000000..f5fb48c Binary files /dev/null and b/game/graphics/bird.png differ diff --git a/game/graphics/bullet.png b/game/graphics/bullet.png new file mode 100644 index 0000000..e0f6ecd Binary files /dev/null and b/game/graphics/bullet.png differ diff --git a/game/graphics/bush1.png b/game/graphics/bush1.png new file mode 100644 index 0000000..1035533 Binary files /dev/null and b/game/graphics/bush1.png differ diff --git a/game/graphics/bush2.png b/game/graphics/bush2.png new file mode 100644 index 0000000..02a3113 Binary files /dev/null and b/game/graphics/bush2.png differ diff --git a/game/graphics/cloud1.png b/game/graphics/cloud1.png new file mode 100644 index 0000000..04368b8 Binary files /dev/null and b/game/graphics/cloud1.png differ diff --git a/game/graphics/cloud2.png b/game/graphics/cloud2.png new file mode 100644 index 0000000..8882806 Binary files /dev/null and b/game/graphics/cloud2.png differ diff --git a/game/graphics/enemy.png b/game/graphics/enemy.png new file mode 100644 index 0000000..60154a3 Binary files /dev/null and b/game/graphics/enemy.png differ diff --git a/game/graphics/explosion.png b/game/graphics/explosion.png new file mode 100644 index 0000000..ad9cc11 Binary files /dev/null and b/game/graphics/explosion.png differ diff --git a/game/graphics/font.png b/game/graphics/font.png new file mode 100644 index 0000000..364a7e1 Binary files /dev/null and b/game/graphics/font.png differ diff --git a/game/graphics/ground.png b/game/graphics/ground.png new file mode 100644 index 0000000..932dff2 Binary files /dev/null and b/game/graphics/ground.png differ diff --git a/game/graphics/groundwin.png b/game/graphics/groundwin.png new file mode 100644 index 0000000..23074c8 Binary files /dev/null and b/game/graphics/groundwin.png differ diff --git a/game/graphics/icon.png b/game/graphics/icon.png new file mode 100644 index 0000000..b35e7de Binary files /dev/null and b/game/graphics/icon.png differ diff --git a/game/graphics/littleexplosion.png b/game/graphics/littleexplosion.png new file mode 100644 index 0000000..500d9a3 Binary files /dev/null and b/game/graphics/littleexplosion.png differ diff --git a/game/graphics/powerup.png b/game/graphics/powerup.png new file mode 100644 index 0000000..273d7f2 Binary files /dev/null and b/game/graphics/powerup.png differ diff --git a/game/graphics/randomshit.png b/game/graphics/randomshit.png new file mode 100644 index 0000000..104d8d5 Binary files /dev/null and b/game/graphics/randomshit.png differ diff --git a/game/graphics/rocket.png b/game/graphics/rocket.png new file mode 100644 index 0000000..49ce77d Binary files /dev/null and b/game/graphics/rocket.png differ diff --git a/game/graphics/rocketkaputt.png b/game/graphics/rocketkaputt.png new file mode 100644 index 0000000..e83ace6 Binary files /dev/null and b/game/graphics/rocketkaputt.png differ diff --git a/game/graphics/splatter.png b/game/graphics/splatter.png new file mode 100644 index 0000000..3f3c1af Binary files /dev/null and b/game/graphics/splatter.png differ diff --git a/game/graphics/star.png b/game/graphics/star.png new file mode 100644 index 0000000..456aef9 Binary files /dev/null and b/game/graphics/star.png differ diff --git a/game/graphics/sunglasses.png b/game/graphics/sunglasses.png new file mode 100644 index 0000000..689a098 Binary files /dev/null and b/game/graphics/sunglasses.png differ diff --git a/game/graphics/title.png b/game/graphics/title.png new file mode 100644 index 0000000..811c79d Binary files /dev/null and b/game/graphics/title.png differ diff --git a/game/graphics/trosh.png b/game/graphics/trosh.png new file mode 100644 index 0000000..8857a25 Binary files /dev/null and b/game/graphics/trosh.png differ diff --git a/game/graphics/troshwin.png b/game/graphics/troshwin.png new file mode 100644 index 0000000..4a0ad08 Binary files /dev/null and b/game/graphics/troshwin.png differ diff --git a/game/graphics/warning.png b/game/graphics/warning.png new file mode 100644 index 0000000..0dd951b Binary files /dev/null and b/game/graphics/warning.png differ diff --git a/game/graphics/wheatley.png b/game/graphics/wheatley.png new file mode 100644 index 0000000..9c88832 Binary files /dev/null and b/game/graphics/wheatley.png differ diff --git a/game/laser.lua b/game/laser.lua new file mode 100644 index 0000000..c5580c4 --- /dev/null +++ b/game/laser.lua @@ -0,0 +1,29 @@ +laser = class:new() + +function laser:init(x, y) + self.i = 0 + self.x = x + self.y = y +end + +function laser:update(dt) + local oldi = self.i + self.i = self.i + dt*5 + + if self.i > 1 then + return true + end + + if enemies then + for i, v in pairs(enemies) do + if v:checkcol(self.x + oldi*100, self.y, self.x + self.i*100) then + v:explode() + end + end + end +end + +function laser:draw() + love.graphics.setColor(getrainbowcolor(math.random(), 400)) + love.graphics.rectangle("fill", self.x*scale, self.y*scale, 100*scale*self.i, scale*2) +end \ No newline at end of file diff --git a/game/main.lua b/game/main.lua new file mode 100644 index 0000000..1f14259 --- /dev/null +++ b/game/main.lua @@ -0,0 +1,316 @@ +function love.load() + love.graphics.setDefaultImageFilter("nearest", "nearest") + + require "class" + require "menu" + require "cloud" + require "cloud2" + require "bush" + require "scene1" + require "scene2" + require "scene3" + require "scene4" + require "scene5" + require "scene6" + require "laser" + require "enemy" + require "explosion" + require "bigexplosion" + require "splatter" + require "powerup" + require "rocket" + require "star" + require "asteroid" + require "bullet" + require "bird" + + love.graphics.setIcon( love.graphics.newImage("graphics/icon.png") ) + imagelist = {"title", "cloud1", "cloud2", "ground", "bush1", "bush2", "powerup", "rocket", "star", "asteroid-big1", "sunglasses", "awesome", "arrow", "groundwin", + "asteroid-big2", "asteroid-small1", "asteroid-small2", "bullet", "littleexplosion", "warning", "wheatley", "alert", "randomshit", "bird"} + + for i = 1, #imagelist do + _G[imagelist[i] .. "img"] = love.graphics.newImage("graphics/" .. imagelist[i] .. ".png") + end + + fontimage = love.graphics.newImage("graphics/font.png") + + fontglyphs = "0123456789abcdefghijklmnopqrstuvwxyz.:/,'C-_>* !{}?" + fontquads = {} + for i = 1, string.len(fontglyphs) do + fontquads[string.sub(fontglyphs, i, i)] = love.graphics.newQuad((i-1)*8, 0, 8, 8, 408, 8) + end + + playerimg = love.graphics.newImage("graphics/trosh.png") + 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)} + + winplayerimg = love.graphics.newImage("graphics/troshwin.png") + winplayerquad = {} + for x = 1, 4 do + winplayerquad[x] = love.graphics.newQuad((x-1)*11, 0, 11, 26, 44, 26) + end + + enemyimg = love.graphics.newImage("graphics/enemy.png") + enemyquad = {} + for y = 1, 4 do + for x = 1, 4 do + enemyquad[(y-1)*4+x] = love.graphics.newQuad((x-1)*100, (y-1)*96, 100, 96, 400, 384) + end + end + + explosionimg = love.graphics.newImage("graphics/explosion.png") + explosionquad = {} + for y = 1, 5 do + for x = 1, 5 do + explosionquad[(y-1)*5+x] = love.graphics.newQuad((x-1)*66, (y-1)*81, 66, 81, 330, 405) + end + end + + bigexplosionimg = love.graphics.newImage("graphics/bigexplosion.png") + bigexplosionquad = {} + for y = 1, 5 do + for x = 1, 5 do + bigexplosionquad[(y-1)*5+x] = love.graphics.newQuad((x-1)*108, (y-1)*121, 108, 121, 540, 605) + end + end + + splatterimg = love.graphics.newImage("graphics/splatter.png") + splatterquad = {} + for x = 1, 6 do + splatterquad[x] = love.graphics.newQuad((x-1)*64, 0, 64, 64, 384, 64) + end + + birdquad = {love.graphics.newQuad(0, 0, 29, 16, 29, 32), love.graphics.newQuad(0, 16, 29, 16, 29, 32)} + + scale = 8 + local w, h = love.graphics.getMode() + if w ~= 100*scale or h ~= 80*scale then + love.graphics.setMode(100*scale, 80*scale, false, true, 0) + end + love.graphics.setIcon( love.graphics.newImage("graphics/icon.png") ) + + bgmusic = love.audio.newSource("audio/trosong.ogg") + bgmusic:setLooping(true) + lasersound = love.audio.newSource("audio/laser.wav") + bigexplosionsound = love.audio.newSource("audio/bigexplosion.ogg") + explosionsound = love.audio.newSource("audio/explosion.wav") + launchsound = love.audio.newSource("audio/launch.ogg") + gunfire = love.audio.newSource("audio/gunfire.wav") + space = love.audio.newSource("audio/space.ogg") + sunglassessound = love.audio.newSource("audio/sunglasses.ogg") + splat = love.audio.newSource("audio/splat.ogg") + ding = love.audio.newSource("audio/ding.ogg") + credits = love.audio.newSource("audio/credits.ogg") + approach = love.audio.newSource("audio/approach.ogg") + credits:setLooping(true) + + skipupdate = true + shakeamount = 0 + shake = 0 + fade = 0 + playerframe = 1 + scoreanim = 1 + rainbowi = 0.5 + sini = 0 + sini2 = math.pi/2 + scrollx = 0 + points = 0 + machinedelay = 0.05 + stars = {} + explosions = {} + backgroundstripes = 10 + sunrot = 0 + + lasers = {} + + realasteroiddelay = 1 + movement1speed = 100 + laserdelay = 0 + reallaserdelay = 0.4 + starttimer = 0 + changegamestate("menu") +end + +function love.update(dt) + if skipupdate then + skipupdate = false + return + end + + sunrot = sunrot + dt*50 + + starttimer = starttimer + dt + + if scoreanim < 1 then + scoreanim = scoreanim + (1-scoreanim)*8*dt + end + + if laserdelay > 0 then + laserdelay = math.max(0, laserdelay-dt) + end + + shake = math.random()*shakeamount*2-shakeamount + + if _G[gamestate .. "_update"] then + _G[gamestate .. "_update"](dt) + end + + --LASERS + local delete = {} + + for i, v in pairs(lasers) do + if v:update(dt) == true then + table.insert(delete, i) + end + end + + table.sort(delete, function(a,b) return a>b end) + + for i, v in pairs(delete) do + table.remove(lasers, v) --remove + end +end + +function pointsget(i) + points = points + i + scoreanim = 0 + rainbowi = math.random() + shakeamount = 10 +end + +function love.draw() + love.graphics.translate(50*scale, 40*scale) + love.graphics.rotate(shake/300) + love.graphics.translate(-50*scale, -40*scale) + + love.graphics.translate(shake*scale/4, shake*scale/4) + + if _G[gamestate .. "_draw"] then + _G[gamestate .. "_draw"]() + end + + + if gamestate ~= "menu" and gamestate ~= "scene6" and not landing then + local r, g, b = unpack(getrainbowcolor(rainbowi)) + + local ar = r + (255-r)*scoreanim + local ag = g + (255-g)*scoreanim + local ab = b + (255-b)*scoreanim + + love.graphics.setColor(ar, ag, ab) + + local s = scale*0.5+(1-scoreanim)*10 + love.graphics.rotate((1-scoreanim)*0.4) + properprint("score: " .. points, 2, 2, s) + love.graphics.rotate(-(1-scoreanim)*0.4) + end + + love.graphics.translate(-shake*scale/4, -shake*scale/4) + + + love.graphics.translate(50*scale, 40*scale) + love.graphics.rotate(-shake/300) + love.graphics.translate(-50*scale, -40*scale) + if fade > 0 then + love.graphics.setColor(255, 255, 255, 255*fade) + love.graphics.rectangle("fill", 0, 0, 100*scale, 80*scale) + love.graphics.setColor(255, 255, 255, 255) + end +end + +function love.keypressed(key, unicode) + if _G[gamestate .. "_keypressed"] then + _G[gamestate .. "_keypressed"](key, unicode) + end + + if key ~= "left" and key ~= "up" and key ~= "right" and key ~= "down" then + if _G[gamestate .. "_action"] then + _G[gamestate .. "_action"](key) + end + end +end + +function love.keyreleased(key, unicode) + if _G[gamestate .. "_keyreleased"] then + _G[gamestate .. "_keyreleased"](key, unicode) + end +end + +function changegamestate(i) + gamestate = i + if _G[gamestate .. "_load"] then + _G[gamestate .. "_load"]() + end +end + +function draw(drawable, x, y, r, sx, sy, ox, oy, kx, ky) + if not sx then + sx = 1 + end + if not sy then + sy = 1 + end + love.graphics.draw(drawable, x*scale, y*scale, r, sx*scale, sy*scale, ox, oy, kx, ky ) +end + +function round(num, idp) --Not by me + local mult = 10^(idp or 0) + return math.floor(num * mult + 0.5) / mult +end + +function properprint(s, x, y, sc) + local sc = sc or scale + local startx = x + local skip = 0 + for i = 1, string.len(tostring(s)) do + if skip > 0 then + skip = skip - 1 + else + local char = string.sub(s, i, i) + if fontquads[char] then + love.graphics.drawq(fontimage, fontquads[char], x*scale+((i-1)*8+1)*sc, y*scale, 0, sc, sc) + end + end + end +end + +function round(num, idp) --Not by me + local mult = 10^(idp or 0) + return math.floor(num * mult + 0.5) / mult +end + +function getrainbowcolor(i, whiteness) + local whiteness = whiteness or 255 + local r, g, b + if i < 1/6 then + r = 1 + g = i*6 + b = 0 + elseif i >= 1/6 and i < 2/6 then + r = (1/6-(i-1/6))*6 + g = 1 + b = 0 + elseif i >= 2/6 and i < 3/6 then + r = 0 + g = 1 + b = (i-2/6)*6 + elseif i >= 3/6 and i < 4/6 then + r = 0 + g = (1/6-(i-3/6))*6 + b = 1 + elseif i >= 4/6 and i < 5/6 then + r = (i-4/6)*6 + g = 0 + b = 1 + else + r = 1 + g = 0 + b = (1/6-(i-5/6))*6 + end + + local add = 0 + if whiteness > 255 then + add = whiteness-255 + end + + return {math.min(255, round(r*whiteness)+add), math.min(255, round(g*whiteness)+add), math.min(255, round(b*whiteness)+add), 255} +end diff --git a/game/menu.lua b/game/menu.lua new file mode 100644 index 0000000..a5f26ed --- /dev/null +++ b/game/menu.lua @@ -0,0 +1,125 @@ +function menu_load() + love.graphics.setBackgroundColor(153, 217, 234) + clouds = {} + bushes = {} + love.audio.play(bgmusic) + for i = 1, 5 do + table.insert(clouds, cloud:new(true)) + end + for i = 1, 30 do + table.insert(bushes, bush:new(true)) + end + + textpos = {} + for i = 0, 7 do + textpos[i] = 10 + end + playerframetimer = 0 + playery = 50 + playerx = 10 + -- 1 2 3 4 5 6 7 + startactions = {2.3, 4.6, 7, 8.20, 9.20, 10.20, 11.20} + starti = 0 + +end + +function menu_update(dt) + for i, v in pairs(clouds) do + v:update(dt) + end + for i, v in pairs(bushes) do + v:update(dt) + end + + scrollx = scrollx + dt*50 + + rainbowi = math.mod(rainbowi + dt/2, 1) + sini = math.mod(sini + dt*10, math.pi*2) + sini2 = math.mod(sini2 + dt*5, math.pi*2) + + if starttimer > startactions[starti+1] then + starti = starti+1 + if starti == 7 then + changegamestate("scene1") + return + end + end + + if starti >= 4 then + shakeamount = shakeamount + dt*4 + end + if starti >= 5 then + shakeamount = shakeamount + dt*10 + end + if starti >= 6 then + shakeamount = shakeamount + dt*50 + end + + for i = -1, starti-1 do + if i >= 0 then + textpos[i] = textpos[i]+(textpos[i]^2*dt) + end + end + + playerframetimer = playerframetimer + dt*10 + while playerframetimer >= 2 do + playerframetimer = playerframetimer - 2 + end + playerframe = math.floor(playerframetimer)+1 + + playermovement1(dt) +end + +function menu_action() + shootlaser() +end + +function menu_draw() + love.graphics.setColor(255, 255, 255) + for i, v in pairs(clouds) do + v:draw() + end + + for i = 1, 2 do + draw(groundimg, -math.mod(scrollx, 120) + (i-1)*120, 59) + end + for i, v in pairs(bushes) do + v:draw() + end + + love.graphics.drawq(playerimg, playerquad[playerframe], playerx*scale, playery*scale, 0, scale, scale, 7, 12) + for i, v in pairs(lasers) do + v:draw() + end + + love.graphics.setColor(getrainbowcolor(rainbowi, 420)) + draw(titleimg, 50, 23, math.sin(sini)/10, (math.sin(sini2)+1)/5+0.7, (math.sin(sini2)+1)/5+0.7, 50, 13) + + love.graphics.setColor(255, 0, 0) + if starti >= 0 then + properprint("directed by maurice", 13, 40+textpos[0], scale/2) + end + if starti >= 1 then + properprint("utilise les fleches", 11, 40+textpos[1], scale/2) + end + if starti >= 2 then + properprint("et la touche espace", 12, 40+textpos[2], scale/2) + end + if starti >= 3 then + properprint("pret...", 30, 40+textpos[3], scale/2) + end + if starti >= 4 then + properprint("3", 40, 40+textpos[4], scale*2) + end + if starti >= 5 then + properprint("2", 36, 40+textpos[5], scale*3) + end + if starti >= 6 then + properprint("1", 32, 40+textpos[6], scale*4) + end + if starti >= 7 then + properprint("go !", 10, 40+textpos[7], scale*6) + end + + love.graphics.setColor(255, 255, 255) +end diff --git a/game/powerup.lua b/game/powerup.lua new file mode 100644 index 0000000..d657288 --- /dev/null +++ b/game/powerup.lua @@ -0,0 +1,47 @@ +powerup = class:new() + +function powerup:init() + self.x = 108 + self.y = math.random()*20+40 + self.speed = 30 + self.movement = 1 + self.blinktimer = 0 + self.blink = true +end + +function powerup:update(dt) + if self.movement == 1 then + self.y = self.y - dt*30 + if self.y < 40 then + self.movement = -1 + end + elseif self.movement == -1 then + self.y = self.y + dt*30 + if self.y > 70 then + self.movement = 1 + end + end + + self.blinktimer = self.blinktimer + dt + if self.blinktimer > 0.2 then + self.blinktimer = self.blinktimer - 0.5 + self.blink = not self.blink + end + + self.x = self.x - self.speed*dt +end + +function powerup:checkcol(x, y) + if math.abs(self.x+8-x) < 10 and math.abs(self.y+4-y) < 10 then + return true + end + return false +end + +function powerup:draw() + draw(powerupimg, self.x, self.y, 0, 1, 1, 8, 4) + love.graphics.setColor(255, 0, 0) + if self.x > 0 and self.blink then + properprint("prend la biere!!!", 15, 45, scale*0.5) + end +end diff --git a/game/readme.txt b/game/readme.txt new file mode 100644 index 0000000..e90a9fa --- /dev/null +++ b/game/readme.txt @@ -0,0 +1,7 @@ +Trosh: The Movie: The Game + -by Maurice + +Special appearances by Trosh and Nondescript Purple Pony. +Made in about 20 hours. + +Version éditée par Le Club Info pour ses évènements diff --git a/game/rocket.lua b/game/rocket.lua new file mode 100644 index 0000000..474aefd --- /dev/null +++ b/game/rocket.lua @@ -0,0 +1,227 @@ +rocket = class:new() + +rocketspeed = 300 +maxrocketspeed = 100 + +function rocket:init() + self.x = 115 + self.y = 60 + self.r = 0 + self.speedx = 0 + self.ground = true + self.startingoffset = 0 + self.thrusttimer = 0 + thrusts = {} + machinegundelay = 0 + self.explosiondelay = 0 + self.explosiontimer = 0 +end + +function rocket:update(dt) + if self.ground then + if self.x > 50 then + self.x = self.x - dt*50 + if self.x < 50 then + self.x = 50 + end + end + else + self.startingoffset = (math.random()*2-1)*0.5 + end + + if self.starting then + self.startingtimer = self.startingtimer + dt + self.startingoffset = (math.random()*2-1)*2 + + if self.startingtimer > 2 then + self.y = self.y - dt*5 + self:thrusts(dt) + end + + if self.startingtimer > 7 then + self.y = self.y + dt*50 + + if self.y > 70 then + self.starting = false + self.y = 70 + changegamestate("scene3") + self.inflight = true + end + end + end + + if self.inflight then + if love.keyboard.isDown("right") and self.x < 100 then + self.speedx = self.speedx + dt*rocketspeed + elseif self.speedx > 0 then + self.speedx = math.max(0, self.speedx - dt*rocketspeed) + end + + if love.keyboard.isDown("left") and self.x > 0 then + self.speedx = self.speedx - dt*rocketspeed + elseif self.speedx < 0 then + self.speedx = math.min(0, self.speedx + dt*rocketspeed) + end + + self.speedx = math.min(maxrocketspeed, math.max(-maxrocketspeed, self.speedx)) + + self.x = self.x + self.speedx*dt + if self.x > 100 then + self.x = 100 + elseif self.x < 0 then + self.x = 0 + end + + self.r = self.speedx/200 + + if #pressedkeys > 0 then + machinegundelay = machinegundelay + dt + while machinegundelay > machinedelay do + self:fire() + machinegundelay = machinegundelay - machinedelay + end + end + + if wheatleytimer then + wheatleytimer = wheatleytimer + dt*2 + wheatleyr = wheatleyr + dt*10 + + if wheatleytimer >= 0.95 and wheatleytimer - dt*2 < 0.95 then + table.insert(explosions, explosion:new(self.x-20, self.y-20)) + rocketimg = love.graphics.newImage("graphics/rocketkaputt.png") + changegamestate("scene4") + self.hit = true + self.inflight = false + end + end + end + shakeamount = self.startingoffset*3 + + if self.hit then + wheatleytimer = wheatleytimer + dt*2 + wheatleyr = wheatleyr + dt*10 + if wheatleytimer < 4 then + if self.r > 0 then + self.r = self.r - dt + else + self.r = self.r + dt + end + else + if self.r < math.pi*0.9 then + self.r = self.r + dt + starmover = -self.r + self.y = self.y - dt*20 + if self.x > 10 then + self.x = self.x - dt*10 + elseif self.x < 10 then + self.x = self.x + dt*10 + end + end + end + + self.explosiontimer = self.explosiontimer + dt + while self.explosiontimer > self.explosiondelay do + self.explosiontimer = self.explosiontimer - self.explosiondelay + self.explosiondelay = math.random(100)/300+0.1 + table.insert(explosions, explosion:new(self.x-16+math.random(16)-8, self.y-20+math.random(16)-8)) + end + self.startingoffset = self.startingoffset*10 + end + + --THRUSTS + local delete = {} + + for i, v in pairs(thrusts) do + if v:update(dt) == true then + table.insert(delete, i) + end + end + + table.sort(delete, function(a,b) return a>b end) + + for i, v in pairs(delete) do + table.remove(thrusts, v) --remove + end +end + +function rocket:fire() + local outx = -math.sin(self.r) * -14 + self.x + local outy = math.cos(self.r) * -14 + self.y + + table.insert(bullets, bullet:new(outx, outy, self.r)) +end + +function rocket:thrusts(dt) --if you know what I mean + self.thrusttimer = self.thrusttimer + dt + local delay = 0.01 + while self.thrusttimer > delay do + self.thrusttimer = self.thrusttimer - delay + table.insert(thrusts, thrust:new(self.x-6, self.y+10)) + table.insert(thrusts, thrust:new(self.x, self.y+10)) + table.insert(thrusts, thrust:new(self.x+6, self.y+10)) + end +end + +function rocket:start() + self.starting = true + self.ground = false + self.startingtimer = 0 +end + +function rocket:checkcol(x, y) + if math.abs(self.x-x) < 16 and math.abs(self.y-y) < 16 then + return true + end + return false +end + +function rocket:draw() + local r, g, b = love.graphics.getColor() + for i, v in pairs(thrusts) do + v:draw() + end + love.graphics.setColor(r, g, b) + draw(rocketimg, self.x+self.startingoffset, self.y, self.r, 1, 1, 15, 16) + + if wheatleytimer then + if wheatleytimer <= 0.95 then + draw(wheatleyimg, self.x-20*(1-wheatleytimer/1), self.y-120*(1-wheatleytimer/1), wheatleyr, 1, 1, 8, 9) + else + draw(wheatleyimg, self.x-20*(1-0.95/1)-(wheatleytimer-0.95)*200, self.y-120*(1-wheatleytimer/1)+(wheatleytimer-0.95)*20, wheatleyr, 1, 1, 8, 9) + end + end +end + +function rocket:wheatleyattack() + wheatleytimer = 0 + wheatleyr = 0 + space:play() +end + +--THRUST + +thrust = class:new() + +function thrust:init(x, y) + self.x = x + self.y = y + self.starty = rockets[1].y + self.dir = (math.random()*2-1)*0.4+math.pi/2 + rockets[1].r + self.speed = 40 + self.life = 1 +end + +function thrust:update(dt) + self.x = self.x + math.cos(self.dir)*self.speed*dt + self.y = self.y + math.sin(self.dir)*self.speed*dt + + self.life = self.life - dt + if self.life <= 0 then + return true + end +end + +function thrust:draw() + love.graphics.setColor(255, 255, 255, 255*self.life) + love.graphics.rectangle("fill", self.x*scale, self.y*scale+(rockets[1].y-self.starty)*scale, scale, scale) +end \ No newline at end of file diff --git a/game/scene1.lua b/game/scene1.lua new file mode 100644 index 0000000..c81b075 --- /dev/null +++ b/game/scene1.lua @@ -0,0 +1,189 @@ +function scene1_load() + shakeamount = 0 + shake = 0 + fade = 1 + enemies = {} + powerups = {} + enemytimer = 0 + nextenemy = 0 + nextstage = false +end + +function scene1_update(dt) + if shakeamount > 0 then + shakeamount = math.max(0, shakeamount-dt*10) + end + + enemytimer = enemytimer + dt + while enemytimer > nextenemy and not nextstage do + enemytimer = enemytimer - nextenemy + if massenemies then + nextenemy = math.random(10)/1000+.002 + else + nextenemy = math.random(10)/10+.1 + end + table.insert(enemies, enemy:new()) + end + rainbowi = math.mod(rainbowi + dt/2, 1) + + + for i, v in pairs(clouds) do + v:update(dt) + end + for i, v in pairs(bushes) do + v:update(dt) + end + for i, v in pairs(powerups) do + v:update(dt) + end + + if starttimer > 32 and starttimer - dt < 32 then + table.insert(powerups, powerup:new()) + end + + if starttimer > 45 and starttimer - dt < 45 then + nextstage = true + end + + if starttimer > 47 and starttimer - dt < 47 then + rockets = {rocket:new()} + end + + if powerups[1] and powerups[1]:checkcol(playerx, playery) then + reallaserdelay = 0.05 + massenemies = true + powerups[1] = nil + end + + --ENEMIES + local delete = {} + + for i, v in pairs(enemies) do + if v:update(dt) == true then + table.insert(delete, i) + end + end + + table.sort(delete, function(a,b) return a>b end) + + for i, v in pairs(delete) do + table.remove(enemies, v) --remove + end + + --EXPLOSION + local delete = {} + + for i, v in pairs(explosions) do + if v:update(dt) == true then + table.insert(delete, i) + end + end + + table.sort(delete, function(a,b) return a>b end) + + for i, v in pairs(delete) do + table.remove(explosions, v) --remove + end + + if fade > 0 then + fade = math.max(0, fade-dt) + end + + playerframetimer = playerframetimer + dt*10 + while playerframetimer >= 2 do + playerframetimer = playerframetimer - 2 + end + playerframe = math.floor(playerframetimer)+1 + + if not rockets or rockets[1].x > 50 then + scrollx = scrollx + dt*50 + end + + if rockets and rockets[1]:checkcol(playerx, playery) and rockets[1].x <= 50 then + changegamestate("scene2") + end + + playermovement1(dt) + + if rockets then + rockets[1]:update(dt) + end +end + +function playermovement1(dt) + if love.keyboard.isDown("left") then + playerx = math.max(0, playerx-dt*movement1speed) + elseif love.keyboard.isDown("right") then + playerx = math.min(100, playerx+dt*movement1speed) + end + + if love.keyboard.isDown("up") then + playery = math.max(50, playery-dt*movement1speed) + elseif love.keyboard.isDown("down") then + playery = math.min(80, playery+dt*movement1speed) + end +end + +function scene1_action() + shootlaser() +end + +function shootlaser() + if laserdelay == 0 then + table.insert(lasers, laser:new(playerx, playery-8)) + lasersound:stop() + lasersound:play() + laserdelay = reallaserdelay + end +end + +function scene1_draw() + local r, g, b = love.graphics.getColor() + love.graphics.setColor(math.random(255), math.random(255), math.random(255), 255*(1-scoreanim)) + for i = 1, backgroundstripes, 2 do + local alpha = math.rad((i/backgroundstripes + math.mod(sunrot/100, 1)) * 360) + local point1 = {50*scale+100*scale*math.cos(alpha), 64*scale+100*scale*math.sin(alpha)} + + local alpha = math.rad(((i+1)/backgroundstripes + math.mod(sunrot/100, 1)) * 360) + local point2 = {50*scale+100*scale*math.cos(alpha), 64*scale+100*scale*math.sin(alpha)} + + love.graphics.polygon("fill", 50*scale, 64*scale, point1[1], point1[2], point2[1], point2[2]) + end + love.graphics.setColor(r, g, b, 255) + + for i, v in pairs(clouds) do + v:draw() + end + + for i = 1, 2 do + draw(groundimg, -math.mod(scrollx, 100) + (i-1)*100, 59) + end + for i, v in pairs(bushes) do + v:draw() + end + for i, v in pairs(enemies) do + v:draw() + end + for i, v in pairs(explosions) do + v:draw() + end + + if rockets then + rockets[1]:draw() + end + + love.graphics.drawq(playerimg, playerquad[playerframe], playerx*scale, playery*scale, 0, scale, scale, 7, 12) + for i, v in pairs(lasers) do + v:draw() + end + love.graphics.setColor(255, 255, 255) + for i, v in pairs(powerups) do + v:draw() + end + + if starttimer > 46 then + love.graphics.setColor(255, 0, 0) + properprint("dans la fuse !!!", 10, 45, scale*0.5) + end + love.graphics.setColor(255, 255, 255) +end diff --git a/game/scene2.lua b/game/scene2.lua new file mode 100644 index 0000000..a761072 --- /dev/null +++ b/game/scene2.lua @@ -0,0 +1,75 @@ +function scene2_load() + starttimer = 0 + shakeamount = 0 + rockets[1].x = 50 + rockets[1]:start() + launchsound:stop() + launchsound:play() + + for y = 1, 30 do + for i = 1, 5 do + table.insert(clouds, cloud:new(true, -y*30)) + end + end + + backgroundcolor = {love.graphics.getBackgroundColor()} +end + +function scene2_update(dt) + for i, v in pairs(clouds) do + v:update(dt) + end + rockets[1]:update(dt) + + if starttimer > 7 then + love.graphics.setBackgroundColor(0, 0, 0) + elseif starttimer > 6 then + local r, g, b = unpack(backgroundcolor) + r = r*(1-(starttimer-6)/1) + g = g*(1-(starttimer-6)/1) + b = b*(1-(starttimer-6)/1) + + love.graphics.setBackgroundColor(r, g, b) + end + + if starttimer > 7 then + if starttimer - dt <= 7 then + for i = 1, 10 do + table.insert(stars, star:new()) + end + end + + staralpha = math.min(1, (starttimer-7)/9) + end +end + +function scene2_draw() + + local launchoffset = 0 + if starttimer > 3 then + launchoffset = 10^(starttimer-3)+(starttimer-3)*20 + end + + love.graphics.translate(0, launchoffset) + + for i, v in pairs(clouds) do + v:draw() + end + + for i = 1, 2 do + draw(groundimg, -math.mod(scrollx, 100) + (i-1)*100, 59) + end + for i, v in pairs(bushes) do + v:draw() + end + love.graphics.translate(0, -launchoffset) + + + for i,v in pairs(stars) do + v:draw() + end + + love.graphics.setColor(255, 255, 255, 255) + + rockets[1]:draw() +end \ No newline at end of file diff --git a/game/scene3.lua b/game/scene3.lua new file mode 100644 index 0000000..53f6e1e --- /dev/null +++ b/game/scene3.lua @@ -0,0 +1,153 @@ +function scene3_load() + backgroundwhite = 0 + staralpha = 1 + asteroids = {} + bullets = {} + asteroidtimer = 0 + rockets = {rocket:new()} + love.audio.play(bgmusic) + rockets[1].x = 50 + rockets[1].y = 70 + rockets[1].ground = false + rockets[1].inflight = true + + table.insert(asteroids, asteroid:new()) + + if #stars == 0 then + for i = 1, 10 do + table.insert(stars, star:new()) + end + end + + lastexplosion = {50, 40} + + pressedkeys = {} + starttimer = 0 + warningtimer = 0 +end + +function scene3_update(dt) + realasteroiddelay = math.max(0.05, 8/starttimer) + backgroundwhite = math.max(0, backgroundwhite - dt) + love.graphics.setBackgroundColor(math.random(127)*backgroundwhite, math.random(127)*backgroundwhite, math.random(127)*backgroundwhite) + + if starttimer < 35 then + asteroidtimer = asteroidtimer + dt + + while asteroidtimer > realasteroiddelay do + asteroidtimer = asteroidtimer - realasteroiddelay + table.insert(asteroids, asteroid:new()) + end + end + + for i, v in pairs(stars) do + v:update(dt) + end + + --ASTEROIDS + local delete = {} + + for i, v in pairs(asteroids) do + if v:update(dt) == true then + table.insert(delete, i) + end + end + + table.sort(delete, function(a,b) return a>b end) + + for i, v in pairs(delete) do + table.remove(asteroids, v) --remove + end + + --BULLETS + local delete = {} + + for i, v in pairs(bullets) do + if v:update(dt) == true then + table.insert(delete, i) + end + end + + table.sort(delete, function(a,b) return a>b end) + + for i, v in pairs(delete) do + table.remove(bullets, v) --remove + end + + + + --EXPLOSION + local delete = {} + + for i, v in pairs(explosions) do + if v:update(dt) == true then + table.insert(delete, i) + end + end + + table.sort(delete, function(a,b) return a>b end) + + for i, v in pairs(delete) do + table.remove(explosions, v) --remove + end + + rockets[1]:update(dt) + + if (starttimer > 38 and starttimer < 40) or warningtimer > 0.1 then + warningtimer = math.mod(warningtimer + dt*7, math.pi*2) + end + + if starttimer >= 40 and starttimer - dt < 40 then + rockets[1]:wheatleyattack() + end +end + +function scene3_draw() + local r, g, b = love.graphics.getColor() + love.graphics.setColor(math.random(255), math.random(255), math.random(255), 255*(1-scoreanim)) + for i = 1, backgroundstripes, 2 do + local alpha = math.rad((i/backgroundstripes + math.mod(sunrot/100, 1)) * 360) + local point1 = {lastexplosion[1]*scale+200*scale*math.cos(alpha), lastexplosion[2]*scale+200*scale*math.sin(alpha)} + + local alpha = math.rad(((i+1)/backgroundstripes + math.mod(sunrot/100, 1)) * 360) + local point2 = {lastexplosion[1]*scale+200*scale*math.cos(alpha), lastexplosion[2]*scale+200*scale*math.sin(alpha)} + + love.graphics.polygon("fill", lastexplosion[1]*scale, lastexplosion[2]*scale, point1[1], point1[2], point2[1], point2[2]) + end + love.graphics.setColor(r, g, b, 255) + + for i,v in pairs(stars) do + v:draw() + end + for i,v in pairs(asteroids) do + v:draw() + end + + rockets[1]:draw() + for i,v in pairs(bullets) do + v:draw() + end + for i, v in pairs(explosions) do + v:draw() + end + + if (starttimer > 38 and starttimer < 40) or warningtimer > 0.1 then + love.graphics.setColor(255, 0, 0, math.abs(math.sin(warningtimer))*255) + draw(warningimg, -3+math.random(5)-3, 20+math.random(5)-3) + end +end + +function scene3_keypressed(key) + if key ~= "left" and key ~= "up" and key ~= "right" and key ~= "down" then + table.insert(pressedkeys, key) + end +end + +function scene3_keyreleased(key) + for i = 1, #pressedkeys do + if pressedkeys[i] == key then + table.remove(pressedkeys, i) + break + end + end +end \ No newline at end of file diff --git a/game/scene4.lua b/game/scene4.lua new file mode 100644 index 0000000..8bafdc0 --- /dev/null +++ b/game/scene4.lua @@ -0,0 +1,174 @@ +function scene4_load() + backgroundwhite = 0 + staralpha = 1 + asteroids = {} + bullets = {} + love.audio.play(bgmusic) + + starttimer = 0 + alerttimer = 0 + flyingquad = 3 + + pspeedx = 0 + pspeedy = 0 + + playerx = nil + + flyanimationtimer = 0 +end + +function scene4_update(dt) + if secondtimer then + secondtimer = secondtimer + dt + end + for i, v in pairs(stars) do + v:update(dt) + end + + --EXPLOSION + local delete = {} + + for i, v in pairs(explosions) do + if v:update(dt) == true then + table.insert(delete, i) + end + end + + table.sort(delete, function(a,b) return a>b end) + + for i, v in pairs(delete) do + table.remove(explosions, v) --remove + end + + if rockets[1] then + rockets[1]:update(dt) + end + + if (starttimer > 0 and starttimer < 3) or alerttimer > 0.1 then + alerttimer = math.mod(alerttimer + dt*7, math.pi*2) + end + + if jumped then + if rockets[1] then + rockets[1].x = rockets[1].x - dt*3 + end + + if rockets[1] and secondtimer > 2 and secondtimer - dt <= 2 then + for i = 1, 20 do + if explosions then + table.insert(explosions, explosion:new(rockets[1].x-16+math.random(16)-8, rockets[1].y-20+math.random(16)-8)) + end + end + starmover = math.pi + rockets[1] = nil + end + + playerx = playerx + pspeedx*dt + playery = playery + pspeedy*dt + + if pspeedx > 0 then + pspeedx = pspeedx - dt*5 + end + + if playery >= 20 then + playery = 20 + pspeedy = 0 + end + + if playerx >= 50 then + pspeedx = 0 + playerx = 50 + end + + if secondtimer > 2 then + local i = math.max(0, (1-(secondtimer-2)/2)) + staralpha = math.max(0, (1-(secondtimer-2)/2))*i + love.graphics.setBackgroundColor(153*(1-i), 217*(1-i), 234*(1-i)) + + if shakeamount < 5 then + shakeamount = math.min(5, shakeamount+dt*3) + elseif shakeamount > 5 then + shakeamount = math.max(5, shakeamount-dt*3) + end + end + + if secondtimer > 4 then + changegamestate("scene5") + end + end + + if starttimer >= 4.3 and starttimer - dt < 4.3 then + playerx = rockets[1].x+4 + playery = rockets[1].y + end + + if jumped then + flyanimationtimer = flyanimationtimer + dt + while flyanimationtimer > 0.1 do + flyanimationtimer = flyanimationtimer - 0.1 + if flyingquad == 3 then + flyingquad = 4 + else + flyingquad = 3 + end + end + end +end + +function scene4_draw() + local r, g, b = love.graphics.getColor() + love.graphics.setColor(math.random(255), math.random(255), math.random(255), 255*(1-scoreanim)) + for i = 1, backgroundstripes, 2 do + local alpha = math.rad((i/backgroundstripes + math.mod(sunrot/100, 1)) * 360) + local point1 = {lastexplosion[1]*scale+200*scale*math.cos(alpha), lastexplosion[2]*scale+200*scale*math.sin(alpha)} + + local alpha = math.rad(((i+1)/backgroundstripes + math.mod(sunrot/100, 1)) * 360) + local point2 = {lastexplosion[1]*scale+200*scale*math.cos(alpha), lastexplosion[2]*scale+200*scale*math.sin(alpha)} + + love.graphics.polygon("fill", lastexplosion[1]*scale, lastexplosion[2]*scale, point1[1], point1[2], point2[1], point2[2]) + end + love.graphics.setColor(r, g, b, 255) + + for i,v in pairs(stars) do + v:draw() + end + + + if playerx then + local off = 0 + if rockets[1] then + off = rockets[1].startingoffset + end + love.graphics.drawq(playerimg, playerquad[flyingquad], (playerx+off)*scale, playery*scale, 0, scale, scale, 13, 6) + end + + if rockets[1] then + rockets[1]:draw() + end + for i, v in pairs(explosions) do + v:draw() + end + + if (starttimer > 0 and starttimer < 3) or alerttimer > 0.1 then + local i = math.abs(math.sin(alerttimer)) + love.graphics.setColor(255, 0, 0, i*100) + love.graphics.rectangle("fill", 0, 0, 100*scale, 80*scale) + love.graphics.setColor(255, 0, 0, i*255) + draw(alertimg, 50+math.random(5)-3, 40+math.random(5)-3, (math.random()*2-1)*0.1, i*0.5+0.6, i*0.5+0.6, 54, 15) + draw(randomshitimg, 50+math.random(20)-10, 40+math.random(20)-10, 0, 1, 1, 50, 42) + end + + if starttimer > 4 and not jumped then + love.graphics.setColor(255, 0, 0, math.random(255)) + properprint("saute!!", 0, 40, scale*2) + end +end + +function scene4_action() + if starttimer > 4.3 and not jumped then + jumped = true + secondtimer = 0 + pspeedx = 20 + pspeedy = 2 + end +end diff --git a/game/scene5.lua b/game/scene5.lua new file mode 100644 index 0000000..d24f8b9 --- /dev/null +++ b/game/scene5.lua @@ -0,0 +1,229 @@ +function scene5_load() + love.graphics.setBackgroundColor(153, 217, 234) + love.audio.play(bgmusic) + + clouds2 = {} + for i = 1, 3 do + for y = 1, 8 do + table.insert(clouds2, cloud2:new(math.random()*140)) + end + end + + lastexplosion = {50, 40} + + starttimer = 0 + flyingquad = 3 + + playerx = 50 + playery = 20 + pspeedx = 0 + pspeedy = 0 + + birds = {} + splatters = {} + birdtimer = 0 + + flyanimationtimer = 0 + + shakeamount = 5 + awesometimer = 0 + + screenx = 0 + + landingtime = 2 + groundy = 90 + + landing = false +end + +function scene5_update(dt) + if starttimer < 20 then + birdtimer = birdtimer + dt + local birddelay = 0.5 + while birdtimer > birddelay do + birdtimer = birdtimer - birddelay + table.insert(birds, bird:new()) + end + end + + if starttimer >= 25 and starttimer - dt < 25 then + landing = true + timeleft = landingtime + landingx = math.random(60)+20 + end + + if starttimer >= 25.4 and starttimer - dt < 25.4 then + approach:play() + end + + if landing then + timeleft = timeleft - dt + if timeleft <= 0 then + timeleft = 0 + groundy = groundy - 400*dt + if groundy <= playery-10 then + changegamestate("scene6") + end + end + end + + for i,v in pairs(clouds2) do + v:update(dt) + end + + flyanimationtimer = flyanimationtimer + dt + while flyanimationtimer > 0.1 do + flyanimationtimer = flyanimationtimer - 0.1 + if flyingquad == 3 then + flyingquad = 4 + else + flyingquad = 3 + end + end + + if awesometimer > 0 then + awesometimer = awesometimer - dt + end + + if landing or starttimer < 24 then + playermovement2(dt) + else + if playerx > 50 then + playerx = playerx - 50*dt + elseif playerx < 50 then + playerx = playerx + 50*dt + end + + if playery > 40 then + playery = playery - 50*dt + elseif playery < 40 then + playery = playery + 50*dt + end + end + + + --BIRDS + local delete = {} + + for i, v in pairs(birds) do + if v:update(dt) == true then + table.insert(delete, i) + end + end + + table.sort(delete, function(a,b) return a>b end) + + for i, v in pairs(delete) do + table.remove(birds, v) --remove + end + + + --SPLATTERS + local delete = {} + + for i, v in pairs(splatters) do + if v:update(dt) == true then + table.insert(delete, i) + end + end + + table.sort(delete, function(a,b) return a>b end) + + for i, v in pairs(delete) do + table.remove(splatters, v) --remove + end + + for i, v in pairs(birds) do + if v:checkcol(playerx, playery) then + splat:stop() + splat:play() + pointsget(20) + table.insert(splatters, splatter:new(v.x, v.y)) + skycolor = getrainbowcolor(math.random(), 400) + love.graphics.setBackgroundColor(skycolor) + lastexplosion = {v.x, v.y} + end + end +end + +function playermovement2(dt) + if love.keyboard.isDown("left") then + playerx = math.max(0, playerx-dt*movement1speed) + elseif love.keyboard.isDown("right") then + playerx = math.min(100, playerx+dt*movement1speed) + end + + if not landing then + if love.keyboard.isDown("up") then + playery = math.max(0, playery-dt*movement1speed) + elseif love.keyboard.isDown("down") then + playery = math.min(80, playery+dt*movement1speed) + end + end +end + +function scene5_draw() + local r, g, b = love.graphics.getColor() + love.graphics.setColor(math.random(255), math.random(255), math.random(255), 100*math.min(1, (starttimer/2))) + for i = 1, backgroundstripes, 2 do + local pos = {playerx, playery} + local alpha = math.rad((i/backgroundstripes + math.mod(sunrot/100, 1)) * 360) + local point1 = {pos[1]*scale+200*scale*math.cos(alpha), pos[2]*scale+200*scale*math.sin(alpha)} + + local alpha = math.rad(((i+1)/backgroundstripes + math.mod(sunrot/100, 1)) * 360) + local point2 = {pos[1]*scale+200*scale*math.cos(alpha), pos[2]*scale+200*scale*math.sin(alpha)} + + love.graphics.polygon("fill", pos[1]*scale, pos[2]*scale, point1[1], point1[2], point2[1], point2[2]) + end + love.graphics.setColor(r, g, b, 255) + + for i,v in pairs(clouds2) do + v:draw() + end + for i,v in pairs(birds) do + v:draw() + end + for i,v in pairs(splatters) do + v:draw() + end + + if groundy < 90 then + draw(groundwinimg, -200+landingx+2, groundy) + end + + love.graphics.drawq(playerimg, playerquad[flyingquad], (playerx)*scale, playery*scale, 0, scale, scale, 13, 6) + + + if sunglasses then + draw(sunglassesimg, playerx+4, playery) + end + + if awesometimer > 0 then + draw(awesomeimg, (awesometimer*2-1)*100, 0) + love.graphics.setColor(0, 0, 0) + properprint("1000 points!", (awesometimer*2-1)*100+3, 73, scale) + love.graphics.setColor(255, 255, 255) + end + + if starttimer > 24 then + if math.mod(starttimer*5, 2) >= 1 then + love.graphics.setColor(255, 0, 0) + properprint("atteri sur la cible !", 0, 20, scale/1.5) + love.graphics.setColor(255, 255, 255) + end + end + + if landing then + draw(arrowimg, math.max(8, landingx-(timeleft/landingtime)*80), 67, 0, 1, 1, 8) + draw(arrowimg, math.min(91, landingx+(timeleft/landingtime)*80), 67, 0, -1, 1, 9) + end +end + +function scene5_action() + if not sunglasses then + sunglasses = true + awesometimer = 1 + pointsget(1000) + sunglassessound:play() + end +end diff --git a/game/scene6.lua b/game/scene6.lua new file mode 100644 index 0000000..6f4bd1c --- /dev/null +++ b/game/scene6.lua @@ -0,0 +1,187 @@ +function scene6_load() + love.graphics.setBackgroundColor(153, 217, 234) + love.audio.stop(bgmusic) + + clouds2 = {} + clouds = {} + bushes = {} + bigexplosions = {} + + playerquad = 1 + + if sunglasses then + playerquad = 3 + end + + playeranimationtimer = 0 + starttimer = 0 + + birds = {} + splatters = {} + + shakeamount = 10 + + fade = 0 + ended = false + + playerx = playerx or 50 + landingx = landingx or 50 + + landdiff = playerx-landingx + + scoremul = round((1-math.abs(landdiff)/80)^8*4, 1) + 1 + + stars = {} + + texts = {} + texts[1] = "ton super score:" + texts[2] = points + texts[3] = "" + texts[4] = "multiplicateur de cible:" + texts[5] = scoremul + texts[6] = "" + texts[7] = "mega total:" + texts[8] = math.ceil(points*scoremul) + + prevt = 0 + + to = 0 + totimes = {8.55, 8.8, 9.4, 9.5, 9.7, 11.0, 12.3, 12.9, 13.2} +end + +function scene6_update(dt) + playeranimationtimer = playeranimationtimer + dt + while playeranimationtimer > 0.1 do + playeranimationtimer = playeranimationtimer - 0.1 + playerquad = playerquad + 1 + if playerquad == 3 then + playerquad = 1 + elseif playerquad == 5 then + playerquad = 3 + end + end + + for i, v in pairs(bigexplosions) do + v:update(dt) + end + + if starttimer >= 0.7 and starttimer - dt < 0.7 then + bigexplosionsound:play() + end + + if starttimer < 0.2 then + + elseif starttimer < 0.5 then + fade = 1 + + if #explosions == 0 then + table.insert(bigexplosions, bigexplosion:new(-4, -30)) + table.insert(bigexplosions, bigexplosion:new(-40, -30)) + table.insert(bigexplosions, bigexplosion:new(36, -30)) + table.insert(bigexplosions, bigexplosion:new(-4, -50)) + end + elseif starttimer < 4 then + if fade > 0.5 then + fade = fade - dt/2 + end + else + if fade > 0 then + fade = fade - dt/2 + end + end + + + if starttimer > 8.3 and starttimer - dt < 8.3 then + credits:play() + end + + if shakeamount > 0 then + shakeamount = shakeamount - dt*3 + end + + for i = 1, 9 do + if starttimer > totimes[i] then + to = i + end + end + + if starttimer >= 15.7 and starttimer -dt < 15.7 then + print(string.format("SCORE:%d", math.ceil(points*scoremul))); + ended = true + staralpha = 1 + + stars = {} + love.graphics.setBackgroundColor(0, 0, 0) + for i = 1, 10 do + table.insert(stars, star:new()) + end + end + for i,v in pairs(stars) do + v:update(dt) + end +end + +function scene6_draw() + local r, g, b = love.graphics.getColor() + for i = 1, backgroundstripes, 1 do + if math.mod(i, 2) == 1 then + love.graphics.setColor(255, 255, 0, math.min(1, math.max(0, 1-(starttimer-7)/2))*255) + else + love.graphics.setColor(255, 0, 0, math.min(1, math.max(0, 1-(starttimer-7)/2))*255) + end + local pos = {31, 53} + local alpha = math.rad((i/backgroundstripes + math.mod(sunrot/100, 1)) * 360) + local point1 = {pos[1]*scale+200*scale*math.cos(alpha), pos[2]*scale+200*scale*math.sin(alpha)} + + local alpha = math.rad(((i+1)/backgroundstripes + math.mod(sunrot/100, 1)) * 360) + local point2 = {pos[1]*scale+200*scale*math.cos(alpha), pos[2]*scale+200*scale*math.sin(alpha)} + + love.graphics.polygon("fill", pos[1]*scale, pos[2]*scale, point1[1], point1[2], point2[1], point2[2]) + end + love.graphics.setColor(r, g, b, 255) + for i,v in pairs(stars) do + v:draw() + v:draw() + v:draw() + v:draw() + end + + love.graphics.translate(20*scale, 50*scale) + love.graphics.rotate(math.pi/7) + love.graphics.translate(-20*scale, -50*scale) + + for i, v in pairs(bigexplosions) do + v:draw() + end + + draw(groundwinimg, -168-landdiff, 56) + love.graphics.drawq(winplayerimg, winplayerquad[playerquad], 30*scale, 55*scale, 0, scale, scale, 5, 13) + + love.graphics.translate(20*scale, 50*scale) + love.graphics.rotate(-math.pi/7) + love.graphics.translate(-20*scale, -50*scale) + + for i = 1, math.min(9, to) do + local s = scale/2 + if i >= 8 then + s = s * 2 + love.graphics.setColor(getrainbowcolor(math.random())) + end + if i == 9 then + draw(titleimg, 65, 65, 0, 0.7, 0.7, 50, 14) + else + properprint(texts[i], 50-tostring(texts[i]):len()*s/2, 5*i, s) + end + love.graphics.setColor(255, 255, 255) + end + + if ended and starttimer % (5/12) > (5/24) then + properprint("appuie sur espace pour recommencer", 15, 50, scale/4); + end +end + +function scene6_keypressed(key, unicode) + if ended then + love.event.quit() + end +end diff --git a/game/splatter.lua b/game/splatter.lua new file mode 100644 index 0000000..2c974dd --- /dev/null +++ b/game/splatter.lua @@ -0,0 +1,23 @@ +splatter = class:new() + +function splatter:init(x, y) + self.x = x + self.y = y + self.quad = 1 + self.quadtimer = 0 +end + +function splatter:update(dt) + self.quadtimer = self.quadtimer + dt*30 + if self.quadtimer > 1 then + self.quadtimer = self.quadtimer - 1 + self.quad = self.quad + 1 + if self.quad == 7 then + return true + end + end +end + +function splatter:draw() + love.graphics.drawq(splatterimg, splatterquad[self.quad], self.x*scale, self.y*scale, 0, scale/2, scale/2, 40, 40) +end \ No newline at end of file diff --git a/game/star.lua b/game/star.lua new file mode 100644 index 0000000..66e53fc --- /dev/null +++ b/game/star.lua @@ -0,0 +1,37 @@ +star = class:new() + +function star:init() + self.x = math.random(100) + self.y = math.random(80)-90 + self.speed = math.random(10)+1000 +end + +function star:update(dt) + if not starmover then + self.y = self.y + self.speed*dt + else + self.y = self.y + math.cos(starmover)*self.speed*dt + self.x = self.x + math.sin(starmover)*self.speed*dt + end + + if self.y > 110 or self.y < -10 or self.x > 110 or self.x < -10 then + self.speed = math.random(10)+1000 + self.x = math.random(100) + if self.y > 110 then + self.y = self.y-120 + elseif self.y < -10 then + self.y = self.y+120 + elseif self.x > 110 then + self.x = self.x-120 + else + self.x = self.x+120 + end + end +end + +function star:draw() + local r, g, b = love.graphics.getColor() + love.graphics.setColor(255, 255, 255, 255*staralpha) + draw(starimg, self.x, self.y, 0, 1, 1, 4.5) + love.graphics.setColor(r, g, b) +end \ No newline at end of file diff --git a/graphics/alert.png b/graphics/alert.png deleted file mode 100644 index 3eb5a30..0000000 Binary files a/graphics/alert.png and /dev/null differ diff --git a/graphics/arrow.png b/graphics/arrow.png deleted file mode 100644 index b03b4ca..0000000 Binary files a/graphics/arrow.png and /dev/null differ diff --git a/graphics/asteroid-big1.png b/graphics/asteroid-big1.png deleted file mode 100644 index f0bb236..0000000 Binary files a/graphics/asteroid-big1.png and /dev/null differ diff --git a/graphics/asteroid-big2.png b/graphics/asteroid-big2.png deleted file mode 100644 index eef1742..0000000 Binary files a/graphics/asteroid-big2.png and /dev/null differ diff --git a/graphics/asteroid-small1.png b/graphics/asteroid-small1.png deleted file mode 100644 index 69ad435..0000000 Binary files a/graphics/asteroid-small1.png and /dev/null differ diff --git a/graphics/asteroid-small2.png b/graphics/asteroid-small2.png deleted file mode 100644 index 193d710..0000000 Binary files a/graphics/asteroid-small2.png and /dev/null differ diff --git a/graphics/awesome.png b/graphics/awesome.png deleted file mode 100644 index 97f54bf..0000000 Binary files a/graphics/awesome.png and /dev/null differ diff --git a/graphics/bigexplosion.png b/graphics/bigexplosion.png deleted file mode 100644 index ff5e33a..0000000 Binary files a/graphics/bigexplosion.png and /dev/null differ diff --git a/graphics/bird.png b/graphics/bird.png deleted file mode 100644 index f5fb48c..0000000 Binary files a/graphics/bird.png and /dev/null differ diff --git a/graphics/bullet.png b/graphics/bullet.png deleted file mode 100644 index e0f6ecd..0000000 Binary files a/graphics/bullet.png and /dev/null differ diff --git a/graphics/bush1.png b/graphics/bush1.png deleted file mode 100644 index 1035533..0000000 Binary files a/graphics/bush1.png and /dev/null differ diff --git a/graphics/bush2.png b/graphics/bush2.png deleted file mode 100644 index 02a3113..0000000 Binary files a/graphics/bush2.png and /dev/null differ diff --git a/graphics/cloud1.png b/graphics/cloud1.png deleted file mode 100644 index 04368b8..0000000 Binary files a/graphics/cloud1.png and /dev/null differ diff --git a/graphics/cloud2.png b/graphics/cloud2.png deleted file mode 100644 index 8882806..0000000 Binary files a/graphics/cloud2.png and /dev/null differ diff --git a/graphics/enemy.png b/graphics/enemy.png deleted file mode 100644 index 60154a3..0000000 Binary files a/graphics/enemy.png and /dev/null differ diff --git a/graphics/explosion.png b/graphics/explosion.png deleted file mode 100644 index ad9cc11..0000000 Binary files a/graphics/explosion.png and /dev/null differ diff --git a/graphics/font.png b/graphics/font.png deleted file mode 100644 index 364a7e1..0000000 Binary files a/graphics/font.png and /dev/null differ diff --git a/graphics/ground.png b/graphics/ground.png deleted file mode 100644 index 932dff2..0000000 Binary files a/graphics/ground.png and /dev/null differ diff --git a/graphics/groundwin.png b/graphics/groundwin.png deleted file mode 100644 index 23074c8..0000000 Binary files a/graphics/groundwin.png and /dev/null differ diff --git a/graphics/icon.png b/graphics/icon.png deleted file mode 100644 index b35e7de..0000000 Binary files a/graphics/icon.png and /dev/null differ diff --git a/graphics/littleexplosion.png b/graphics/littleexplosion.png deleted file mode 100644 index 500d9a3..0000000 Binary files a/graphics/littleexplosion.png and /dev/null differ diff --git a/graphics/powerup.png b/graphics/powerup.png deleted file mode 100644 index 273d7f2..0000000 Binary files a/graphics/powerup.png and /dev/null differ diff --git a/graphics/randomshit.png b/graphics/randomshit.png deleted file mode 100644 index 104d8d5..0000000 Binary files a/graphics/randomshit.png and /dev/null differ diff --git a/graphics/rocket.png b/graphics/rocket.png deleted file mode 100644 index 49ce77d..0000000 Binary files a/graphics/rocket.png and /dev/null differ diff --git a/graphics/rocketkaputt.png b/graphics/rocketkaputt.png deleted file mode 100644 index e83ace6..0000000 Binary files a/graphics/rocketkaputt.png and /dev/null differ diff --git a/graphics/splatter.png b/graphics/splatter.png deleted file mode 100644 index 3f3c1af..0000000 Binary files a/graphics/splatter.png and /dev/null differ diff --git a/graphics/star.png b/graphics/star.png deleted file mode 100644 index 456aef9..0000000 Binary files a/graphics/star.png and /dev/null differ diff --git a/graphics/sunglasses.png b/graphics/sunglasses.png deleted file mode 100644 index 689a098..0000000 Binary files a/graphics/sunglasses.png and /dev/null differ diff --git a/graphics/title.png b/graphics/title.png deleted file mode 100644 index 811c79d..0000000 Binary files a/graphics/title.png and /dev/null differ diff --git a/graphics/trosh.png b/graphics/trosh.png deleted file mode 100644 index 8857a25..0000000 Binary files a/graphics/trosh.png and /dev/null differ diff --git a/graphics/troshwin.png b/graphics/troshwin.png deleted file mode 100644 index 4a0ad08..0000000 Binary files a/graphics/troshwin.png and /dev/null differ diff --git a/graphics/warning.png b/graphics/warning.png deleted file mode 100644 index 0dd951b..0000000 Binary files a/graphics/warning.png and /dev/null differ diff --git a/graphics/wheatley.png b/graphics/wheatley.png deleted file mode 100644 index 9c88832..0000000 Binary files a/graphics/wheatley.png and /dev/null differ diff --git a/laser.lua b/laser.lua deleted file mode 100644 index c5580c4..0000000 --- a/laser.lua +++ /dev/null @@ -1,29 +0,0 @@ -laser = class:new() - -function laser:init(x, y) - self.i = 0 - self.x = x - self.y = y -end - -function laser:update(dt) - local oldi = self.i - self.i = self.i + dt*5 - - if self.i > 1 then - return true - end - - if enemies then - for i, v in pairs(enemies) do - if v:checkcol(self.x + oldi*100, self.y, self.x + self.i*100) then - v:explode() - end - end - end -end - -function laser:draw() - love.graphics.setColor(getrainbowcolor(math.random(), 400)) - love.graphics.rectangle("fill", self.x*scale, self.y*scale, 100*scale*self.i, scale*2) -end \ No newline at end of file diff --git a/main.lua b/main.lua deleted file mode 100644 index 70ca008..0000000 --- a/main.lua +++ /dev/null @@ -1,316 +0,0 @@ -function love.load() - love.graphics.setDefaultImageFilter("nearest", "nearest") - - require "class" - require "menu" - require "cloud" - require "cloud2" - require "bush" - require "scene1" - require "scene2" - require "scene3" - require "scene4" - require "scene5" - require "scene6" - require "laser" - require "enemy" - require "explosion" - require "bigexplosion" - require "splatter" - require "powerup" - require "rocket" - require "star" - require "asteroid" - require "bullet" - require "bird" - - love.graphics.setIcon( love.graphics.newImage("graphics/icon.png") ) - imagelist = {"title", "cloud1", "cloud2", "ground", "bush1", "bush2", "powerup", "rocket", "star", "asteroid-big1", "sunglasses", "awesome", "arrow", "groundwin", - "asteroid-big2", "asteroid-small1", "asteroid-small2", "bullet", "littleexplosion", "warning", "wheatley", "alert", "randomshit", "bird"} - - for i = 1, #imagelist do - _G[imagelist[i] .. "img"] = love.graphics.newImage("graphics/" .. imagelist[i] .. ".png") - end - - fontimage = love.graphics.newImage("graphics/font.png") - - fontglyphs = "0123456789abcdefghijklmnopqrstuvwxyz.:/,'C-_>* !{}?" - fontquads = {} - for i = 1, string.len(fontglyphs) do - fontquads[string.sub(fontglyphs, i, i)] = love.graphics.newQuad((i-1)*8, 0, 8, 8, 408, 8) - end - - playerimg = love.graphics.newImage("graphics/trosh.png") - 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)} - - winplayerimg = love.graphics.newImage("graphics/troshwin.png") - winplayerquad = {} - for x = 1, 4 do - winplayerquad[x] = love.graphics.newQuad((x-1)*11, 0, 11, 26, 44, 26) - end - - enemyimg = love.graphics.newImage("graphics/enemy.png") - enemyquad = {} - for y = 1, 4 do - for x = 1, 4 do - enemyquad[(y-1)*4+x] = love.graphics.newQuad((x-1)*100, (y-1)*96, 100, 96, 400, 384) - end - end - - explosionimg = love.graphics.newImage("graphics/explosion.png") - explosionquad = {} - for y = 1, 5 do - for x = 1, 5 do - explosionquad[(y-1)*5+x] = love.graphics.newQuad((x-1)*66, (y-1)*81, 66, 81, 330, 405) - end - end - - bigexplosionimg = love.graphics.newImage("graphics/bigexplosion.png") - bigexplosionquad = {} - for y = 1, 5 do - for x = 1, 5 do - bigexplosionquad[(y-1)*5+x] = love.graphics.newQuad((x-1)*108, (y-1)*121, 108, 121, 540, 605) - end - end - - splatterimg = love.graphics.newImage("graphics/splatter.png") - splatterquad = {} - for x = 1, 6 do - splatterquad[x] = love.graphics.newQuad((x-1)*64, 0, 64, 64, 384, 64) - end - - birdquad = {love.graphics.newQuad(0, 0, 29, 16, 29, 32), love.graphics.newQuad(0, 16, 29, 16, 29, 32)} - - scale = 8 - local w, h = love.graphics.getMode() - if w ~= 100*scale or h ~= 80*scale then - love.graphics.setMode(100*scale, 80*scale, false, true, 0) - end - love.graphics.setIcon( love.graphics.newImage("graphics/icon.png") ) - - bgmusic = love.audio.newSource("audio/trosong.ogg") - bgmusic:setLooping(true) - lasersound = love.audio.newSource("audio/laser.wav") - bigexplosionsound = love.audio.newSource("audio/bigexplosion.ogg") - explosionsound = love.audio.newSource("audio/explosion.wav") - launchsound = love.audio.newSource("audio/launch.ogg") - gunfire = love.audio.newSource("audio/gunfire.wav") - space = love.audio.newSource("audio/space.ogg") - sunglassessound = love.audio.newSource("audio/sunglasses.ogg") - splat = love.audio.newSource("audio/splat.ogg") - ding = love.audio.newSource("audio/ding.ogg") - credits = love.audio.newSource("audio/credits.ogg") - approach = love.audio.newSource("audio/approach.ogg") - credits:setLooping(true) - - skipupdate = true - shakeamount = 0 - shake = 0 - fade = 0 - playerframe = 1 - scoreanim = 1 - rainbowi = 0.5 - sini = 0 - sini2 = math.pi/2 - scrollx = 0 - points = 0 - machinedelay = 0.05 - stars = {} - explosions = {} - backgroundstripes = 10 - sunrot = 0 - - lasers = {} - - realasteroiddelay = 1 - movement1speed = 100 - laserdelay = 0 - reallaserdelay = 0.4 - starttimer = 0 - changegamestate("menu") -end - -function love.update(dt) - if skipupdate then - skipupdate = false - return - end - - sunrot = sunrot + dt*50 - - starttimer = starttimer + dt - - if scoreanim < 1 then - scoreanim = scoreanim + (1-scoreanim)*8*dt - end - - if laserdelay > 0 then - laserdelay = math.max(0, laserdelay-dt) - end - - shake = math.random()*shakeamount*2-shakeamount - - if _G[gamestate .. "_update"] then - _G[gamestate .. "_update"](dt) - end - - --LASERS - local delete = {} - - for i, v in pairs(lasers) do - if v:update(dt) == true then - table.insert(delete, i) - end - end - - table.sort(delete, function(a,b) return a>b end) - - for i, v in pairs(delete) do - table.remove(lasers, v) --remove - end -end - -function pointsget(i) - points = points + i - scoreanim = 0 - rainbowi = math.random() - shakeamount = 10 -end - -function love.draw() - love.graphics.translate(50*scale, 40*scale) - love.graphics.rotate(shake/300) - love.graphics.translate(-50*scale, -40*scale) - - love.graphics.translate(shake*scale/4, shake*scale/4) - - if _G[gamestate .. "_draw"] then - _G[gamestate .. "_draw"]() - end - - - if gamestate ~= "menu" and gamestate ~= "scene6" and not landing then - local r, g, b = unpack(getrainbowcolor(rainbowi)) - - local ar = r + (255-r)*scoreanim - local ag = g + (255-g)*scoreanim - local ab = b + (255-b)*scoreanim - - love.graphics.setColor(ar, ag, ab) - - local s = scale*0.5+(1-scoreanim)*10 - love.graphics.rotate((1-scoreanim)*0.4) - properprint("score: " .. points, 2, 2, s) - love.graphics.rotate(-(1-scoreanim)*0.4) - end - - love.graphics.translate(-shake*scale/4, -shake*scale/4) - - - love.graphics.translate(50*scale, 40*scale) - love.graphics.rotate(-shake/300) - love.graphics.translate(-50*scale, -40*scale) - if fade > 0 then - love.graphics.setColor(255, 255, 255, 255*fade) - love.graphics.rectangle("fill", 0, 0, 100*scale, 80*scale) - love.graphics.setColor(255, 255, 255, 255) - end -end - -function love.keypressed(key, unicode) - if _G[gamestate .. "_keypressed"] then - _G[gamestate .. "_keypressed"](key, unicode) - end - - if key ~= "left" and key ~= "up" and key ~= "right" and key ~= "down" then - if _G[gamestate .. "_action"] then - _G[gamestate .. "_action"](key) - end - end -end - -function love.keyreleased(key, unicode) - if _G[gamestate .. "_keyreleased"] then - _G[gamestate .. "_keyreleased"](key, unicode) - end -end - -function changegamestate(i) - gamestate = i - if _G[gamestate .. "_load"] then - _G[gamestate .. "_load"]() - end -end - -function draw(drawable, x, y, r, sx, sy, ox, oy, kx, ky) - if not sx then - sx = 1 - end - if not sy then - sy = 1 - end - love.graphics.draw(drawable, x*scale, y*scale, r, sx*scale, sy*scale, ox, oy, kx, ky ) -end - -function round(num, idp) --Not by me - local mult = 10^(idp or 0) - return math.floor(num * mult + 0.5) / mult -end - -function properprint(s, x, y, sc) - local sc = sc or scale - local startx = x - local skip = 0 - for i = 1, string.len(tostring(s)) do - if skip > 0 then - skip = skip - 1 - else - local char = string.sub(s, i, i) - if fontquads[char] then - love.graphics.drawq(fontimage, fontquads[char], x*scale+((i-1)*8+1)*sc, y*scale, 0, sc, sc) - end - end - end -end - -function round(num, idp) --Not by me - local mult = 10^(idp or 0) - return math.floor(num * mult + 0.5) / mult -end - -function getrainbowcolor(i, whiteness) - local whiteness = whiteness or 255 - local r, g, b - if i < 1/6 then - r = 1 - g = i*6 - b = 0 - elseif i >= 1/6 and i < 2/6 then - r = (1/6-(i-1/6))*6 - g = 1 - b = 0 - elseif i >= 2/6 and i < 3/6 then - r = 0 - g = 1 - b = (i-2/6)*6 - elseif i >= 3/6 and i < 4/6 then - r = 0 - g = (1/6-(i-3/6))*6 - b = 1 - elseif i >= 4/6 and i < 5/6 then - r = (i-4/6)*6 - g = 0 - b = 1 - else - r = 1 - g = 0 - b = (1/6-(i-5/6))*6 - end - - local add = 0 - if whiteness > 255 then - add = whiteness-255 - end - - return {math.min(255, round(r*whiteness)+add), math.min(255, round(g*whiteness)+add), math.min(255, round(b*whiteness)+add), 255} -end \ No newline at end of file diff --git a/menu.lua b/menu.lua deleted file mode 100644 index a5f26ed..0000000 --- a/menu.lua +++ /dev/null @@ -1,125 +0,0 @@ -function menu_load() - love.graphics.setBackgroundColor(153, 217, 234) - clouds = {} - bushes = {} - love.audio.play(bgmusic) - for i = 1, 5 do - table.insert(clouds, cloud:new(true)) - end - for i = 1, 30 do - table.insert(bushes, bush:new(true)) - end - - textpos = {} - for i = 0, 7 do - textpos[i] = 10 - end - playerframetimer = 0 - playery = 50 - playerx = 10 - -- 1 2 3 4 5 6 7 - startactions = {2.3, 4.6, 7, 8.20, 9.20, 10.20, 11.20} - starti = 0 - -end - -function menu_update(dt) - for i, v in pairs(clouds) do - v:update(dt) - end - for i, v in pairs(bushes) do - v:update(dt) - end - - scrollx = scrollx + dt*50 - - rainbowi = math.mod(rainbowi + dt/2, 1) - sini = math.mod(sini + dt*10, math.pi*2) - sini2 = math.mod(sini2 + dt*5, math.pi*2) - - if starttimer > startactions[starti+1] then - starti = starti+1 - if starti == 7 then - changegamestate("scene1") - return - end - end - - if starti >= 4 then - shakeamount = shakeamount + dt*4 - end - if starti >= 5 then - shakeamount = shakeamount + dt*10 - end - if starti >= 6 then - shakeamount = shakeamount + dt*50 - end - - for i = -1, starti-1 do - if i >= 0 then - textpos[i] = textpos[i]+(textpos[i]^2*dt) - end - end - - playerframetimer = playerframetimer + dt*10 - while playerframetimer >= 2 do - playerframetimer = playerframetimer - 2 - end - playerframe = math.floor(playerframetimer)+1 - - playermovement1(dt) -end - -function menu_action() - shootlaser() -end - -function menu_draw() - love.graphics.setColor(255, 255, 255) - for i, v in pairs(clouds) do - v:draw() - end - - for i = 1, 2 do - draw(groundimg, -math.mod(scrollx, 120) + (i-1)*120, 59) - end - for i, v in pairs(bushes) do - v:draw() - end - - love.graphics.drawq(playerimg, playerquad[playerframe], playerx*scale, playery*scale, 0, scale, scale, 7, 12) - for i, v in pairs(lasers) do - v:draw() - end - - love.graphics.setColor(getrainbowcolor(rainbowi, 420)) - draw(titleimg, 50, 23, math.sin(sini)/10, (math.sin(sini2)+1)/5+0.7, (math.sin(sini2)+1)/5+0.7, 50, 13) - - love.graphics.setColor(255, 0, 0) - if starti >= 0 then - properprint("directed by maurice", 13, 40+textpos[0], scale/2) - end - if starti >= 1 then - properprint("utilise les fleches", 11, 40+textpos[1], scale/2) - end - if starti >= 2 then - properprint("et la touche espace", 12, 40+textpos[2], scale/2) - end - if starti >= 3 then - properprint("pret...", 30, 40+textpos[3], scale/2) - end - if starti >= 4 then - properprint("3", 40, 40+textpos[4], scale*2) - end - if starti >= 5 then - properprint("2", 36, 40+textpos[5], scale*3) - end - if starti >= 6 then - properprint("1", 32, 40+textpos[6], scale*4) - end - if starti >= 7 then - properprint("go !", 10, 40+textpos[7], scale*6) - end - - love.graphics.setColor(255, 255, 255) -end diff --git a/powerup.lua b/powerup.lua deleted file mode 100644 index d657288..0000000 --- a/powerup.lua +++ /dev/null @@ -1,47 +0,0 @@ -powerup = class:new() - -function powerup:init() - self.x = 108 - self.y = math.random()*20+40 - self.speed = 30 - self.movement = 1 - self.blinktimer = 0 - self.blink = true -end - -function powerup:update(dt) - if self.movement == 1 then - self.y = self.y - dt*30 - if self.y < 40 then - self.movement = -1 - end - elseif self.movement == -1 then - self.y = self.y + dt*30 - if self.y > 70 then - self.movement = 1 - end - end - - self.blinktimer = self.blinktimer + dt - if self.blinktimer > 0.2 then - self.blinktimer = self.blinktimer - 0.5 - self.blink = not self.blink - end - - self.x = self.x - self.speed*dt -end - -function powerup:checkcol(x, y) - if math.abs(self.x+8-x) < 10 and math.abs(self.y+4-y) < 10 then - return true - end - return false -end - -function powerup:draw() - draw(powerupimg, self.x, self.y, 0, 1, 1, 8, 4) - love.graphics.setColor(255, 0, 0) - if self.x > 0 and self.blink then - properprint("prend la biere!!!", 15, 45, scale*0.5) - end -end diff --git a/readme.txt b/readme.txt deleted file mode 100644 index e90a9fa..0000000 --- a/readme.txt +++ /dev/null @@ -1,7 +0,0 @@ -Trosh: The Movie: The Game - -by Maurice - -Special appearances by Trosh and Nondescript Purple Pony. -Made in about 20 hours. - -Version éditée par Le Club Info pour ses évènements diff --git a/rocket.lua b/rocket.lua deleted file mode 100644 index 474aefd..0000000 --- a/rocket.lua +++ /dev/null @@ -1,227 +0,0 @@ -rocket = class:new() - -rocketspeed = 300 -maxrocketspeed = 100 - -function rocket:init() - self.x = 115 - self.y = 60 - self.r = 0 - self.speedx = 0 - self.ground = true - self.startingoffset = 0 - self.thrusttimer = 0 - thrusts = {} - machinegundelay = 0 - self.explosiondelay = 0 - self.explosiontimer = 0 -end - -function rocket:update(dt) - if self.ground then - if self.x > 50 then - self.x = self.x - dt*50 - if self.x < 50 then - self.x = 50 - end - end - else - self.startingoffset = (math.random()*2-1)*0.5 - end - - if self.starting then - self.startingtimer = self.startingtimer + dt - self.startingoffset = (math.random()*2-1)*2 - - if self.startingtimer > 2 then - self.y = self.y - dt*5 - self:thrusts(dt) - end - - if self.startingtimer > 7 then - self.y = self.y + dt*50 - - if self.y > 70 then - self.starting = false - self.y = 70 - changegamestate("scene3") - self.inflight = true - end - end - end - - if self.inflight then - if love.keyboard.isDown("right") and self.x < 100 then - self.speedx = self.speedx + dt*rocketspeed - elseif self.speedx > 0 then - self.speedx = math.max(0, self.speedx - dt*rocketspeed) - end - - if love.keyboard.isDown("left") and self.x > 0 then - self.speedx = self.speedx - dt*rocketspeed - elseif self.speedx < 0 then - self.speedx = math.min(0, self.speedx + dt*rocketspeed) - end - - self.speedx = math.min(maxrocketspeed, math.max(-maxrocketspeed, self.speedx)) - - self.x = self.x + self.speedx*dt - if self.x > 100 then - self.x = 100 - elseif self.x < 0 then - self.x = 0 - end - - self.r = self.speedx/200 - - if #pressedkeys > 0 then - machinegundelay = machinegundelay + dt - while machinegundelay > machinedelay do - self:fire() - machinegundelay = machinegundelay - machinedelay - end - end - - if wheatleytimer then - wheatleytimer = wheatleytimer + dt*2 - wheatleyr = wheatleyr + dt*10 - - if wheatleytimer >= 0.95 and wheatleytimer - dt*2 < 0.95 then - table.insert(explosions, explosion:new(self.x-20, self.y-20)) - rocketimg = love.graphics.newImage("graphics/rocketkaputt.png") - changegamestate("scene4") - self.hit = true - self.inflight = false - end - end - end - shakeamount = self.startingoffset*3 - - if self.hit then - wheatleytimer = wheatleytimer + dt*2 - wheatleyr = wheatleyr + dt*10 - if wheatleytimer < 4 then - if self.r > 0 then - self.r = self.r - dt - else - self.r = self.r + dt - end - else - if self.r < math.pi*0.9 then - self.r = self.r + dt - starmover = -self.r - self.y = self.y - dt*20 - if self.x > 10 then - self.x = self.x - dt*10 - elseif self.x < 10 then - self.x = self.x + dt*10 - end - end - end - - self.explosiontimer = self.explosiontimer + dt - while self.explosiontimer > self.explosiondelay do - self.explosiontimer = self.explosiontimer - self.explosiondelay - self.explosiondelay = math.random(100)/300+0.1 - table.insert(explosions, explosion:new(self.x-16+math.random(16)-8, self.y-20+math.random(16)-8)) - end - self.startingoffset = self.startingoffset*10 - end - - --THRUSTS - local delete = {} - - for i, v in pairs(thrusts) do - if v:update(dt) == true then - table.insert(delete, i) - end - end - - table.sort(delete, function(a,b) return a>b end) - - for i, v in pairs(delete) do - table.remove(thrusts, v) --remove - end -end - -function rocket:fire() - local outx = -math.sin(self.r) * -14 + self.x - local outy = math.cos(self.r) * -14 + self.y - - table.insert(bullets, bullet:new(outx, outy, self.r)) -end - -function rocket:thrusts(dt) --if you know what I mean - self.thrusttimer = self.thrusttimer + dt - local delay = 0.01 - while self.thrusttimer > delay do - self.thrusttimer = self.thrusttimer - delay - table.insert(thrusts, thrust:new(self.x-6, self.y+10)) - table.insert(thrusts, thrust:new(self.x, self.y+10)) - table.insert(thrusts, thrust:new(self.x+6, self.y+10)) - end -end - -function rocket:start() - self.starting = true - self.ground = false - self.startingtimer = 0 -end - -function rocket:checkcol(x, y) - if math.abs(self.x-x) < 16 and math.abs(self.y-y) < 16 then - return true - end - return false -end - -function rocket:draw() - local r, g, b = love.graphics.getColor() - for i, v in pairs(thrusts) do - v:draw() - end - love.graphics.setColor(r, g, b) - draw(rocketimg, self.x+self.startingoffset, self.y, self.r, 1, 1, 15, 16) - - if wheatleytimer then - if wheatleytimer <= 0.95 then - draw(wheatleyimg, self.x-20*(1-wheatleytimer/1), self.y-120*(1-wheatleytimer/1), wheatleyr, 1, 1, 8, 9) - else - draw(wheatleyimg, self.x-20*(1-0.95/1)-(wheatleytimer-0.95)*200, self.y-120*(1-wheatleytimer/1)+(wheatleytimer-0.95)*20, wheatleyr, 1, 1, 8, 9) - end - end -end - -function rocket:wheatleyattack() - wheatleytimer = 0 - wheatleyr = 0 - space:play() -end - ---THRUST - -thrust = class:new() - -function thrust:init(x, y) - self.x = x - self.y = y - self.starty = rockets[1].y - self.dir = (math.random()*2-1)*0.4+math.pi/2 + rockets[1].r - self.speed = 40 - self.life = 1 -end - -function thrust:update(dt) - self.x = self.x + math.cos(self.dir)*self.speed*dt - self.y = self.y + math.sin(self.dir)*self.speed*dt - - self.life = self.life - dt - if self.life <= 0 then - return true - end -end - -function thrust:draw() - love.graphics.setColor(255, 255, 255, 255*self.life) - love.graphics.rectangle("fill", self.x*scale, self.y*scale+(rockets[1].y-self.starty)*scale, scale, scale) -end \ No newline at end of file diff --git a/scene1.lua b/scene1.lua deleted file mode 100644 index c81b075..0000000 --- a/scene1.lua +++ /dev/null @@ -1,189 +0,0 @@ -function scene1_load() - shakeamount = 0 - shake = 0 - fade = 1 - enemies = {} - powerups = {} - enemytimer = 0 - nextenemy = 0 - nextstage = false -end - -function scene1_update(dt) - if shakeamount > 0 then - shakeamount = math.max(0, shakeamount-dt*10) - end - - enemytimer = enemytimer + dt - while enemytimer > nextenemy and not nextstage do - enemytimer = enemytimer - nextenemy - if massenemies then - nextenemy = math.random(10)/1000+.002 - else - nextenemy = math.random(10)/10+.1 - end - table.insert(enemies, enemy:new()) - end - rainbowi = math.mod(rainbowi + dt/2, 1) - - - for i, v in pairs(clouds) do - v:update(dt) - end - for i, v in pairs(bushes) do - v:update(dt) - end - for i, v in pairs(powerups) do - v:update(dt) - end - - if starttimer > 32 and starttimer - dt < 32 then - table.insert(powerups, powerup:new()) - end - - if starttimer > 45 and starttimer - dt < 45 then - nextstage = true - end - - if starttimer > 47 and starttimer - dt < 47 then - rockets = {rocket:new()} - end - - if powerups[1] and powerups[1]:checkcol(playerx, playery) then - reallaserdelay = 0.05 - massenemies = true - powerups[1] = nil - end - - --ENEMIES - local delete = {} - - for i, v in pairs(enemies) do - if v:update(dt) == true then - table.insert(delete, i) - end - end - - table.sort(delete, function(a,b) return a>b end) - - for i, v in pairs(delete) do - table.remove(enemies, v) --remove - end - - --EXPLOSION - local delete = {} - - for i, v in pairs(explosions) do - if v:update(dt) == true then - table.insert(delete, i) - end - end - - table.sort(delete, function(a,b) return a>b end) - - for i, v in pairs(delete) do - table.remove(explosions, v) --remove - end - - if fade > 0 then - fade = math.max(0, fade-dt) - end - - playerframetimer = playerframetimer + dt*10 - while playerframetimer >= 2 do - playerframetimer = playerframetimer - 2 - end - playerframe = math.floor(playerframetimer)+1 - - if not rockets or rockets[1].x > 50 then - scrollx = scrollx + dt*50 - end - - if rockets and rockets[1]:checkcol(playerx, playery) and rockets[1].x <= 50 then - changegamestate("scene2") - end - - playermovement1(dt) - - if rockets then - rockets[1]:update(dt) - end -end - -function playermovement1(dt) - if love.keyboard.isDown("left") then - playerx = math.max(0, playerx-dt*movement1speed) - elseif love.keyboard.isDown("right") then - playerx = math.min(100, playerx+dt*movement1speed) - end - - if love.keyboard.isDown("up") then - playery = math.max(50, playery-dt*movement1speed) - elseif love.keyboard.isDown("down") then - playery = math.min(80, playery+dt*movement1speed) - end -end - -function scene1_action() - shootlaser() -end - -function shootlaser() - if laserdelay == 0 then - table.insert(lasers, laser:new(playerx, playery-8)) - lasersound:stop() - lasersound:play() - laserdelay = reallaserdelay - end -end - -function scene1_draw() - local r, g, b = love.graphics.getColor() - love.graphics.setColor(math.random(255), math.random(255), math.random(255), 255*(1-scoreanim)) - for i = 1, backgroundstripes, 2 do - local alpha = math.rad((i/backgroundstripes + math.mod(sunrot/100, 1)) * 360) - local point1 = {50*scale+100*scale*math.cos(alpha), 64*scale+100*scale*math.sin(alpha)} - - local alpha = math.rad(((i+1)/backgroundstripes + math.mod(sunrot/100, 1)) * 360) - local point2 = {50*scale+100*scale*math.cos(alpha), 64*scale+100*scale*math.sin(alpha)} - - love.graphics.polygon("fill", 50*scale, 64*scale, point1[1], point1[2], point2[1], point2[2]) - end - love.graphics.setColor(r, g, b, 255) - - for i, v in pairs(clouds) do - v:draw() - end - - for i = 1, 2 do - draw(groundimg, -math.mod(scrollx, 100) + (i-1)*100, 59) - end - for i, v in pairs(bushes) do - v:draw() - end - for i, v in pairs(enemies) do - v:draw() - end - for i, v in pairs(explosions) do - v:draw() - end - - if rockets then - rockets[1]:draw() - end - - love.graphics.drawq(playerimg, playerquad[playerframe], playerx*scale, playery*scale, 0, scale, scale, 7, 12) - for i, v in pairs(lasers) do - v:draw() - end - love.graphics.setColor(255, 255, 255) - for i, v in pairs(powerups) do - v:draw() - end - - if starttimer > 46 then - love.graphics.setColor(255, 0, 0) - properprint("dans la fuse !!!", 10, 45, scale*0.5) - end - love.graphics.setColor(255, 255, 255) -end diff --git a/scene2.lua b/scene2.lua deleted file mode 100644 index a761072..0000000 --- a/scene2.lua +++ /dev/null @@ -1,75 +0,0 @@ -function scene2_load() - starttimer = 0 - shakeamount = 0 - rockets[1].x = 50 - rockets[1]:start() - launchsound:stop() - launchsound:play() - - for y = 1, 30 do - for i = 1, 5 do - table.insert(clouds, cloud:new(true, -y*30)) - end - end - - backgroundcolor = {love.graphics.getBackgroundColor()} -end - -function scene2_update(dt) - for i, v in pairs(clouds) do - v:update(dt) - end - rockets[1]:update(dt) - - if starttimer > 7 then - love.graphics.setBackgroundColor(0, 0, 0) - elseif starttimer > 6 then - local r, g, b = unpack(backgroundcolor) - r = r*(1-(starttimer-6)/1) - g = g*(1-(starttimer-6)/1) - b = b*(1-(starttimer-6)/1) - - love.graphics.setBackgroundColor(r, g, b) - end - - if starttimer > 7 then - if starttimer - dt <= 7 then - for i = 1, 10 do - table.insert(stars, star:new()) - end - end - - staralpha = math.min(1, (starttimer-7)/9) - end -end - -function scene2_draw() - - local launchoffset = 0 - if starttimer > 3 then - launchoffset = 10^(starttimer-3)+(starttimer-3)*20 - end - - love.graphics.translate(0, launchoffset) - - for i, v in pairs(clouds) do - v:draw() - end - - for i = 1, 2 do - draw(groundimg, -math.mod(scrollx, 100) + (i-1)*100, 59) - end - for i, v in pairs(bushes) do - v:draw() - end - love.graphics.translate(0, -launchoffset) - - - for i,v in pairs(stars) do - v:draw() - end - - love.graphics.setColor(255, 255, 255, 255) - - rockets[1]:draw() -end \ No newline at end of file diff --git a/scene3.lua b/scene3.lua deleted file mode 100644 index 53f6e1e..0000000 --- a/scene3.lua +++ /dev/null @@ -1,153 +0,0 @@ -function scene3_load() - backgroundwhite = 0 - staralpha = 1 - asteroids = {} - bullets = {} - asteroidtimer = 0 - rockets = {rocket:new()} - love.audio.play(bgmusic) - rockets[1].x = 50 - rockets[1].y = 70 - rockets[1].ground = false - rockets[1].inflight = true - - table.insert(asteroids, asteroid:new()) - - if #stars == 0 then - for i = 1, 10 do - table.insert(stars, star:new()) - end - end - - lastexplosion = {50, 40} - - pressedkeys = {} - starttimer = 0 - warningtimer = 0 -end - -function scene3_update(dt) - realasteroiddelay = math.max(0.05, 8/starttimer) - backgroundwhite = math.max(0, backgroundwhite - dt) - love.graphics.setBackgroundColor(math.random(127)*backgroundwhite, math.random(127)*backgroundwhite, math.random(127)*backgroundwhite) - - if starttimer < 35 then - asteroidtimer = asteroidtimer + dt - - while asteroidtimer > realasteroiddelay do - asteroidtimer = asteroidtimer - realasteroiddelay - table.insert(asteroids, asteroid:new()) - end - end - - for i, v in pairs(stars) do - v:update(dt) - end - - --ASTEROIDS - local delete = {} - - for i, v in pairs(asteroids) do - if v:update(dt) == true then - table.insert(delete, i) - end - end - - table.sort(delete, function(a,b) return a>b end) - - for i, v in pairs(delete) do - table.remove(asteroids, v) --remove - end - - --BULLETS - local delete = {} - - for i, v in pairs(bullets) do - if v:update(dt) == true then - table.insert(delete, i) - end - end - - table.sort(delete, function(a,b) return a>b end) - - for i, v in pairs(delete) do - table.remove(bullets, v) --remove - end - - - - --EXPLOSION - local delete = {} - - for i, v in pairs(explosions) do - if v:update(dt) == true then - table.insert(delete, i) - end - end - - table.sort(delete, function(a,b) return a>b end) - - for i, v in pairs(delete) do - table.remove(explosions, v) --remove - end - - rockets[1]:update(dt) - - if (starttimer > 38 and starttimer < 40) or warningtimer > 0.1 then - warningtimer = math.mod(warningtimer + dt*7, math.pi*2) - end - - if starttimer >= 40 and starttimer - dt < 40 then - rockets[1]:wheatleyattack() - end -end - -function scene3_draw() - local r, g, b = love.graphics.getColor() - love.graphics.setColor(math.random(255), math.random(255), math.random(255), 255*(1-scoreanim)) - for i = 1, backgroundstripes, 2 do - local alpha = math.rad((i/backgroundstripes + math.mod(sunrot/100, 1)) * 360) - local point1 = {lastexplosion[1]*scale+200*scale*math.cos(alpha), lastexplosion[2]*scale+200*scale*math.sin(alpha)} - - local alpha = math.rad(((i+1)/backgroundstripes + math.mod(sunrot/100, 1)) * 360) - local point2 = {lastexplosion[1]*scale+200*scale*math.cos(alpha), lastexplosion[2]*scale+200*scale*math.sin(alpha)} - - love.graphics.polygon("fill", lastexplosion[1]*scale, lastexplosion[2]*scale, point1[1], point1[2], point2[1], point2[2]) - end - love.graphics.setColor(r, g, b, 255) - - for i,v in pairs(stars) do - v:draw() - end - for i,v in pairs(asteroids) do - v:draw() - end - - rockets[1]:draw() - for i,v in pairs(bullets) do - v:draw() - end - for i, v in pairs(explosions) do - v:draw() - end - - if (starttimer > 38 and starttimer < 40) or warningtimer > 0.1 then - love.graphics.setColor(255, 0, 0, math.abs(math.sin(warningtimer))*255) - draw(warningimg, -3+math.random(5)-3, 20+math.random(5)-3) - end -end - -function scene3_keypressed(key) - if key ~= "left" and key ~= "up" and key ~= "right" and key ~= "down" then - table.insert(pressedkeys, key) - end -end - -function scene3_keyreleased(key) - for i = 1, #pressedkeys do - if pressedkeys[i] == key then - table.remove(pressedkeys, i) - break - end - end -end \ No newline at end of file diff --git a/scene4.lua b/scene4.lua deleted file mode 100644 index 8bafdc0..0000000 --- a/scene4.lua +++ /dev/null @@ -1,174 +0,0 @@ -function scene4_load() - backgroundwhite = 0 - staralpha = 1 - asteroids = {} - bullets = {} - love.audio.play(bgmusic) - - starttimer = 0 - alerttimer = 0 - flyingquad = 3 - - pspeedx = 0 - pspeedy = 0 - - playerx = nil - - flyanimationtimer = 0 -end - -function scene4_update(dt) - if secondtimer then - secondtimer = secondtimer + dt - end - for i, v in pairs(stars) do - v:update(dt) - end - - --EXPLOSION - local delete = {} - - for i, v in pairs(explosions) do - if v:update(dt) == true then - table.insert(delete, i) - end - end - - table.sort(delete, function(a,b) return a>b end) - - for i, v in pairs(delete) do - table.remove(explosions, v) --remove - end - - if rockets[1] then - rockets[1]:update(dt) - end - - if (starttimer > 0 and starttimer < 3) or alerttimer > 0.1 then - alerttimer = math.mod(alerttimer + dt*7, math.pi*2) - end - - if jumped then - if rockets[1] then - rockets[1].x = rockets[1].x - dt*3 - end - - if rockets[1] and secondtimer > 2 and secondtimer - dt <= 2 then - for i = 1, 20 do - if explosions then - table.insert(explosions, explosion:new(rockets[1].x-16+math.random(16)-8, rockets[1].y-20+math.random(16)-8)) - end - end - starmover = math.pi - rockets[1] = nil - end - - playerx = playerx + pspeedx*dt - playery = playery + pspeedy*dt - - if pspeedx > 0 then - pspeedx = pspeedx - dt*5 - end - - if playery >= 20 then - playery = 20 - pspeedy = 0 - end - - if playerx >= 50 then - pspeedx = 0 - playerx = 50 - end - - if secondtimer > 2 then - local i = math.max(0, (1-(secondtimer-2)/2)) - staralpha = math.max(0, (1-(secondtimer-2)/2))*i - love.graphics.setBackgroundColor(153*(1-i), 217*(1-i), 234*(1-i)) - - if shakeamount < 5 then - shakeamount = math.min(5, shakeamount+dt*3) - elseif shakeamount > 5 then - shakeamount = math.max(5, shakeamount-dt*3) - end - end - - if secondtimer > 4 then - changegamestate("scene5") - end - end - - if starttimer >= 4.3 and starttimer - dt < 4.3 then - playerx = rockets[1].x+4 - playery = rockets[1].y - end - - if jumped then - flyanimationtimer = flyanimationtimer + dt - while flyanimationtimer > 0.1 do - flyanimationtimer = flyanimationtimer - 0.1 - if flyingquad == 3 then - flyingquad = 4 - else - flyingquad = 3 - end - end - end -end - -function scene4_draw() - local r, g, b = love.graphics.getColor() - love.graphics.setColor(math.random(255), math.random(255), math.random(255), 255*(1-scoreanim)) - for i = 1, backgroundstripes, 2 do - local alpha = math.rad((i/backgroundstripes + math.mod(sunrot/100, 1)) * 360) - local point1 = {lastexplosion[1]*scale+200*scale*math.cos(alpha), lastexplosion[2]*scale+200*scale*math.sin(alpha)} - - local alpha = math.rad(((i+1)/backgroundstripes + math.mod(sunrot/100, 1)) * 360) - local point2 = {lastexplosion[1]*scale+200*scale*math.cos(alpha), lastexplosion[2]*scale+200*scale*math.sin(alpha)} - - love.graphics.polygon("fill", lastexplosion[1]*scale, lastexplosion[2]*scale, point1[1], point1[2], point2[1], point2[2]) - end - love.graphics.setColor(r, g, b, 255) - - for i,v in pairs(stars) do - v:draw() - end - - - if playerx then - local off = 0 - if rockets[1] then - off = rockets[1].startingoffset - end - love.graphics.drawq(playerimg, playerquad[flyingquad], (playerx+off)*scale, playery*scale, 0, scale, scale, 13, 6) - end - - if rockets[1] then - rockets[1]:draw() - end - for i, v in pairs(explosions) do - v:draw() - end - - if (starttimer > 0 and starttimer < 3) or alerttimer > 0.1 then - local i = math.abs(math.sin(alerttimer)) - love.graphics.setColor(255, 0, 0, i*100) - love.graphics.rectangle("fill", 0, 0, 100*scale, 80*scale) - love.graphics.setColor(255, 0, 0, i*255) - draw(alertimg, 50+math.random(5)-3, 40+math.random(5)-3, (math.random()*2-1)*0.1, i*0.5+0.6, i*0.5+0.6, 54, 15) - draw(randomshitimg, 50+math.random(20)-10, 40+math.random(20)-10, 0, 1, 1, 50, 42) - end - - if starttimer > 4 and not jumped then - love.graphics.setColor(255, 0, 0, math.random(255)) - properprint("saute!!", 0, 40, scale*2) - end -end - -function scene4_action() - if starttimer > 4.3 and not jumped then - jumped = true - secondtimer = 0 - pspeedx = 20 - pspeedy = 2 - end -end diff --git a/scene5.lua b/scene5.lua deleted file mode 100644 index d24f8b9..0000000 --- a/scene5.lua +++ /dev/null @@ -1,229 +0,0 @@ -function scene5_load() - love.graphics.setBackgroundColor(153, 217, 234) - love.audio.play(bgmusic) - - clouds2 = {} - for i = 1, 3 do - for y = 1, 8 do - table.insert(clouds2, cloud2:new(math.random()*140)) - end - end - - lastexplosion = {50, 40} - - starttimer = 0 - flyingquad = 3 - - playerx = 50 - playery = 20 - pspeedx = 0 - pspeedy = 0 - - birds = {} - splatters = {} - birdtimer = 0 - - flyanimationtimer = 0 - - shakeamount = 5 - awesometimer = 0 - - screenx = 0 - - landingtime = 2 - groundy = 90 - - landing = false -end - -function scene5_update(dt) - if starttimer < 20 then - birdtimer = birdtimer + dt - local birddelay = 0.5 - while birdtimer > birddelay do - birdtimer = birdtimer - birddelay - table.insert(birds, bird:new()) - end - end - - if starttimer >= 25 and starttimer - dt < 25 then - landing = true - timeleft = landingtime - landingx = math.random(60)+20 - end - - if starttimer >= 25.4 and starttimer - dt < 25.4 then - approach:play() - end - - if landing then - timeleft = timeleft - dt - if timeleft <= 0 then - timeleft = 0 - groundy = groundy - 400*dt - if groundy <= playery-10 then - changegamestate("scene6") - end - end - end - - for i,v in pairs(clouds2) do - v:update(dt) - end - - flyanimationtimer = flyanimationtimer + dt - while flyanimationtimer > 0.1 do - flyanimationtimer = flyanimationtimer - 0.1 - if flyingquad == 3 then - flyingquad = 4 - else - flyingquad = 3 - end - end - - if awesometimer > 0 then - awesometimer = awesometimer - dt - end - - if landing or starttimer < 24 then - playermovement2(dt) - else - if playerx > 50 then - playerx = playerx - 50*dt - elseif playerx < 50 then - playerx = playerx + 50*dt - end - - if playery > 40 then - playery = playery - 50*dt - elseif playery < 40 then - playery = playery + 50*dt - end - end - - - --BIRDS - local delete = {} - - for i, v in pairs(birds) do - if v:update(dt) == true then - table.insert(delete, i) - end - end - - table.sort(delete, function(a,b) return a>b end) - - for i, v in pairs(delete) do - table.remove(birds, v) --remove - end - - - --SPLATTERS - local delete = {} - - for i, v in pairs(splatters) do - if v:update(dt) == true then - table.insert(delete, i) - end - end - - table.sort(delete, function(a,b) return a>b end) - - for i, v in pairs(delete) do - table.remove(splatters, v) --remove - end - - for i, v in pairs(birds) do - if v:checkcol(playerx, playery) then - splat:stop() - splat:play() - pointsget(20) - table.insert(splatters, splatter:new(v.x, v.y)) - skycolor = getrainbowcolor(math.random(), 400) - love.graphics.setBackgroundColor(skycolor) - lastexplosion = {v.x, v.y} - end - end -end - -function playermovement2(dt) - if love.keyboard.isDown("left") then - playerx = math.max(0, playerx-dt*movement1speed) - elseif love.keyboard.isDown("right") then - playerx = math.min(100, playerx+dt*movement1speed) - end - - if not landing then - if love.keyboard.isDown("up") then - playery = math.max(0, playery-dt*movement1speed) - elseif love.keyboard.isDown("down") then - playery = math.min(80, playery+dt*movement1speed) - end - end -end - -function scene5_draw() - local r, g, b = love.graphics.getColor() - love.graphics.setColor(math.random(255), math.random(255), math.random(255), 100*math.min(1, (starttimer/2))) - for i = 1, backgroundstripes, 2 do - local pos = {playerx, playery} - local alpha = math.rad((i/backgroundstripes + math.mod(sunrot/100, 1)) * 360) - local point1 = {pos[1]*scale+200*scale*math.cos(alpha), pos[2]*scale+200*scale*math.sin(alpha)} - - local alpha = math.rad(((i+1)/backgroundstripes + math.mod(sunrot/100, 1)) * 360) - local point2 = {pos[1]*scale+200*scale*math.cos(alpha), pos[2]*scale+200*scale*math.sin(alpha)} - - love.graphics.polygon("fill", pos[1]*scale, pos[2]*scale, point1[1], point1[2], point2[1], point2[2]) - end - love.graphics.setColor(r, g, b, 255) - - for i,v in pairs(clouds2) do - v:draw() - end - for i,v in pairs(birds) do - v:draw() - end - for i,v in pairs(splatters) do - v:draw() - end - - if groundy < 90 then - draw(groundwinimg, -200+landingx+2, groundy) - end - - love.graphics.drawq(playerimg, playerquad[flyingquad], (playerx)*scale, playery*scale, 0, scale, scale, 13, 6) - - - if sunglasses then - draw(sunglassesimg, playerx+4, playery) - end - - if awesometimer > 0 then - draw(awesomeimg, (awesometimer*2-1)*100, 0) - love.graphics.setColor(0, 0, 0) - properprint("1000 points!", (awesometimer*2-1)*100+3, 73, scale) - love.graphics.setColor(255, 255, 255) - end - - if starttimer > 24 then - if math.mod(starttimer*5, 2) >= 1 then - love.graphics.setColor(255, 0, 0) - properprint("atteri sur la cible !", 0, 20, scale/1.5) - love.graphics.setColor(255, 255, 255) - end - end - - if landing then - draw(arrowimg, math.max(8, landingx-(timeleft/landingtime)*80), 67, 0, 1, 1, 8) - draw(arrowimg, math.min(91, landingx+(timeleft/landingtime)*80), 67, 0, -1, 1, 9) - end -end - -function scene5_action() - if not sunglasses then - sunglasses = true - awesometimer = 1 - pointsget(1000) - sunglassessound:play() - end -end diff --git a/scene6.lua b/scene6.lua deleted file mode 100644 index 6f4bd1c..0000000 --- a/scene6.lua +++ /dev/null @@ -1,187 +0,0 @@ -function scene6_load() - love.graphics.setBackgroundColor(153, 217, 234) - love.audio.stop(bgmusic) - - clouds2 = {} - clouds = {} - bushes = {} - bigexplosions = {} - - playerquad = 1 - - if sunglasses then - playerquad = 3 - end - - playeranimationtimer = 0 - starttimer = 0 - - birds = {} - splatters = {} - - shakeamount = 10 - - fade = 0 - ended = false - - playerx = playerx or 50 - landingx = landingx or 50 - - landdiff = playerx-landingx - - scoremul = round((1-math.abs(landdiff)/80)^8*4, 1) + 1 - - stars = {} - - texts = {} - texts[1] = "ton super score:" - texts[2] = points - texts[3] = "" - texts[4] = "multiplicateur de cible:" - texts[5] = scoremul - texts[6] = "" - texts[7] = "mega total:" - texts[8] = math.ceil(points*scoremul) - - prevt = 0 - - to = 0 - totimes = {8.55, 8.8, 9.4, 9.5, 9.7, 11.0, 12.3, 12.9, 13.2} -end - -function scene6_update(dt) - playeranimationtimer = playeranimationtimer + dt - while playeranimationtimer > 0.1 do - playeranimationtimer = playeranimationtimer - 0.1 - playerquad = playerquad + 1 - if playerquad == 3 then - playerquad = 1 - elseif playerquad == 5 then - playerquad = 3 - end - end - - for i, v in pairs(bigexplosions) do - v:update(dt) - end - - if starttimer >= 0.7 and starttimer - dt < 0.7 then - bigexplosionsound:play() - end - - if starttimer < 0.2 then - - elseif starttimer < 0.5 then - fade = 1 - - if #explosions == 0 then - table.insert(bigexplosions, bigexplosion:new(-4, -30)) - table.insert(bigexplosions, bigexplosion:new(-40, -30)) - table.insert(bigexplosions, bigexplosion:new(36, -30)) - table.insert(bigexplosions, bigexplosion:new(-4, -50)) - end - elseif starttimer < 4 then - if fade > 0.5 then - fade = fade - dt/2 - end - else - if fade > 0 then - fade = fade - dt/2 - end - end - - - if starttimer > 8.3 and starttimer - dt < 8.3 then - credits:play() - end - - if shakeamount > 0 then - shakeamount = shakeamount - dt*3 - end - - for i = 1, 9 do - if starttimer > totimes[i] then - to = i - end - end - - if starttimer >= 15.7 and starttimer -dt < 15.7 then - print(string.format("SCORE:%d", math.ceil(points*scoremul))); - ended = true - staralpha = 1 - - stars = {} - love.graphics.setBackgroundColor(0, 0, 0) - for i = 1, 10 do - table.insert(stars, star:new()) - end - end - for i,v in pairs(stars) do - v:update(dt) - end -end - -function scene6_draw() - local r, g, b = love.graphics.getColor() - for i = 1, backgroundstripes, 1 do - if math.mod(i, 2) == 1 then - love.graphics.setColor(255, 255, 0, math.min(1, math.max(0, 1-(starttimer-7)/2))*255) - else - love.graphics.setColor(255, 0, 0, math.min(1, math.max(0, 1-(starttimer-7)/2))*255) - end - local pos = {31, 53} - local alpha = math.rad((i/backgroundstripes + math.mod(sunrot/100, 1)) * 360) - local point1 = {pos[1]*scale+200*scale*math.cos(alpha), pos[2]*scale+200*scale*math.sin(alpha)} - - local alpha = math.rad(((i+1)/backgroundstripes + math.mod(sunrot/100, 1)) * 360) - local point2 = {pos[1]*scale+200*scale*math.cos(alpha), pos[2]*scale+200*scale*math.sin(alpha)} - - love.graphics.polygon("fill", pos[1]*scale, pos[2]*scale, point1[1], point1[2], point2[1], point2[2]) - end - love.graphics.setColor(r, g, b, 255) - for i,v in pairs(stars) do - v:draw() - v:draw() - v:draw() - v:draw() - end - - love.graphics.translate(20*scale, 50*scale) - love.graphics.rotate(math.pi/7) - love.graphics.translate(-20*scale, -50*scale) - - for i, v in pairs(bigexplosions) do - v:draw() - end - - draw(groundwinimg, -168-landdiff, 56) - love.graphics.drawq(winplayerimg, winplayerquad[playerquad], 30*scale, 55*scale, 0, scale, scale, 5, 13) - - love.graphics.translate(20*scale, 50*scale) - love.graphics.rotate(-math.pi/7) - love.graphics.translate(-20*scale, -50*scale) - - for i = 1, math.min(9, to) do - local s = scale/2 - if i >= 8 then - s = s * 2 - love.graphics.setColor(getrainbowcolor(math.random())) - end - if i == 9 then - draw(titleimg, 65, 65, 0, 0.7, 0.7, 50, 14) - else - properprint(texts[i], 50-tostring(texts[i]):len()*s/2, 5*i, s) - end - love.graphics.setColor(255, 255, 255) - end - - if ended and starttimer % (5/12) > (5/24) then - properprint("appuie sur espace pour recommencer", 15, 50, scale/4); - end -end - -function scene6_keypressed(key, unicode) - if ended then - love.event.quit() - end -end diff --git a/splatter.lua b/splatter.lua deleted file mode 100644 index 2c974dd..0000000 --- a/splatter.lua +++ /dev/null @@ -1,23 +0,0 @@ -splatter = class:new() - -function splatter:init(x, y) - self.x = x - self.y = y - self.quad = 1 - self.quadtimer = 0 -end - -function splatter:update(dt) - self.quadtimer = self.quadtimer + dt*30 - if self.quadtimer > 1 then - self.quadtimer = self.quadtimer - 1 - self.quad = self.quad + 1 - if self.quad == 7 then - return true - end - end -end - -function splatter:draw() - love.graphics.drawq(splatterimg, splatterquad[self.quad], self.x*scale, self.y*scale, 0, scale/2, scale/2, 40, 40) -end \ No newline at end of file diff --git a/star.lua b/star.lua deleted file mode 100644 index 66e53fc..0000000 --- a/star.lua +++ /dev/null @@ -1,37 +0,0 @@ -star = class:new() - -function star:init() - self.x = math.random(100) - self.y = math.random(80)-90 - self.speed = math.random(10)+1000 -end - -function star:update(dt) - if not starmover then - self.y = self.y + self.speed*dt - else - self.y = self.y + math.cos(starmover)*self.speed*dt - self.x = self.x + math.sin(starmover)*self.speed*dt - end - - if self.y > 110 or self.y < -10 or self.x > 110 or self.x < -10 then - self.speed = math.random(10)+1000 - self.x = math.random(100) - if self.y > 110 then - self.y = self.y-120 - elseif self.y < -10 then - self.y = self.y+120 - elseif self.x > 110 then - self.x = self.x-120 - else - self.x = self.x+120 - end - end -end - -function star:draw() - local r, g, b = love.graphics.getColor() - love.graphics.setColor(255, 255, 255, 255*staralpha) - draw(starimg, self.x, self.y, 0, 1, 1, 4.5) - love.graphics.setColor(r, g, b) -end \ No newline at end of file -- libgit2 0.21.2