[2D Sidescroll] Generating terrain based on random templates

0 favourites
  • 14 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • Hello Reader!

    Somehow I cant figure out a rather "simple" Task.

    What I Need/want to do is: you got a start Position. The game operates at only 1 "layer" (means: no hills or something. The character stands on an even platform across the whole map). The start/spawn is always "the same". On triggering "new game" the world is created, before entering it.

    Now the question: how is it done best (tilemaps possible??) to create a world based on random numbers - e.g. number 1 is a plain, 400px in width, nr. 2 a forrest, 600px, nr. 3 a Meadow with a Little tree in the middle, 200px in width, nr. 4 a Bridge, 800px, nr. 5 a rocky area, 500px, etc.

    Now the "world Generator" grabs on "new game" (for example): start,3,3,5,1,3,2,4,etc. (lets say, there is a Maximum Count... lets make it 10 different Areas, then there is a huge mountain or a very big forrest, where you cannot pass.

    Best described by the (great, but sadly not rich in Features/Elements "Kingdom" (

    Subscribe to Construct videos now

    )). When I say "Kingdom", Im not wanting to clone it, but the gameplay itself (or the "backende") will be similar to it (watching the Trailer above describes best, what I want to do :s).

    How is this doable the best way? Cant figure out how this should work with tilemaps (unless you cant randomize them in a way, or am I wrong)?

    Thanks in Advantage!

    Have a great day,

    Tan 'Proxy' E.

    P.S.: sorry for my spelling - german Edge Browser Features a nice spellchecker, that is somehow racist - it only knows german and wont let you choose other languages nor let you write them without Messing it up... thanks Microsoft <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

  • Im Feeling free to *push*

    No one gots an idea? Or is it that simple that Im too dumb for it?

  • I was sitting the other day trying to do this too. What i eventually had was a sprite the width of the layout and the height of the "ground"

    Create a variable for each setting eg. 1= desert animation 2=forest animation 3= grassland

    Each time the player the goes off screen, let the system choose a random number in the variable and change the animation of the sprite.

    The capx is on my laptop, i'll upload it later for you to see.

    Cheers

  • Here is the capx,

    Just have it spawn things every time the player get's sent back to the left of the layer

    https://onedrive.live.com/redir?resid=E ... ile%2ccapx

  • Here is the capx,

    Just have it spawn things every time the player get's sent back to the left of the layer

    https://onedrive.live.com/redir?resid=E ... ile%2ccapx

    Hi ryrydawg!

    Thanks for your answer and the *.capx! Already thougth, no one would answer <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    Yes, the idea of it is what I wanted to do - but sadly I cant use it for the Project. Problem is, that you have this "fixed Screen" - I would like to include a dynamic camera, showing the area infront of you (when you turn the direction, camera is moved). In the end, the world Generator should build to right and left side. The Code for Building even one side is tricky (cant figure out a solution which doesnt Impacts the System too hard (if there is one!). I want to publish it as a universal app for Win10 (so it will mostly be on mobiles, for me to Play <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy"> - and others). I dont care ressource-managing for Computers, but maybe on 512mb devices it may get laggy, when you have 50 areasprites to the right and 50 on the left... plus sprites for characters (npcs), particles for atmospheric effects, enemies and projectiles, etc...

    [Off-Topic = 1]

    I never build something in C2, I like making math-systems like a skilltree with many different stats which Impacts on others in combination (Dark Souls- Series, the best "modern" game ever... <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">) and combat calculations, etc... Ive made tons of "tech-demos" from different Elements of the game (crappy graphics, Im not an Artist nor do I have the skill to just make it "quick and dirty" - but now, when I finally enhanced every element to a state where I am ok with it, I stand before such Problem, and Im not able to solve it <img src="{SMILIES_PATH}/icon_eek.gif" alt=":shock:" title="Shocked">

    [Off-Topic = 0]

    If everyone has an idea approach, I would be very thankful...!

    Have a great day,

    Tan 'Proxy' E.

  • Yea I get what you saying! What you could also do is look at the auto runner template and see the logic that was used there. Try incorporate it into what you wanting it to do.

    Cheers,

  • Ill throw a look on it.. thats a possible starting point, thanks again!

    Have a great weekend,

    Tan

  • If you design the starting plain in the editor then it's just a matter of creating other terrain where the plain ends.

    Let's consider creating the terrain to the right. You'll need two global variables for the X and y of the end of the terrain. You can set these values manually. Next you'll need a global variable to keep track of a random number. Your events could then look like this if each terrain piece was an object. Note the "---" means the event is a sub event.

    Global number X=400

    Global number y=409

    Global number terrain=0

    Start of layout

    Repeat 10 times

    set terrain to int(random(3))

    --- terrain = 0

    --- > create forest at (X,y)

    --- > add 200 to X

    --- terrain = 1

    --- > create hills at (X,y)

    --- > add 300 to X

    --- terrain = 2

    --- > create grass at (X,y)

    --- > add 400 to X

    Start of layout

    create right_cliff at (X,y)

    This is also assuming the values added to X are the width of the objects and the hotspot of the objects are positioned to the left.

    Anything more deluxe can be done in a similar fashion. For instance the terrain could consist of multiple created objects or you could even set tiles on a tilemap is you so desire, just be sure the tilemap is wide enough.

  • I think the main issue here would be the layout size wouldn't it?

    Lets assume you were to create a floor that would spawn to the right each time you reached a certain point, the layout width would be massive...

    I don't have enough experience with construct to know if it's possible to extend layout width with code.. is it?

    The reason I mentioned the autorunner template is because you could keep a standard layout size and just pass the stuff off the layout. then bring it back again using the bullet direction.

    This is going to bug me if not done hahah

    Cheers

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • There is a system action to set the layout size, but it's probably easier to just set the layout to unbounded and not worry about the layout's size.

  • There is a system action to set the layout size, but it's probably easier to just set the layout to unbounded and not worry about the layout's size.

  • If you design the starting plain in the editor then it's just a matter of creating other terrain where the plain ends.

    Let's consider creating the terrain to the right. You'll need two global variables for the X and y of the end of the terrain. You can set these values manually. Next you'll need a global variable to keep track of a random number. Your events could then look like this if each terrain piece was an object. Note the "---" means the event is a sub event.

    Global number X=400

    Global number y=409

    Global number terrain=0

    Start of layout

    Repeat 10 times

    > set terrain to int(random(3))

    --- terrain = 0

    --- > create forest at (X,y)

    --- > add 200 to X

    --- terrain = 1

    --- > create hills at (X,y)

    --- > add 300 to X

    --- terrain = 2

    --- > create grass at (X,y)

    --- > add 400 to X

    Start of layout

    > create right_cliff at (X,y)

    This is also assuming the values added to X are the width of the objects and the hotspot of the objects are positioned to the left.

    Anything more deluxe can be done in a similar fashion. For instance the terrain could consist of multiple created objects or you could even set tiles on a tilemap is you so desire, just be sure the tilemap is wide enough.

    Hi R0J0hound,

    thanks for this, great and slim, solution! This is pretty much exactly what I needed! Tryed it out with a Little example - later today I gonna test it out and will upload the *.capx. maybe others will find this helpful, too!

    Thanks, again!

    Have a great Weekend,

    Tan

  • Hi again,

    I modified it a bit:

    [quote:1otlqm8p]http://www.proxy.wtf/construct2/capxs/Sidescrolling.capx

    (Camera movement provided by:

    Subscribe to Construct videos now

    )

    R0J0hound, would you even recommend using tilemaps in such a Project? In the end the ground isnt animated, but it should be a detailed graphic? Is there a difference in Performance, when it Comes to "big tilemaps" (detailed groundtextures) instead of just putting in sprites? The borders are limited, not endless, but I havent got enough experience to decide, if it is even noticable in that case. Even through, working with sprites could be a bit more Handy.

    The empty spaces in the left-generation-part are fixable with a bit of math - havent done that yet.

    Have a great Weekend,

    Tan

    (once again: sorry for the spellchecking and autocorrecting from my browser, it doesnt wants me to write in other languages except the OS one)

  • Hi again,

    I modified it a bit:

    [quote:375o95ww]http://www.proxy.wtf/construct2/capxs/Sidescrolling.capx

    (Camera movement provided by:

    Subscribe to Construct videos now

    )

    R0J0hound, would you even recommend using tilemaps in such a Project? In the end the ground isnt animated, but it should be a detailed graphic? Is there a difference in Performance, when it Comes to "big tilemaps" (detailed groundtextures) instead of just putting in sprites? The borders are limited, not endless, but I havent got enough experience to decide, if it is even noticable in that case. Even through, working with sprites could be a bit more Handy.

    The empty spaces in the left-generation-part are fixable with a bit of math - havent done that yet.

    Have a great Weekend,

    Tan

    (once again: sorry for the spellchecking and autocorrecting from my browser, it doesnt wants me to write in other languages except the OS one)

    Hey man, I saw what you did there and have been trying to come up with a way that will continually create terrain without the repeat loop since I assume you would want it to keep generating regardless of how long the player is running left or right?

    This is probably the most simplistic way I could come up with, if you wanna have a look.

    You could make the blocks invisible and change the size of the floor so that it is building outside the window,

    Anyway here it is

    https://onedrive.live.com/redir?resid=E ... ile%2ccapx

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)