How do I Delete Duplicate 3D Arrays

Get help using Construct 2

Post » Wed Jun 29, 2016 3:00 am

@Maydie

when you are adding the trees to the array, you are using their screen coordinate ( tree.x ) ...

just took another look, and you must have updated the image. try floor(tree.x/32) and floor(tree.y/32)
B
95
S
33
G
20
Posts: 438
Reputation: 17,640

Post » Wed Jun 29, 2016 3:37 am

@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.
B
30
S
14
G
3
Posts: 16
Reputation: 3,734

Post » Wed Jun 29, 2016 4:00 am

@Maydie
yes, it looks like you are calling them correctly.

However, when the water is created, it is only looking for places that are not water - so it could put water over a tree...
B
95
S
33
G
20
Posts: 438
Reputation: 17,640

Post » Wed Jun 29, 2016 4:13 am

@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.
B
30
S
14
G
3
Posts: 16
Reputation: 3,734

Post » Wed Jun 29, 2016 4:38 am

@Maydie

when you create objects, the instances can not accessed until the next top level event. (that is why they can be accessed outside the On Start of layout).
But they can be accessed in the section where they are created, so you could insert them into the array as they are created... (which is what I was doing when the water is created).
B
95
S
33
G
20
Posts: 438
Reputation: 17,640

Post » Wed Jun 29, 2016 4:47 am

@AllanR

Crap. So far I have 2 sections. One for spawning resources which essentially I made collision boxes, and if they didnt overlap any other collision boxes then I spawn the nodes within the area. The same thing for the trees.

The difference for the water is I wanted to eventually replace the edges of a body of water with different sprites to make it look like the edge of a lake, I thought that using an array would be the best use. I still think it is so I may try to use a combination of what you taught me and my previous butchered collision boxes and go from there for now.

Ultimately I may just end up trying to figure out that noise plugin to generate the map more cleanly, or (sigh) re-do all of my coding to store everything into an array first, then generate everything afterwards instead of doing it in multiple steps.

I appreciate all of the help. Hopefully I can pick on your brain in the future ;)
B
30
S
14
G
3
Posts: 16
Reputation: 3,734

Previous

Return to How do I....?

Who is online

Users browsing this forum: amazingdream, lordsas, mekonbekon and 49 guests