Maydie's Recent Forum Activity

  • AllanR

    Update 1: It is looking like it doesn't actually see the objects until after the "on start of layout" section. It works when i throw it outside of that which is after the layout has loaded.

    Strange, the json is not showing any instances of trees even though I did it correctly.

    I am not too concerned about the water overlapping just yet. I am going to put the water in first, block that off so nothing can spawn there, then spawn the trees after. Right now I just want to make sure I have something that works when trying to store other sprites that I already "created" during the before load section. I have other resources that I would like to also store to the array. If i can at least get the tree sprites to work the rest should be easy.

  • AllanR

    Yeah I realized that after the fact lol.

    I just went through and made sure that all of the trees were indeed on snap. All of the locations were randomized with x=round(random((0, LayoutWidth)*32)/32))

    y=round(random((0, LayoutHeight)*32)/32))

    The layout itself is a multiple of 32

    Am I calling the sprite correctly? I need to be able to loop through all of them.

  • AllanR

    Hello,

    Ok, I have been trying to get this to work for hours. I easily managed to get your capx to work for me (thanks for that ;D). Now I have been trying to adopt it to store values of other sprites within the layout (this is all before the layout finishes loading). My last array I am working on is to loop through my entire layout and look for every sprite named "tree'. I thought it would be simple to do the following:

    https://www.dropbox.com/s/fwgqcsp155qe2 ... 3.jpg?dl=0

    All of the trees were created using "create object" at random coordinates (all of which are on 32 grid snap).

    That project you made looks awesome btw.

  • AllanR

    I cannot wait until work is done to check this out, sometimes I think I took the wrong career path....aww well. Sounds like exactly what I have been trying to do. I truly appreciate the effort of creating a mini project for me, I will check it out and let you know. I was pulling out my hair last night trying to get the array to work.

    Essentially what my plan for this is:

    -Have a set amount of random bodies of water

    -randomly select a location where no other tiles currently exist

    -Create a random sized body of water with that information on a 32 snap grid

    My next challenge after this is to find the outline of the water and replace it with the appropriate sprites so it looks more natural, something I will of course attempt before asking anyone here to help with.

    Cheers!

  • Update: Nope, spoke too soon, sorry for posting so much.

    I think I may have figured it out, I am trying to validate the data. Maybe someone with more experience will be able to point it out before I have finished.

    I changed the last "For each XY element" to:

    https://www.dropbox.com/s/st05bvbfdvfgz ... 2.jpg?dl=0

  • Hello,

    First of all I really appreciate the time to write.

    Secondly, I guess arrays flew over my head but looking at that example and your explanation I think I am on track now. Having said that, this is as far as I have got:

    https://www.dropbox.com/s/0ec29x8wf5bdi ... 1.jpg?dl=0

    Correct me if I am wrong, this will only delete duplicate values at the first "Y0" it sees that has been duplicated. I would like to modify this to look for when "Y0" AND "Y1" are both exactly the same.

  • Let me know if there is anything I can make more clear. I appreciate any help and time in advance. Was hoping this was an easy one so I could continue work on my project after work today.

    Cheers

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello,

    First time post, so far all my answers have been answered simply by going through the forums. My challenge is with manipulating 3D arrays.

    I have a 3D array that is 50 in width, 1 high, and 3 depth. I am using this to store randomly generated coordinates before the layout has loaded. I am doing this to create an object without ever creating another object over top of one that has already been occupied when the layout gets generated using the array.

    My current array setup:

    -Depth 1 = "X" coordinate, -Depth 2= "Y" coordinate and "Z" stores the same value (for example "sprite1").

    My dilemma:

    I would like to loop through the entire array named "arrayMap" and remove all duplicates where index "x" depth 1 and depth 2 are duplicated.

    For example:

    Index 4, Depth 1 = 20, Depth 2 = 15, Depth 3 = "sprite1"

    Index 32, Depth 1 = 20, Depth 2 = 15, Depth 3 = "sprite1"

    Index 4 and Index 32 have the same values stored for an "X" and "Y" coordinate so I would like to remove the duplicate (while of course keeping one instance of it).

    Hopefully my explanation makes sense. I did a lot of reading on arrays but my feeble brain gets lost as soon as nested loops and 3D arrays get involved.

    I appreciate any help that can be offered as this will solve a ton of my "random generated" sprite issues that I currently have, not to mention make things a lot cleaner with less coding.

    Cheers.

Maydie's avatar

Maydie

Member since 31 Jul, 2015

None one is following Maydie yet!

Trophy Case

  • 9-Year Club
  • Email Verified

Progress

10/44
How to earn trophies