Issues With Array Checking

0 favourites
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • 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.

  • Can we see a capx please? Is this topdown like Zelda or 2D and a sidescroller such as Terraria?

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

    I can send you the capX

  • 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.

  • 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.

  • 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.

  • 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.

  • 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.

  • You could. It just identifies all the places where air is above dirt. You can then do what you like in the actions.

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In what I posted above, 0 is empty and 1 is dirt. It doesn't matter what values you use, 0 can be dirt but you need a value for empty. How do you currently know a position has air?

  • R0J0hound That was my issue,I dont understand how. How can air be 0 if my sprite value is 0 so my question would be how do i replace the value for air?

    Can I? Or what trick do i have to pull off to get this to work in a way that i can understand.

  • Maybe -1?

  • R0J0hound Here is my capX if you could show me what im doing wrong i would be very grateful.

    I dont see where i am making a mistake, I tried using the syntax you showed but it ended up making all tiles turn to grass. I dont think my approach is the best.

    https://www.dropbox.com/s/z0qvx32mtrdyd ... .capx?dl=0

    The sprites inside this capX are free to use for prototyping if anyone needs it but do not use them for revenue.

  • R0J0hound Is the anwser really that simple or are you trolling me? I feel like you are not trolling but assume that i know the outcome,im quite sure that my post explains in detail that im no good with these arrays, -1 is not a viable anwser for me since im pretty much lost.

    All i need to figure out is how to make this work with my capX or what im doing wrong so i can fix it. There is no way that many people can learn arrays without running into some issues if you are doing everything alone and not with a partner.

    Im straight up confused about these arrays and im starting to lean towards different ways to get my game complete,I have spent alot of time trying to learn arrays alone in scirra construct and everytime i just feel like im a burden to the community.

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