[2D Sidescroll] Generating terrain based on random templates

Get help using Construct 2

Post » Thu Nov 26, 2015 8:00 pm

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" ( https://www.youtube.com/watch?v=iIvbTMQ9uRE )). 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 :mrgreen:
B
24
S
14
G
9
Posts: 118
Reputation: 6,799

Post » Fri Nov 27, 2015 6:53 pm

Im Feeling free to *push*

No one gots an idea? Or is it that simple that Im too dumb for it? :shock:
B
24
S
14
G
9
Posts: 118
Reputation: 6,799

Post » Fri Nov 27, 2015 11:48 pm

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
B
18
S
2
Posts: 48
Reputation: 896

Post » Sat Nov 28, 2015 12:02 am

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
B
18
S
2
Posts: 48
Reputation: 896

Post » Sat Nov 28, 2015 1:25 am

ryrydawg wrote: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 :mrgreen:
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 :D - 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... :D) 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 :shock:
[Off-Topic = 0]

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


Have a great day,
Tan 'Proxy' E.
B
24
S
14
G
9
Posts: 118
Reputation: 6,799

Post » Sat Nov 28, 2015 2:49 am

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,
B
18
S
2
Posts: 48
Reputation: 896

Post » Sat Nov 28, 2015 3:14 am

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


Have a great weekend,
Tan
B
24
S
14
G
9
Posts: 118
Reputation: 6,799

Post » Sat Nov 28, 2015 4:42 am

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.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Sat Nov 28, 2015 7:23 am

@roj0j0hound

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
B
18
S
2
Posts: 48
Reputation: 896

Post » Sat Nov 28, 2015 7:41 am

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.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Next

Return to How do I....?

Who is online

Users browsing this forum: jorgmaquoi, Lancifer, R0J0hound and 19 guests