--# Main
-- Geometry Jump
displayMode(OVERLAY)
displayMode(FULLSCREEN)
function setup()
touchControl = Touch()
stage = Stage()
stage:addObject(Polygon({vec2(-1000,0),vec2(99999,0),vec2(99999,100),vec2(-1000,100)},
{color(192, 192, 192, 255),color(190, 190, 190, 255),color(255, 255, 255, 255),color(255, 255, 255, 255)},true))
player = Player({vec2(-25,-25),vec2(25,-25),vec2(25,25),vec2(-25,25)},color(200,255,200))
player:setPosition(25,125)
player:setLinearSpeed(400,0)
stage:addObject(player)
for i = 0,100 do
local w = 30 + math.random() * 15
local p = Polygon({vec2(-w,-w),vec2(w,-w),vec2(w,w),vec2(-w,w)},
color(255 * math.random(), 255 * math.random(), 255 * math.random()),true)
p:initDynamicBody(i * 300,400 + math.random() * 50,30 * i)
p:setGravity(math.floor(math.random() * 2))
p:setAngularSpeed((math.random() - 0.5) * 100)
stage:addObject(p)
end
stage:setBackGround(Polygon({vec2(-1000,0),vec2(99999,0),vec2(99999,HEIGHT),vec2(-1000,HEIGHT)},
{color(241, 239, 238, 255),color(241, 239, 238, 255),color(197, 206, 101, 255),color(147, 113, 205, 255)}))
physics.gravity(0,-3000)
parameter.watch("1/DeltaTime")
end
function draw()
background(63, 63, 63, 255)
setCamera()
stage:draw()
end
function touched(touch)
stage:touched(touch)
touchControl:touched(touch)
end
function collide(contact)
stage:collide(contact)
end
function setCamera()
translate(-player.body.x + WIDTH / 2,0)
end
--# Stage
Stage = class()
function Stage:init()
self.objects = {}
self.backGround = nil
end
function Stage:draw()
if self.backGround then self.backGround:draw() end
for k,object in pairs(self.objects) do
object:draw()
end
end
function Stage:touched(touch)
for k,object in pairs(self.objects) do
object:touched(touch)
end
end
function Stage:collide(contact)
for k,object in pairs(self.objects) do
object:collide(contact)
end
end
function Stage:addObject(object)
table.insert(self.objects,object)
end
function Stage:setBackGround(bg)
self.backGround = bg
end
-- Geometry Jump
displayMode(OVERLAY)
displayMode(FULLSCREEN)
function setup()
touchControl = Touch()
stage = Stage()
stage:addObject(Polygon({vec2(-1000,0),vec2(99999,0),vec2(99999,100),vec2(-1000,100)},
{color(192, 192, 192, 255),color(190, 190, 190, 255),color(255, 255, 255, 255),color(255, 255, 255, 255)},true))
player = Player({vec2(-25,-25),vec2(25,-25),vec2(25,25),vec2(-25,25)},color(200,255,200))
player:setPosition(25,125)
player:setLinearSpeed(400,0)
stage:addObject(player)
for i = 0,100 do
local w = 30 + math.random() * 15
local p = Polygon({vec2(-w,-w),vec2(w,-w),vec2(w,w),vec2(-w,w)},
color(255 * math.random(), 255 * math.random(), 255 * math.random()),true)
p:initDynamicBody(i * 300,400 + math.random() * 50,30 * i)
p:setGravity(math.floor(math.random() * 2))
p:setAngularSpeed((math.random() - 0.5) * 100)
stage:addObject(p)
end
stage:setBackGround(Polygon({vec2(-1000,0),vec2(99999,0),vec2(99999,HEIGHT),vec2(-1000,HEIGHT)},
{color(241, 239, 238, 255),color(241, 239, 238, 255),color(197, 206, 101, 255),color(147, 113, 205, 255)}))
physics.gravity(0,-3000)
parameter.watch("1/DeltaTime")
end
function draw()
background(63, 63, 63, 255)
setCamera()
stage:draw()
end
function touched(touch)
stage:touched(touch)
touchControl:touched(touch)
end
function collide(contact)
stage:collide(contact)
end
function setCamera()
translate(-player.body.x + WIDTH / 2,0)
end
--# Stage
Stage = class()
function Stage:init()
self.objects = {}
self.backGround = nil
end
function Stage:draw()
if self.backGround then self.backGround:draw() end
for k,object in pairs(self.objects) do
object:draw()
end
end
function Stage:touched(touch)
for k,object in pairs(self.objects) do
object:touched(touch)
end
end
function Stage:collide(contact)
for k,object in pairs(self.objects) do
object:collide(contact)
end
end
function Stage:addObject(object)
table.insert(self.objects,object)
end
function Stage:setBackGround(bg)
self.backGround = bg
end