Page 1 of 1

Is there a simple way to make random level generation

PostPosted: Sat Dec 04, 2010 9:13 pm
by zxcvbnm
I tried using timers and the like but cannot seem to make proper randomly generated levels. Games like canabalt and doodle jump have platforms appearing randomly to make every time you play a new challenge. Does anyone have a simple method to do this.

Re: Is there a simple way to make random level generation

PostPosted: Sat Dec 04, 2010 11:07 pm
by lcl
Here, kren. :D
I made it for you. :D

Use enter to create level.
You can go around level by moving the pacman with a, w and d, or
move around with view by arrow keys.

I hope that's what you needed. :wink:

Re: Is there a simple way to make random level generation

PostPosted: Sat Dec 04, 2010 11:41 pm
by zxcvbnm
Excellent work , But as far as code I only understand some of it. Can you give some basics on what you did ?

Re: Is there a simple way to make random level generation

PostPosted: Sun Dec 05, 2010 12:03 am
by lcl
Oh. Yeah. :D
The main function is in global code.
It has three things that you have to define when you use it.
First is how many platforms it will create, second one is maxim of how far can platforms
be from other one. The last one is maxim y distance between platforms.

The function checks if there is not as many platforms as defined when function is called
and creates new one if needed. The new platforms x and y values are randomized by previous
ones coordinates. That is what I needed random and getClone functions for.

It is pretty much the most important part.
Also, when platform is created it's coordinates are rounded for making it look better.
In create actor event there is also much other code, that code checks the position of
new platform and compares it to previous one. If the platforms are at same coordinates
or in somehow otherwise stupid positions, the code moves them. :D

That's it pretty much. Did that help you? :D

Re: Is there a simple way to make random level generation

PostPosted: Sun Dec 05, 2010 12:39 am
by zxcvbnm
Ok so the createlevel command is a function right? I never saw that command thats what threw me off. If I want more spacing between platform , where do I change that at?
Also why does the platform move up on its own to collide with you?

Re: Is there a simple way to make random level generation

PostPosted: Sun Dec 05, 2010 12:45 am
by lcl
Actually, createlevel is function that I wrote into global code. It is not built in ge command.

Anyway, for getting more space between platforms check the platform key down event
and change the second value in function for x distance and third for y distance. :D

Re: Is there a simple way to make random level generation

PostPosted: Sun Dec 05, 2010 1:08 am
by needaname
the ground doesn't move up, the player and view move down

Re: Is there a simple way to make random level generation

PostPosted: Sun Dec 05, 2010 11:45 pm
by lcl
needaname wrote:the ground doesn't move up, the player and view move down

What was that supposed to mean?? :lol:

Re: Is there a simple way to make random level generation

PostPosted: Mon Dec 06, 2010 7:30 am
by needaname
zxcvbnm wrote:Also why does the platform move up on its own to collide with you?

was answering this question, i was saying gravity is moving the player/view down. so, the platform doesn't move up.

Re: Is there a simple way to make random level generation

PostPosted: Mon Dec 06, 2010 8:48 am
by lcl
needaname wrote:
zxcvbnm wrote:Also why does the platform move up on its own to collide with you?

was answering this question, i was saying gravity is moving the player/view down. so, the platform doesn't move up.

Oh yeah, thanks, I didn't notice that question. :D