Cubic Run - an endless runner

the art really is great, honestly!

Great Fun watching the Video… Congrats on the good work done …

wow! this looks amazing! very impressive (especially as I’ve spent ages trying to develop code even to this level) - so well done you :slight_smile: I did (temporarily) give up with a game of this type and concentrated on my book/game app (which will be released in the next few weeks) - however I would LOVE to see your code (if thats ok?).

Thank you and hope to speak soon,

Chris

Really nice work! Looks well optimized and looks like your using line append if I’m not mistaken?

Keep it up :smiley:

Really nice work! Looks well optimized and looks like your using line append if I’m not mistaken?

Keep it up :smiley:

Lots of neat features in there, the one thing I’m interested in is the parallax. This is how I did it (I had a couple people help me out with it).

It scrolls some clouds, and it prevents repeats so the same cloud doesn’t show up on the next frame. I’m getting towards the last stages of my game, and this was more of a polish element. I thought it be nice to not see a repeating texture (because I pay close attention to that in games, I can’t help it).

What’s not shown is there a local variable called scrollSpeed, which has a value assigned to it. I have about 5 of these code sets that divide the scroll speed so that each layer going towards the back is slower and slower for a nice effect.

However, even after tightening it up I’m always interested in how others accomplished the same thing. 

In other words, I’d like to see your fancy pants code :slight_smile:

-Nick

–I copied and pasted this out of my project, hopefully I put everything in there. It’s pretty straight forward, just looks a bit oddball (at least I think so).

local midScrollingBG = display.newGroup() local currentXM = 0 local prevXM = 0 ----------------------------------------------------------------- ---------------------Middle BG Scrolling Group loop-------------- ----------------------------------------------------------------- local lastNum2 = 0 local mRandom2 = math.random --for loop to generate the far background pieces (aka nbg) pieces for mbg = 1, 16 do --make sure if you change 1, # - # being the number, you have to change --specifically here \> newX = midScrollingBG[#] -the# should match the for loop --Notice in this example it's 16, and in the updateMidScrollingBG() it's also 16. --this picks a random number between 1 and 8, and if the next number is same --as last, then skip it until it's different repeat rNumMBG = mRandom2(8) until rNumMBG ~= lastNum2 lastNum2 = rNumMBG local newMidBG = nil display.remove(newMidBG) newMidBG = display.newImageRect ("images/scrollingimages/cloud" .. rNumnbg .. "t.png", math.random (100,600), math.random(100,200)) newMidBG.size = 1360 ; print(rNumMBG) currentXM= currentXM + prevXM\*0.5 + newMidBG.size\*0.5 newMidBG.x = currentXM --(r \* 100) - 100 newMidBG.y = math.random (50, 460) midScrollingBG:insert(newMidBG) prevXM = newMidBG.size end local function updateMid( event ) updateMidScrollingBG() end function updateMidScrollingBG() for mbg = 1, midScrollingBG.numChildren do if(mbg \> 1) then newX = midScrollingBG[mbg-1].x + midScrollingBG[mbg-1].size\*0.5 + midScrollingBG[mbg].size\*0.5--widthref else newX = midScrollingBG[16].x + midScrollingBG[16].size\*0.5 + midScrollingBG[16].size\*0.5 - speed --widthref end if(midScrollingBG[mbg].x \< -1400) then --go with a larger piece to prevent pop in midScrollingBG[mbg].x, midScrollingBG[mbg].y = newX, midScrollingBG[mbg].y else midScrollingBG[mbg]:translate(scrollSpeed / 10000 \* -1, 0) end end end timer.performWithDelay(1, updateMid, -1)

Great work! From the video it looks like either you are very good at the game, or its a little easy :slight_smile:

Impressive :slight_smile:

Very impressed, being able to review the source code would be much appreciated.

I’m especially interested on how you achieved the ‘endless’ part of the game i.e. is it random or is there some logic behind it?

Thanks! No, I don’t use line:append()

I’ve sent you the link for the source. Have fun!

Thank you, Danny!
This version is easy, but there is another one, much harder. And yeah, I am good at it.

You can download android version here https://dl.dropboxusercontent.com/u/55969280/CubicRunLDMusic.apk
 

