My Submission: The Falling Spectrum. Dodge the rain. (Portrait)
May have bunched a few single line if statements together, or a couple pushStyle/popStyles sharing lines, but I did spend 3 hours on this do please don’t be too critical about that. Let me know what you guys thing ^.^ I may develop it a tad further into the App Store.
function setup()
displayMode(FULLSCREEN)
supportedOrientations(PORTRAIT_ANY)
mode = Classic()
score = 0
hs = readLocalData("highscore") or 0
time = os.clock()
fontSize(80)
song = music("Game Music One:Smoothie", true)
end
function draw()
background(255, 255, 255, 255)
mode:draw()
end
function touched(t)
if mode ~= nil then mode:touched(t) end
end
function collide(c)
if c.bodyA.id == mode.ball.id or c.bodyB.id== mode.ball.id then
mode.gameOver = true
physics.pause()
if score > hs then hs = score
saveLocalData("highscore", hs) end
end
end
Classic = class()
function Classic:init()
self.ball = physics.body(CIRCLE, 50)
self.ball.x,self.ball.y = WIDTH/5 * 2 + WIDTH/10,350
self.ball.gravityScale = 0
self.ball.color = color(127,127,127)
self.ball.id = 69
self.drops = {}
self.fade = 255
self.gameOver = false
end
function Classic:draw()
makeRain()
text(score, WIDTH/2, HEIGHT*.5)
pushStyle()
for a,b in pairs(self.drops) do
if b.y < WIDTH/5 + b.radius*2 + 10 then fill(b.color) else fill(127,127,127) end
ellipse(b.x,b.y,b.radius * 2)
end
fill(self.ball.color)
ellipse(self.ball.x, self.ball.y, self.ball.radius * 2)
popStyle()
for a = 1, 7 do
rect((a-1) * WIDTH/5, HEIGHT/5, WIDTH/5, WIDTH/10)
end
if not self.gameOver and self.fade > 0 then
pushStyle()
fill(255, 255, 255, self.fade)
rect(0,0, WIDTH, HEIGHT)
popStyle()
self.fade = self.fade - 2
end
if self.gameOver then
pushStyle()
fill(255, 255, 255, self.fade)
rect(0,0,WIDTH, HEIGHT)
self.fade = self.fade + 1.5
popStyle()
fill(127, 127, 127, self.fade)
if self.fade > 255 then fill(127) end
fontSize(50)
text("High Score: "..hs, WIDTH/2, HEIGHT * .75)
text("".."And So The \
Story Ended", WIDTH/2, HEIGHT*.5)
ellipse(WIDTH/2, HEIGHT/5, HEIGHT/5)
fill(255, 255, 255, 255)
text("AGAIN",WIDTH/2, HEIGHT/5)
end
pushStyle() fontSize(50)
text("By Kirk Zimmer", WIDTH* .75, HEIGHT *.05)
popStyle()
end
function Classic:touched(t)
self.ball.x = math.floor((t.x) /(WIDTH/5)) *WIDTH/5 + WIDTH/10
if self.gameOver and vec2(t.x,t.y):dist(vec2(WIDTH/2, HEIGHT/5)) < HEIGHT/10 then restart() end
end
function makeRain()
for a = 1, #mode.drops do
if mode.drops[a].y < -100 then
mode.ball.color = color(mode.drops[a].color.r, mode.drops[a].color.g, mode.drops[a].color.b, 20):blend(mode.ball.color)
mode.drops[a]:destroy()
mode.drops[a] = nil
table.remove(mode.drops, a)
score = score + 1
break
end
end
if #mode.drops < 40 and #mode.drops <= (score* 2) and math.random(100) <= (1 + score/10) and os.clock() - time > .05 then
local drop = physics.body(CIRCLE, math.random(20,WIDTH/30))
drop.x,drop.y = WIDTH/5 * (math.random(5)-1)+ WIDTH/10,HEIGHT* 1.2
drop.gravityScale = .09 + score*.006
drop.color = color(math.random(100,230), math.random(80,255), math.random(100,230), 255)
table.insert(mode.drops, drop)
time = os.clock()
end
end