[SOLVED] Generating platforms randomly?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Eamonn
Party member
Posts: 550
Joined: Sat May 04, 2013 1:29 pm
Location: Ireland

[SOLVED] Generating platforms randomly?

Post by Eamonn »

So, this is probably what discouraged me from LÖVE the most: I can't figure out how to generate platforms in a random fashion.

It's been 3 weeks, and I've been thinking constantly about how to make a game doodle jump. I'd know how do make it so if he touches the platform, he jumps again: You'd just see if he's on the ground, and if he is then jump. But what I can't figure out is:

• Generate the platforms constantly out of the screen's view.
• Make it so the player can move up the platform, but can't fall back down.
• How to make it so the camera only follows the player going up.

I'd assume:

1) To make it so the player dies when he touches the end of the screen, Id' make it so the camera only moves up, but when he hits the bottom of the screen(if the player's Y is equal to 0 - the player's height).

2) Just move the camera up, just make it follow the player going up(which I don't know how to do).

I can't find any code examples in any programming language on how to do this. Same goes for endless runners. The only ones are for Scratch, GameMaker, Unity and GameSalad. I hate them. You should have to code a game, no easy tools, or shortcuts or anything like that, but that's another topic for another time(to get derailed another time too ;) ). But I will say this: I am not against the people who use them, I'm against the creators of them.

Maybe it's something really obvious and I just can't think of it, and I've been holding off asking here because of that. But I think after 3 weeks or so I've thought long enough and searched long enough.

I did ask a while ago about random maze generation. I haven't gotten any farther with that, so I can't use any knowledge from that to help me :| I know how to make them spawn randomly on the X axis, but the Y axis is confusing. For the X axis, you'd just do:

Code: Select all

platform.x = math.random(0, widthOfField)
But I don't know how to make it so multiple spawn at once on the Y axis, how they go up and don't spawn below, etc etc.

Thanks! Help is appreciated(as long as it's help and no insults)!
Last edited by Eamonn on Fri Jul 26, 2013 7:35 am, edited 1 time in total.
"In those quiet moments, you come into my mind" - Liam Reilly
User avatar
mickeyjm
Party member
Posts: 237
Joined: Thu Dec 29, 2011 11:41 am

Re: Generating platforms randomly?

Post by mickeyjm »

I can't go into detail now because its hard typing on my iPod but I would have a variable that keeps track of the highest Y coordinate reached and have the camera track that. His would also mean for generating the platforms you go a do something like
platform.y = math.random(MAXYREACHED-someHeight,MAXYREACHED+someHeight)
I would make some height equal to half the screen height and then have the camera track so that MAXYREACHED is in the centre, that way platforms generate across he while of the visible screen
Your screen is very zoomed in...
Shanulu
Prole
Posts: 21
Joined: Mon Jun 24, 2013 11:34 pm

Re: Generating platforms randomly?

Post by Shanulu »

I have a bit of code that randomly draws rectangles of random sizes in my pong game. You could replicate that with what Mickey has said above. Limit the generation of the platforms to anywhere between the bottom of the screen and exactly how high your player can jump. At least I think that'a what he was saying :)
User avatar
Eamonn
Party member
Posts: 550
Joined: Sat May 04, 2013 1:29 pm
Location: Ireland

Re: Generating platforms randomly?

Post by Eamonn »

Thanks everyone! I'll look into your pong game and maybe modify it a little. Thanks for telling me about it though! :D
"In those quiet moments, you come into my mind" - Liam Reilly
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest