May I Get Some Array Help?

0 favourites
  • 12 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I have just figured out how to use arrays in one of scirras tutorials,It has taken me awhile to grasp ahold of this since i have been learning independently.

    R0J0hound or anyone who knows of this,I wanted to know if you could show me in my capX file how i can make my tile Generation start wherever i want it to start.

    As of now from learning in the tutorial i read,I only know how to make my tile Generation start from the Top Left corner all the way down to the floor.

    I cant have my player on the world if its full of dirt.I hope i make sense and if you can show me,please show me in a simple form since i am still in my learning curve.

    Thank you Guys The CapX

  • Well, if for instance you only wanted dirt after the 5th row, then add a system compare condition to the bottom of event 2:

    Tile_Array.CurY > 5

  • This didnt work for me R0J0hound i did exactly as you said to do.

    im missing something.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I see where i meesed up by looking at your capX file TELLES0808

    But if i were to do this in this way wouldnt it load the world in this same fashion every single time i loaded the game?

    Lets say i wanted to Dig up a bunch of grass tiles and then quit the game.As soon as i come back the world will load up and look exactly the same each time.

    Im not looking for random generation but i would like to know how do i make the tile generation persist when i start the layout each time instead of generating over and over each time.

    i know about the behaviour persist but that wont work with the array generation im guessing.

  • Me learning in this step by step fashion is actually working for me!!! Thank you guys!! i really havnt felt this good about arrays up until this point. You guys are showing me in a way that i didnt see before.

  • You can setup the array and load it whenever you want, it will still the same, so, make a global variable like CREATION_WORLD, check if this variable is setup to 0 before creating the world by the first time, then, setup it to 1, and the code will never run again.

    GLOBAL VAR -> CREATION_WORLD = 0;

    EVENTS:

    = Run once while true;

    = CREATION_WORLD = 0;

    --> Generate your world with the array;

    --> Set CREATION_WORLD = 1;

  • That Is Awesome!! And so damm easy!!! wow i feel like a real stupid.

    TELLES0808 my gratitude goes to you for explaining this to me.

    You and R0j0 have some awesome pictures by the way,I love Dogs in general,Thank you once again.

    Before i go i have one more question about this paticular capX and everything i learned so far from you guys.

    What would i have to do to create the random style terrain.I also know that switching the id of the array to show my animation frame change would be the best option to add Ores and stone but how do you place the Actual position.

    For instance If i want to have stone on my 10th row to the 20th row then the rest back to dirt how would i go about Dictating the position where everything starts to generate.

    i hope i made sense Thank you again

  • That's another use of variables, local or global.

    The easiest way is check if the array.at(X,Y) is where you want start to place the ore, also checking if the array.at(x,y) is bigger than the range wanted.

    Checking it before start the events of placement, and configuring each placement method to place the desired tiles there is the easiest way.

    So, you'll be able, for example, to make grass on the top tiles, while filled dirt blocks inside the ground, by checking their Y with the conditionals.

  • TELLES0808 i apollogize man ,But i am missing something when it comes to what you are saying.I dont understand how to make that happen in code i know how to use variables but incorperating it with arrays,I have never done before.Do i have to tell each Cell which ore goes where? and how would i check if a cell is empty? I dont want to sound funny but all of these questions are helping me alot and i hope others from the forums get help from this aswell.

  • To Me this isnt making sense.I am missing a piece of info that could clear this right up to me.

    I understand how to check if the range is bigger on an array but how does that affect anything? How does that change my grass to whatever else i want?Everytime i set it up it changes every single tile to the exact same sprite.

    Dont leave me hangin guys im so close to learning this.Thank you for everything so far,i know it can be annoying to anwser the same questions in different ways over and over.

    R0J0hound TELLES0808

  • I don't have C2 in front of me but from what I gather here he is saying just like you did with the max height to keep it from filling your screen, check what row(Y) you are at in the array, and based on that do logic to say if array.Y = 4 then the tile you should use is "whatever tile goes on that row"...

    Hope that helps, sorry if not.

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