Doodle Jump App

Can anyone please help me out i`m trying to make a doodle jump “style”
application but im wondering what is the best approach to create a background
that is basically endless as you get higher. I cant image creating a huge tall background
and code in objects (like the platform you jump on in Doodle Jump) in different x and y
along the way. If anyone can help me accomplish this or point me in the right direction
perhaps they done something similar or know of a tutorial or ANYTHING that can land
a hand I would be very grateful.

To make my question more simple incase something does not understand what
im trying to do I basically want to know what would be the best or most proper way
to create a doodle jump type of game that every time you jump on a platform you
keep going higher and higher and is basically endless. I created an application around
march this year I havent worked on another since then so im trying to get back into
programming in corona sdk, I never used tables in my application im assuming this type
of app would require to use tables?

Any help is greatly appreciated thank you very much! [import]uid: 30314 topic_id: 15283 reply_id: 315283[/import]

Hey Man,
I don’t know much of Corona yet, but I used to use this type of logic in GameSalad, & it’s about the same. Your key to an endless game is either continually spawning (http://blog.anscamobile.com/2011/09/how-to-spawn-objects-—-the-right-way/) or you can do something that GameSalad calls recycling, which is supposedly better for memory. Clearly you wouldn’t use the GS code for this, but it will give you a good idea on the logic. http://www.youtube.com/watch?v=W7ZN_1sY63M

Hope this helps :slight_smile:

Matt [import]uid: 50842 topic_id: 15283 reply_id: 56422[/import]

@matthew

Thanks for response im still trying to implement it to my game but no luck
if anyone has any sample code or can help me out with this or just send me
the right direction ill appreciate it. I just want to know how to create an endless
game like Doodle Jump were the background keeps scrolling as you climb up
and new objects keep appearing in random places im assuming this is all looping?
with math.random? any help is greatly appreciated [import]uid: 30314 topic_id: 15283 reply_id: 56600[/import]

I could be wrong (I haven’t played DJ in awhile) but if I remember correctly it’s not the background that moves when you jump but rather the platforms meaning that all you have to do is spawn the background once and make the platforms move, thus giving it the illusion of movement.

If your crafty enough you could probably get away with only spawning the platforms once and make them move or invisible each time you jump on one reducing the tax on the system resources.

Anyway here is some rough code I came up with that should help you get started in creating and moving platforms randomly.

[blockcode]

local physics = require “physics”
physics.start(true)
physics.setGravity(0, 10)

local background = display.newImageRect(“background.png”, 320, 480)
background.x = 160
background.y = 240

local guy = display.newImageRect(“mycharacter.png”, 82,33)
physics.addBody(guy, “dynamic”,{density = 30, bounce = .7})
guy.x = 100
guy.myName = “guyt”

local spawntable = {“object.png”, “object.png”, “object.png”, “object.png”, “object.png”, }
for i = 1, #spawntable do
spawntable[i] = display.newImageRect(spawntable[i], 64,23)
spawntable[i].x = (math.random(1,200) + (math.random(1,200)))
spawntable[i].y = (math.random(1,200) + (math.random(1,200)))
physics.addBody(spawntable[i], “kinematic”,{density = 30, bounce = .7})
local spawnnameone = “spawn”…i
local spawnname = (string.format("%q", spawnnameone ))
spawntable[i].myName = spawnname
end

local function moveObjects()
for k = 1, #spawntable do
spawntable[k].x = (math.random(1,200) + (math.random(1,200)))
spawntable[k].y = (math.random(1,200) + (math.random(1,200)))
end
end

local function collision( event )
for i = 1,#spawntable do
local spawnnameone = “spawn”…i
local spawnname = (string.format("%q", spawnnameone ))
if ( event.phase == “began” ) and (event.object1.myName == “guyt”) and (event.object2.myName == spawnname) then
timer.performWithDelay(15,moveObjects)
end
end

end

Runtime:addEventListener( “collision”, collision )

[/blockcode]

[import]uid: 23649 topic_id: 15283 reply_id: 56610[/import]