Creating landscape from array

This forum is currently in read-only mode.
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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.

    I don't fully understand that. I can toggle on a visual grid to help manual placement, but that's not what you meant, right?

    And how (and why) should I want to put all tiles into one sprite? Im utterly confused

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

    'm out, maybe we talk about different things? At the moment the x/y positions of tile placement are defined as: (LayoutWidth / 2) + (Array.CurrentX * Global('tile_offset_x')), (20 + (Array.CurrentX * Global('tile_offset_y')) whereas the half-tileset-variable is used to offset the tiles, and is after every complete vertical row reduced by a full tilesize (50, 26). So I should start with a row as long as the arrays Y-value and continue to the left with new rows Array-x-length times...

    My problem at the moment is, that the condition at which it should jump into the new row (by changing the offset) to place it, is too true. My current event sheet in shortform:

    Fill Array with random numbers,
    go into for each loop {
      if Array.CurrentX, Array.CurrentY is 1 - place Desert sprite at (see formulae above) and add 1 to variable x_counter.
      if above condition is true and the variable x_counter is greater or equal than the Arrays X size - substract 50 from tile_offset_x and substract 26 from tile_offset_y
    
     the same thing above again with the only difference that, if Array.CurrentX, Array.CurrentY is 2, a grass tile will be placed.
    [/code:1bngpcsa]
    
    I'm aware that at the moment, it would only produce two correct aligned rows... and probably all other rows over the second one after that. But even this don't work. Because every loop he substracts again from tile_offset_y and x which leads to abysmal values like -4029 and greater. I need this substraction only once, for now.
    
    
    

    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.

    Yep, I did that after finding out I need to offset each next tile by half the tilesize, and 23 really isn't that great for dividing. So the new tilesize is 50x26px which divides nicely into 25x16 offsets.

    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)

    You're not telling me my effort was pointless because I could used an built in behaviour which does everything I am trying to do manually, are you? I can't even seem to find that RTS-behaviour-thingy in Constructor...

    Beautiful concept pixel art btw. Really, kudos.

    Thanks, wait till you see the real deal ingame, and in (modest) motion.

  • Epic. Using frames with zero animation speed is a clever thing. But I think this doesn't really helps me with the placing of my tiles. Besides the problem would then be, to change the animation frame of every tile according to numbers in an array.

  • Yes the idea is to have all the tiles already created, so all you would need to do is change the frame using your array IE:

    if data at x, y is greater than one set frame of sprite at x,y to frame 2.

  • Okay, that's my current problem:

    I want to draw him a column of tiles. I do this via:

    FOR EACH entry in array "Array" {
     IF:
     value at Array.CurrentX, Array.CurrentY 
        THEN:
        create object "GenericTile" at (LayoutWidth / 2) + (Array.CurrentX * Global('tileoffset_x')), 20 + (Array.CurrentX * Global('tileoffset_y'))
        add 1 to global variable 'x_counter'
    [/code:2hl03ttl]
    
    Fine. He should have drawn a number of tiles now ... but if he doesnt stop, he will draw the next few rows also at the same position. So at the end, no matter how many columns I wanted, I will have only one column with all other columns stacked over it. So I want him to stop after the first column is done, correct the offset and continue.
    
    [code:2hl03ttl]
      IF:
      'x_counter' equal to 'number_of_columns' 
        THEN:
        substract 'substractor_x' from 'tileoffset_x
        substract 'substractor_y' from 'tileoffset_y
        add 1 to global variable 'number_of_columns'
    }
    [/code:2hl03ttl]
    
    So the next column will be set off by the value of the substractor (usually the width of the tile). I continue this behaviour as often as needed till all columns are done. Is this wrong? It has to be, because it doesn't work.
    
    Suggestions please?
    BTW: Today is a rainy grey day. -.-
  • Basically you need a simple switch here. If you go with a counter an easy way to do it is use even or odd, and two corresponding sub-events.

    To start out your counter should be zero... an even number.

    So before you create your first row/ column you need an event that checks the counter.

    if global variable 'x_counter' %(modulo) 2=0
    -create sprite at array x,y+tilewidth
    -add 1 to tilecount
    
    if global variable 'x_counter' %(modulo) 2>0
    -create sprite at array x,y+tilewidth+ offset
    -add 1 to tilecount
    
    if tilecount > x(the known number of tiles across)
    - set tilecount to 0
    - add 1 to global variable 'x_counter'[/code:30tj4v0k]
    
    Course you'll probably have to add an extra event for the difference in columns, and rows offset.
  • I have to admit that I didn't quite follow the ongoing discussion between you guys and chances are I might have missed something important (looking at all that pseudo code).

    But if you only want to create a flat iso terrain from an array it could be simply done like this:

    http://dl.dropbox.com/u/2306601/simpleisotest.cap

    Or am I missing the point?!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah, that's pretty good, but I'm not sure you can set up what he was wanting to do with the different tiles with that.

    However you could still use the array to change the frames.

    Also that brings up a bit about optimization. Depending on how big the layout is, and if you want the whole thing covered in tiles... you can actually wind up with a lot of tiles.

    Too many tiles can be a big hit on performance, so one thing you could do is use a Canvas, and paste all the tiles that don't have to be used for collision detection into the canvas, and then destroy those sprites.

    You could also just use the Tiled Background object as a base, and use the array to create the tiles you want different,if you want the whole screen filled that is.

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