May I Get Some Array Help?

Get help using Construct 2

Post » Tue Nov 05, 2013 7:45 pm

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
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,368

Post » Wed Nov 06, 2013 5:22 am

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
B
91
S
31
G
103
Posts: 5,238
Reputation: 67,762

Post » Wed Nov 06, 2013 9:05 am

This didnt work for me @R0j0hound i did exactly as you said to do.
im missing something.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,368

Post » Wed Nov 06, 2013 12:13 pm

I did exactly like R0j0 said.

https://dl.dropboxusercontent.com/u/47035927/temp/RandomMap-d4f6uml0f837.capx
Image
B
104
S
23
G
17
Posts: 1,350
Reputation: 22,028

Post » Wed Nov 06, 2013 2:11 pm

I see where i meesed up by looking at your capX file @TELLES0808
@R0J0hound.
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.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,368

Post » Wed Nov 06, 2013 2:12 pm

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.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,368

Post » Wed Nov 06, 2013 3:14 pm

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;
Image
B
104
S
23
G
17
Posts: 1,350
Reputation: 22,028

Post » Wed Nov 06, 2013 7:46 pm

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
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,368

Post » Wed Nov 06, 2013 8:31 pm

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.
Image
B
104
S
23
G
17
Posts: 1,350
Reputation: 22,028

Post » Thu Nov 07, 2013 10:41 am

@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.RookieDev2013-11-07 10:45:36
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,368

Next

Return to How do I....?

Who is online

Users browsing this forum: alextro, Colludium, Ryan Kocourek and 8 guests