[phpBB Debug] PHP Warning: in file [ROOT]/viewtopic.php on line 1582: number_format() expects parameter 1 to be double, string given
Creating landscape from array - Scirra Forums

Creating landscape from array

For questions about using Classic.

Post » Wed Sep 22, 2010 9:20 am

Hi!

I am planning to do a little sandbox to play around with pattern creation, random landscape generation and so on, kind of an RTS-type sandbox-game (maybe it will evolve into a full game over time).

For that reason I want to create a tiled landscape (isometric angle of view). Something that looks not exactly but alot like this in the end (I made it to visualize the style) :


My idea is to use an array, where the data for the level is stored (and later randomly generated before being stored into the array). My first step would be the generation of a terrain with an array like this: [code:1z5h00kl]int terrain[4][4]={{1, 2, 1, 1},
{2, 2, 2, 1},
{1, 2, 1, 1},
{1, 1, 2, 1}};[/code:1z5h00kl]
In this small example, it would be a tiny map with 4x4 tiles, of which tiles with identifier 1 are desert-tiles, and 2 are grass-tiles. Like these:
Then, according to the array, different sprites would be placed, another problem because I don't exactly know how to dynamically place sprites yet. I managed to "create" an object instance at an exact location derivated from a sprite object when clicking on a button. Which is, in a way, pathetic. I would like to use a variable instead of fixed per-pixel locations, which then will be counted up after each tile-placement. That will do for a row. How to manage multiple rows this way, I'm not so sure. Another variable counting up after every x-dimension placements?

[code:1z5h00kl]
(Assuming the dimensions of the array are w=4 and h=4)
int max_x = w
int max_y = h
int i1
int i2

for (i1 < max_y;) {
for(i2 < max_x;) {
// Here the tiles would be placed
}
}
[/code:1z5h00kl]

Something along this lines... But how to do it in Construct?

So much for my first few questions (although sometimes not directly asked). You think you can help me getting this to work? : )

Best regards,
Nol
B
3
G
2
Posts: 35
Reputation: 770

Post » Wed Sep 22, 2010 9:35 am

[quote="Dunkelseele":2ne1qc45]Hi!

I am planning to do a little sandbox to play around with pattern creation, random landscape generation and so on, kind of an RTS-type sandbox-game (maybe it will evolve into a full game over time).

For that reason I want to create a tiled landscape (isometric angle of view). Something that looks not exactly but alot like this in the end (I made it to visualize the style) :


My idea is to use an array, where the data for the level is stored (and later randomly generated before being stored into the array). My first step would be the generation of a terrain with an array like this: [code:2ne1qc45]int Matrix[4][4]={{1, 2, 1, 1},
{2, 2, 2, 1},
{1, 2, 1, 1},
{1, 1, 2, 1}};[/code:2ne1qc45]
In this small example, it would be a tiny map with 4x4 tiles, of which tiles with identifier 1 are desert-tiles, and 2 are grass-tiles. Like these:
Then, according to the array, different sprites would be placed, another problem because I don't exactly know how to dynamically place sprites yet.

So much for my first few questions (although not directly asked). You think you can help me getting this to work? : )

Best regards,
Nol[/quote:2ne1qc45]
Hey this looks good, the one guy you should ask is Vdrake he seems to know this RTS stuff well :wink: If you need any assistance with your GUI tech i will help you for free :wink:
B
2
S
1
Reputation: 400

Post » Wed Sep 22, 2010 9:49 am

Thanks! I will ask him to have a look at this thread right now.
B
3
G
2
Posts: 35
Reputation: 770

Post » Wed Sep 22, 2010 9:52 am

While i can't really help you with the random generation, i can help with placing sprites according to values in an array.

http://dl.dropbox.com/u/6660860/array.cap

I didn't comment it, if you need any help met me know.

EDIT: Just realized you seem to be doing this in python, my .cap is evented.
B
7
S
2
G
4
Posts: 164
Reputation: 2,418

Post » Wed Sep 22, 2010 10:09 am

If your really interested in random generated terrain, then I'd suggest you take a look at the Perlin Noise plug.
[url:2a19fei9]http://www.scirra.com/forum/viewtopic.php?f=2&t=4836&hilit=Perlin+Noise+plugin+Arsonide[/url:2a19fei9]

