Creating landscape from array

This forum is currently in read-only mode.
0 favourites
From the Asset Store
Awardkit
$5 USD
Create custom awards and achievement or use the many templates and create your own.
  • 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) :

    <img src="http://www.strongground.de/bunker/images/diorama.png">

    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:

    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: <img src="http://www.strongground.de/bunker/images/tile_desert.png"><img src="http://www.strongground.de/bunker/images/tile_grass.png">
    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,
    No�l
  • 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) :

    <img src="http://www.strongground.de/bunker/images/diorama.png">

    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:

    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: <img src="http://www.strongground.de/bunker/images/tile_desert.png"><img src="http://www.strongground.de/bunker/images/tile_grass.png">
    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,
    No?l
    

    Hey this looks good, the one guy you should ask is Vdrake he seems to know this RTS stuff well

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks! I will ask him to have a look at this thread right now.

  • 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.

  • If your really interested in random generated terrain, then I'd suggest you take a look at the Perlin Noise plug.

    http://www.scirra.com/forum/viewtopic.php?f=2&t=4836&hilit=Perlin+Noise+plugin+Arsonide

    Not sure if the RTS behavior would work for an isometric grid movement tho.

  • 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:

  • 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.

    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 ), 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?

    I'd suggest you take a look at the Perlin Noise plug.

    Thanks! I certainly will take a look ...

    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.

    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...

  • 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?

    Yes, sorry it was made in 0.99.95 it says it is an unstable build but IMO it is the most stable version of construct to date.

    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...

    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!

  • You sir, are being very helpful!

    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.

  • 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.

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

    To the left in the properties bar the X, Y and Z dimensions of the array can be entered.

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

    Indeed. It loops through all the elements of the array.

    What is "Array.CurrentX" exactly?

    When you're looping through the elements of the array, Array.CurrentX describes the current X position.

    And if you haven't done so already, you can always take a look at the wiki: http://sourceforge.net/apps/mediawiki/construct/index.php?title=Array

    Oh, and since you're asking about Perlin Noise and arrays to create a random landscape you might learn one or two things by looking at the source of my older Perlinscape thingie: http://www.scirra.com/forum/viewtopic.php?f=4&t=5084

  • Okay, so far a few new questions have arisen.

    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?

    Yes

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

    PixelRebirth already answered this one, but i thought i would mention you can set the size of the array at runtime also, using the Set size action for the array object, just make sure the Z dimension is at least 1 or else it will break.

  • Thanks to you two, I now understand another concept: referencing others objects values as variables in objects. I'm now near solving the problem that my map would need to be looking diamond-shaped while the map from your example, Citnarf, was a angular. box shape. You get it.

    I'll probably upload a first version of the generator with some eye-candy tomorrow, so you can see all your effort in helping didn't went down the drain.

  • [quote:3jo1kln0]I'm now near solving the problem that my map would need to be looking diamond-shaped while the map from your example, Citnarf, was a angular. box shape. You get it

    That's a whole other box of worms since every other row/column is offset by a tile size.

    If it makes things easier you can make a grid manually in the editor, and then load all your images into one sprite, then simply change the frames at runtime.

    Thing is your still going to have to figure a way to get the offset, as well as pick that particular instance.

    One thing I'll suggest is pick your tile sizes now, and make sure they work for both height and width... and divisible into the map. 48 x 23 doesn't work too well.

  • I just tried iso sprites with rts behavior with no issue (except sorting, of course, but that's better solved with the filmation algorithm... it gets easier if everything is ground-based)

    Beautiful concept pixel art btw. Really, kudos.

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