Lots of neat features in there, the one thing I’m interested in is the parallax. This is how I did it (I had a couple people help me out with it).

It scrolls some clouds, and it prevents repeats so the same cloud doesn’t show up on the next frame. I’m getting towards the last stages of my game, and this was more of a polish element. I thought it be nice to not see a repeating texture (because I pay close attention to that in games, I can’t help it).

What’s not shown is there a local variable called scrollSpeed, which has a value assigned to it. I have about 5 of these code sets that divide the scroll speed so that each layer going towards the back is slower and slower for a nice effect.

However, even after tightening it up I’m always interested in how others accomplished the same thing. 

In other words, I’d like to see your fancy pants code :slight_smile:

-Nick

–I copied and pasted this out of my project, hopefully I put everything in there. It’s pretty straight forward, just looks a bit oddball (at least I think so).

local midScrollingBG = display.newGroup() local currentXM = 0 local prevXM = 0 ----------------------------------------------------------------- ---------------------Middle BG Scrolling Group loop-------------- ----------------------------------------------------------------- local lastNum2 = 0 local mRandom2 = math.random --for loop to generate the far background pieces (aka nbg) pieces for mbg = 1, 16 do --make sure if you change 1, # - # being the number, you have to change --specifically here \> newX = midScrollingBG[#] -the# should match the for loop --Notice in this example it's 16, and in the updateMidScrollingBG() it's also 16. --this picks a random number between 1 and 8, and if the next number is same --as last, then skip it until it's different repeat rNumMBG = mRandom2(8) until rNumMBG ~= lastNum2 lastNum2 = rNumMBG local newMidBG = nil display.remove(newMidBG) newMidBG = display.newImageRect ("images/scrollingimages/cloud" .. rNumnbg .. "t.png", math.random (100,600), math.random(100,200)) newMidBG.size = 1360 ; print(rNumMBG) currentXM= currentXM + prevXM\*0.5 + newMidBG.size\*0.5 newMidBG.x = currentXM --(r \* 100) - 100 newMidBG.y = math.random (50, 460) midScrollingBG:insert(newMidBG) prevXM = newMidBG.size end local function updateMid( event ) updateMidScrollingBG() end function updateMidScrollingBG() for mbg = 1, midScrollingBG.numChildren do if(mbg \> 1) then newX = midScrollingBG[mbg-1].x + midScrollingBG[mbg-1].size\*0.5 + midScrollingBG[mbg].size\*0.5--widthref else newX = midScrollingBG[16].x + midScrollingBG[16].size\*0.5 + midScrollingBG[16].size\*0.5 - speed --widthref end if(midScrollingBG[mbg].x \< -1400) then --go with a larger piece to prevent pop in midScrollingBG[mbg].x, midScrollingBG[mbg].y = newX, midScrollingBG[mbg].y else midScrollingBG[mbg]:translate(scrollSpeed / 10000 \* -1, 0) end end end timer.performWithDelay(1, updateMid, -1)

Great work! From the video it looks like either you are very good at the game, or its a little easy :slight_smile:

Impressive :slight_smile:

Very impressed, being able to review the source code would be much appreciated.

I’m especially interested on how you achieved the ‘endless’ part of the game i.e. is it random or is there some logic behind it?

Thanks! No, I don’t use line:append()

I’ve sent you the link for the source. Have fun!

Thank you, Danny!
This version is easy, but there is another one, much harder. And yeah, I am good at it.

You can download android version here https://dl.dropboxusercontent.com/u/55969280/CubicRunLDMusic.apk
 

Really cool game and good graphic, would love to check out your source code. I’m thinking of making a endless runner game myself

Hello Lerg,

Very nice work here  :slight_smile:

Could you send me the source code, it would be much appreciated.

Thx a lot,

Fabian

Just an FYI to those looking to take a look at the source for Lerg’s Endless Runner, check out the show notes for CoronaGeek #79

http://coronalabs.com/blog/coronageek/corona-geek-hangout-79/

And, as a special treat, Sergey Lerg offered to share the source code for his Cubic Run LD27 endless runner game with anyone who rates and reviews his Three Puzzle – Hex LED game for Android. If that’s you, then contact Sergey and let him know after you rate and review his app.

Lets support the community members who share their knowledge with others.