Issues With Array Checking

Get help using Construct 2

Post » Sat Mar 19, 2016 7:04 am

Hello everyone,

Im having a few issues trying to figure out how to check if my solid block inside my array is exposed to air above.

I want to spawn something ontop of those spites if it is exposed.

whats messing with me is the fact that my array generation is random so i cant call one code to just fill a row and change anything in particular. I want to make a dirt block turn to grass and also have a tree sapling spawn/created in the cell and only the cell right above the dirt sprite.

I looked around but didnt see any capx files that show how to do this. The event will only be called once and that is at the start of the game, After that the code will be useless.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Sat Mar 19, 2016 7:35 am

Can we see a capx please? Is this topdown like Zelda or 2D and a sidescroller such as Terraria?
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620

Post » Sat Mar 19, 2016 7:37 am

@LaDestitute Sorry about that it is a 2D Platformer like Terraria.

I can send you the capX
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Sat Mar 19, 2016 7:43 am

@LaDestitute I have a few addons inside C2 now that i think about it. I have NoiseJs. And Magicam. Im sorry about that but im not sure you can open it unless you have those installed.

My random generation comes from perlin noise.

I am still willing to hear your feedback about this issue.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Sat Mar 19, 2016 7:55 am

I'll download the plugins in a moment after a search but keep mind, next time, give links if you can.
Just go ahead and upload the capx.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620

Post » Sat Mar 19, 2016 8:00 am

@LaDestitute Thank you for the help i sent it to your inbox. I apollogize aswell for not posting links, I have been gone for a long time so im getting back in the mode.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Sat Mar 19, 2016 8:07 am

Just loop over the array and if the current value is dirt, the value above is empty do whatever.
The actual event to do this is like this here:

For each xy
Array at (curx, cury) = 1
Array at (curx, cury-1) = 0
--- do something

At least that's the simple case of air to dirt.
B
92
S
32
G
110
Posts: 5,295
Reputation: 71,501

Post » Sat Mar 19, 2016 8:10 am

@R0J0hound Wouldnt this same expression work if i was trying to spawn something ontop of the dirt aswell? If my mind is working correct it looks like it would.
Last edited by RookieDev on Sat Mar 19, 2016 10:51 am, edited 2 times in total.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Sat Mar 19, 2016 8:23 am

You could. It just identifies all the places where air is above dirt. You can then do what you like in the actions.
B
92
S
32
G
110
Posts: 5,295
Reputation: 71,501

Post » Sat Mar 19, 2016 10:52 am

@R0J0hound

Correct me if im wrong, will this work if my array is setup using sprite frames?

0 is the initial value of the dirt so how would 0 be the value of an empty array cell?

Im filling the array with one sprite and setting the frame to the cell value. Im missing something.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Next

Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, valefor and 6 guests