Not sure if the RTS behavior would work for an isometric grid movement tho.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Wed Sep 22, 2010 10:13 am

Wow! How have i never seen that plugin before? Thanks for pointing that out Newt.

Also, yeah isometric and the RTS behavior won't mix well at all i don't imagine, not to mention how hard isometric can be to work with.

R0J0hound has made a perfect isometric sorting example here: viewtopic.php?f=4&t=7180
B
7
S
2
G
4
Posts: 164
Reputation: 2,418

Post » Wed Sep 22, 2010 10:51 am

[quote="Citnarf":21gm6sx8]While i can't really help you with the random generation, i can help with placing sprites according to values in an array.

http://dl.dropbox.com/u/6660860/array.cap

I didn't comment it, if you need any help met me know.

EDIT: Just realized you seem to be doing this in python, my .cap is evented.[/quote:21gm6sx8]

Thanks for your example... that will certainly help me! And I'm not yet sure if I will do this in Python (as that would include learning it first :D), but I thought my explanations would be much more readable if written in plain C, as that is something most people can read and understand.
EDIT: I can't open it. It says it was created with a newer version. Check updates reports my version as the newest one. I'm confused. You using a Nightly or Beta-build?

[quote="newt":21gm6sx8]I'd suggest you take a look at the Perlin Noise plug.[/quote:21gm6sx8]
Thanks! I certainly will take a look ...

[quote="Citnarf":21gm6sx8]Also, yeah isometric and the RTS behavior won't mix well at all i don't imagine, not to mention how hard isometric can be to work with.[/quote:21gm6sx8]
Well, most 2D RTS games use isometric perspectives, or am I horribly mistaken?
Age of Empires I+II, Sudden Strike I+II, each and every clone of those... and was C&C not isometric too? Of course I neither can or want going anywhere even near the greatness of those games...
B
3
G
2
Posts: 35
Reputation: 770

Post » Wed Sep 22, 2010 11:03 am

[quote="Dunkelseele":3822mwbr]
EDIT: I can't open it. It says it was created with a newer version. Check updates reports my version as the newest one. I'm confused. You using a Nightly or Beta-build?
[/quote:3822mwbr]
Yes, sorry it was made in 0.99.95 viewtopic.php?f=2&t=7318 it says it is an unstable build but IMO it is the most stable version of construct to date.


[quote="Dunkelseele":3822mwbr]
Well, most 2D RTS games use isometric perspectives, or am I horribly mistaken?
Age of Empires I+II, Sudden Strike I+II, each and every clone of those... and was C&C not isometric too? Of course I neither can or want going anywhere even near the greatness of those games...[/quote:3822mwbr]

Yes you are right, those games are isometric but what i meant was, the built in RTS behavior that construct uses probably won't work well with an isometric view because it splits the layout into square grids for its pathfinding (i think, someone will need to confirm this). I could be totally wrong though, i have never played around with isometric stuff before!
B
7
S
2
G
4
Posts: 164
Reputation: 2,418

Post » Wed Sep 22, 2010 11:20 am

You sir, are being very helpful! :mrgreen:
Your example is perfectly what I wanted to do. I hope by studying your event structure I can learn a thing or two. Thanks alot!

Next thing would be the random creation of the array data, or maybe a second pass of drawing to place buildings, landmarks, vegetation and so on. Im very excited!

I'll keep you posted about my progress.
B
3
G
2
Posts: 35
Reputation: 770

Post » Wed Sep 22, 2010 11:56 am

Okay, so far a few new questions have arisen.

What does the "For each element" condition do exactly? I guess it is a loop?

As far as I understand: You are filling the array with random data (I didn't noticed at first) from the range between 1 and 2. What does the "+1" after the "Random(2)" do? Does "Random()" start indexing at 0? So you add 1 afterwards to prevent a 0 showing up in the array?

What is "Array.CurrentX" exactly? I mean, it refers to the X-row of the two-dimensional array named "Array", I can see that. But what does it include, if it is a variable? As far as I understand it is a counter...?

Another miracle: Where exactly do you say how big the array should be?

So many questions. I hope some will be answered. :wink:
B
3
G
2
Posts: 35
Reputation: 770

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests