Is there a fast way to fill array cells?

0 favourites
  • 15 posts
From the Asset Store
An educational game for Fill in the Blanks. An easy to use template for developers to build larger games
  • Whatsup everyone,

    I was wondering if there is a fast way to fill cells in an array grid.

    I have a room that is 6400x6400 and im using 32x32 pixel tiles i have my ground level at 3200x3200 in the layout.

    My question is how do i fill half of my layout with my ground tiles in such a way where i do not have to individually place what goes in each cell.

    I ask this because i know there has to be a trick to doing this or i will have to place 200 blocks.

    I understand how to place blocks through arrays i just want to know if there is a fast way to fill half of a layout

  • Use loops?

  • Loops are your friend, specifically For Each Element in the Array object. If you need an example give me a bit and I'll throw one together for you. If you don't know how loops work, check out this tutorial (shameless plug <img src="smileys/smiley2.gif" border="0" align="middle" /> )

    scirra.com/tutorials/40/basic-loops-and-arrays

  • sqiddster cow_trix

    Thank you both,I never knew that loops are made to help with this issue.But i still do not understand how to make it run through certain cells.Like if 1-320

    I guess im looking for the expressions used? or even better would be to see what you guys mean.

    Thanks for replying,I know that it sounds lame but i am learning from all of this.Thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well, have you looked into 'for each element'? Or are you only wanting to fill specific cells?

    Loops and arrays go together very well - you can't really use arrays to their full potential without knowing how they go with loops. Maybe look at some array tutorials?

  • sqiddster I am trying to create the starting foundation for my game,I just want to call for specific cells that in this case would be my Ground to be created only once.

    I have seen alot of the tutorials but it isnt helping me like the forums.

    I actually just got done looking at the link cow_trix provided.

    Like i was saying in my first post i only am trying to create my ground,I Know how to place Tiles in array cells Individually i understand that part.

    I just need to know how to place a bunch of tiles at once without having to call each cell one by one.

    You guys told me loops but i dont understand how to use them.Thanks for replying guys

  • cow_trix could you explain what you mean when you say i can use the 'For function you said this in you tutorial.

    A for loop can be considered a subcategory of a while loop. It is used when you know how many iterations you want, e.g.

    1

    For 0 to 9

    2

          Print "Hello!"

    This will print "Hello!" 10 times. It's important to remember Construct 2 (and a lot of programming languages) are zero-based as a rule (however, this can get confusing when we get to Arrays, but don't worry about that just yet).

    You Said to use this,But you never went into detail on how to use this ingame.If you or anyone else could fill me in it would be very helpful.I really need to use this method to fill half of my layout with tiles.

  • Check this out, see if it makes any more sense.

  • cow_trix its 404 for me.The link isnt working and thanks for replying man

  • blackhornet 's link will probably be fine as well. Mine is working too now, just had to give the server a second.

  • cow_trix i would like to see how you do this and you are still 404 man i tried your link like 10 times

    1

    For 0 to 9

    2

          Print "Hello!"

    This will print "Hello!" 10 times. It's important to remember Construct 2 (and a lot of programming languages) are zero-based as a rule (however, this can get confusing when we get to Arrays, but don't worry about that just yet).

    blackhornet i dont understand how you are creating tiles the way you are in that capX.You are using Global Variables in a way that i thought was not needed to do what im trying to do. I really am a noob and i feel overwhelmed looking at this.

    I just need my generation to start at half of my layout i dont need something overly complicated. I just need to know how to specify where to start and end my generation of ground tiles. lets say i have a 10x10 grid i want to start my ground generation at 5x5 which is half of my layout.

    I really am starting to feel like i will never get the hang of this,I have been stuck on this for a long time

    I really dont want to place tiles one by one in a layout that is 6400x6400 in size.But the more i look the more i start to feel like i will have to alter my project to fit my skill lvl which will depress me.I also want to thank each one of you guys for helping me try and understand this you are saints for that.good karma to all of you guys

  • Why don't you post what you have. I have to keep guessing at what you are looking for.

  • cow_trix Your link has been hit by the dreaded extra space in the default URL link gotcha.

    Array-Fill-Example.capx

  • blackhornet i will post it in your PM box because i have graphics that are not for public use and i dont want them being used in a foul manner.

    Thanks for your help

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