|
-- Orb-Bits |
|
-- ======================= |
|
-- Version 1.0 |
|
-- 8 Jan 2012 |
|
-- Mark Sumner |
|
-- devilstower@gmail.com |
|
-- ======================= |
|
|
|
function setup() |
|
displayMode(FULLSCREEN) |
|
x = 100 |
|
y = 100 |
|
system = 1 |
|
scale = 1 |
|
deg = 270 |
|
ship = Ship(111,111) |
|
newSystem() |
|
soundtimer = 0 |
|
gameon = true |
|
end |
|
|
|
function newSystem() |
|
-- create systems |
|
if system == 1 then |
|
planets = {} |
|
rocks = {} |
|
planets[1] = Orbiter(75, 0, 20) |
|
planets[1].clr = color(222, 222, 222, 255) |
|
planets[2] = Orbiter(150, 0, 30) |
|
planets[2].clr = color(231, 230, 84, 255) |
|
planets[3] = Orbiter(220, 0, 30) |
|
planets[3].clr = color(134, 196, 224, 255) |
|
for i = 1, 36 do |
|
rocks[i] = Orbiter(320, i * 10, 6) |
|
rocks[i].clr = color(255, 0, 14, 255) |
|
rocks[i].tagged = true |
|
end |
|
ship = Ship(planets[1].radius, 0) |
|
ship.fuel = 600 |
|
elseif system == 2 then |
|
planets = {} |
|
rocks = {} |
|
planets[1] = Orbiter(80, 0, 22) |
|
planets[1].clr = color(166, 255, 0, 255) |
|
planets[2] = Orbiter(150, 0, 35) |
|
planets[2].clr = color(0, 237, 255, 255) |
|
planets[3] = Orbiter(300, 0, 40) |
|
planets[3].clr = color(255, 0, 222, 255) |
|
for i = 1, 36 do |
|
rocks[i] = Orbiter(200 + i * 10, i * 10, 6) |
|
rocks[i].clr = color(255, 0, 14, 255) |
|
rocks[i].tagged = true |
|
end |
|
ship = Ship(planets[2].radius, 0) |
|
ship.fuel = 500 |
|
elseif system == 3 then |
|
planets = {} |
|
rocks = {} |
|
planets[1] = Orbiter(100, 0, 22) |
|
planets[1].clr = color(227, 229, 223, 255) |
|
planets[2] = Orbiter(150, 0, 35) |
|
planets[2].clr = color(0, 237, 255, 255) |
|
planets[3] = Orbiter(290, 0, 20) |
|
planets[3].clr = color(255, 0, 222, 255) |
|
planets[4] = Orbiter(340, 0, 20) |
|
planets[4].clr = color(0, 255, 2, 255) |
|
for i = 1, 36 do |
|
rocks[i] = Orbiter(200 + math.random(50), i * 10, 6) |
|
rocks[i].clr = color(255, 0, 14, 255) |
|
rocks[i].tagged = true |
|
end |
|
ship = Ship(planets[4].radius, 0) |
|
ship.fuel = 400 |
|
elseif system == 4 then |
|
planets = {} |
|
rocks = {} |
|
planets[1] = Orbiter(35, 0, 15) |
|
planets[1].clr = color(224, 226, 221, 255) |
|
planets[2] = Orbiter(75, 0, 25) |
|
planets[2].clr = color(180, 225, 90, 255) |
|
planets[3] = Orbiter(125, 0, 25) |
|
planets[3].clr = color(0, 236, 255, 255) |
|
planets[4] = Orbiter(200, 0, 20) |
|
planets[4].clr = color(255, 145, 0, 255) |
|
for i = 1, 36 do |
|
rocks[i] = Orbiter(260 + math.random(35), i * 10, 6) |
|
rocks[i].clr = color(255, 0, 14, 255) |
|
rocks[i].tagged = true |
|
end |
|
planets[5] = Orbiter(340, 0, 50) |
|
planets[5].clr = color(176, 0, 255, 255) |
|
|
|
|
|
ship = Ship(planets[4].radius, 0) |
|
ship.fuel = 600 |
|
else |
|
-- random system |
|
numplanets = math.random(5) + 1 |
|
planets = {} |
|
for i = 1, numplanets do |
|
planets[i] = Orbiter(i * 75, math.random(360), |
|
math.random(25) + 10) |
|
planets[i].clr = color(155 + math.random(100), |
|
155 + math.random(100), 155 + math.random(100), 255) |
|
end |
|
rocks = {} |
|
--ring 1 |
|
numrocks = math.random(30) + 1 |
|
for i = 1, numrocks do |
|
rocks[i] = Orbiter( 190 + math.random(30), |
|
math.random(360), 6) |
|
rocks[i].clr = color(255, 0, 14, 255) |
|
rocks[i].tagged = true |
|
end |
|
ship = Ship(planets[numplanets].radius, |
|
planets[numplanets].deg) |
|
ship.fuel = 600 |
|
end |
|
end |
|
|
|
function draw() |
|
local i |
|
|
|
background(0, 0, 0) |
|
noSmooth() |
|
stroke(246, 255, 0, 255) |
|
pushMatrix() |
|
translate(WIDTH/2, HEIGHT/2) |
|
i = math.random(10) + 15 |
|
line(-i, 0, i, 0) |
|
line(0, -i, 0, i) |
|
line(-i, -i, i, i) |
|
line(-i, i, i, -i) |
|
popMatrix() |
|
|
|
alltagged = true |
|
|
|
for i, p in ipairs(planets) do |
|
p:draw() |
|
if ship.fire == false and p:land(ship.x, ship.y) then |
|
ship:land(p) |
|
p.tagged = true |
|
if ElapsedTime > soundtimer + 1 then |
|
sound(SOUND_JUMP, p.radius) |
|
soundtimer = ElapsedTime |
|
end |
|
end |
|
if not p.tagged then |
|
alltagged = false |
|
end |
|
end |
|
|
|
for i, r in ipairs(rocks) do |
|
r:draw() |
|
if r:land(ship.x, ship.y) and not ship.exploded then |
|
ship.exploded = true |
|
ship.exptimer = 1 |
|
end |
|
end |
|
|
|
if CurrentTouch.state == BEGAN or CurrentTouch.state == MOVING then |
|
|
|
if gameon then |
|
if not ship.exploded then |
|
if ship.fuel > 0 then |
|
ship.fire = true |
|
ship.fuel = ship.fuel - 1 |
|
end |
|
end |
|
else |
|
gameon = true |
|
ship = Ship(1000,1) |
|
scale = 1 |
|
system = 1 |
|
newSystem() |
|
end |
|
else |
|
ship.fire = false |
|
end |
|
|
|
ship:draw() |
|
|
|
if alltagged then |
|
scale = scale + 0.1 |
|
if scale > 8 then |
|
system = system + 1 |
|
newSystem() |
|
end |
|
else |
|
if scale > 1 then |
|
scale = scale - 0.1 |
|
end |
|
end |
|
|
|
if ship.radius < 10 then |
|
if scale > 0 then |
|
scale = scale - 0.1 |
|
else |
|
gameon = false |
|
end |
|
end |
|
|
|
if ship.exploded and ship.exptimer > 20 then |
|
gameon = false |
|
end |
|
|
|
if not gameon then |
|
line(300, 300, 300, 330) |
|
line(300, 300, 315, 300) |
|
line(300, 330, 315, 330) |
|
line(315, 300, 315, 315) |
|
line(315, 315, 310, 315) |
|
|
|
line(320, 300, 330, 330) |
|
line(330, 330, 340, 300) |
|
line(325, 315, 335, 315) |
|
|
|
line(350, 300, 360, 330) |
|
line(360, 330, 370, 300) |
|
line(370, 300, 380, 330) |
|
line(380, 330, 390, 300) |
|
|
|
line(400, 300, 400, 330) |
|
line(400, 300, 420, 300) |
|
line(400, 330, 420, 330) |
|
line(400, 315, 410, 315) |
|
|
|
line(600, 300, 600, 330) |
|
line(600, 300, 620, 300) |
|
line(600, 330, 620, 330) |
|
line(620, 330, 620, 300) |
|
|
|
line(630, 330, 640, 300) |
|
line(640, 300, 650, 330) |
|
|
|
line(660, 300, 660, 330) |
|
line(660, 300, 680, 300) |
|
line(660, 330, 680, 330) |
|
line(660, 315, 670, 315) |
|
|
|
line(690, 300, 690, 330) |
|
line(690, 330, 710, 330) |
|
line(710, 330, 690, 315) |
|
line(690, 315, 710, 300) |
|
|
|
end |
|
|
|
end |