so it is supposed to simulate 3d buildings with the player angle and distance scaling the building to provide the 3d effect my problem is my sorting system of the distance of building1 seems to have no effect and z depth doesn’t seem to affect these sprites.
the problem is with your code. let’s take a look at this bit:
so my guess here is that the idea was that each step of this loop would get all sprites that were X pixels away. so, for example, at index 10 it would get all sprites that are exactly 20 pixels away.
however, the way the “get all sprites within radius” block works is that it returns all sprites at that radius or less, meaning at the last step of the outer loop (when the radius is at its maximum), it’s going to get all of the buildings and give them the same z index
i think the easier solution here would be to just get the distance of each building sprite from the player and set the z-index based on that. you’re already calculating the distance in the loop below this one, so you could just alter the z-index there.
but what to set it to? well, we want closer buildings to be above further buildings, so we’re going to need to subtract from some larger number like this:
sprite.z = 1000 - (distance from mySprite)
however, it would probably be a good idea to keep the z-index in a more manageable range. 1000 is pretty high so it will be annoying to put HUD elements overtop it.
so something like this might be better:
building.z = 10 + ((1000 - (distance from mySprite)) / 1000)
that’ll make it so that all our buildings have z index values that are between 10 and 11
ignore that system said it was a bad post (I “forgot” a link), and if it helps, it involved floating point numbers. @system please allow this post
Is there a difference between this render on z with screen and the one from sprite-utils?
Also, is it a bad idea to create a bunch of renderables, or is it OK? I’m working on a particle extension, and I can either render all of them as one or make each particle its own renderable (which I’m worried might cause lag).
i think there is no difference they both use the image.createrenderable or something like that
scene.createRenderable
I was close
no difference! and yeah, i wouldn’t create one for each particle though it might be fine. renderables are way more lightweight than sprites; the only lag caused would be making the scene sorting slower and i don’t think it would be that bad… just make sure you destroy them as they finish drawing.
but really, i think you’d be better off just making one that draws all the particles at once.
I genuinely forgot that distance to my sprite exists lol I may make a small extension out of rhis
There’s a bug with the for each visible tile location with x y location block. If tiles are at the right or bottom edge of the screen and are only partially visible, they won’t be in the loop. If I take the animated tiles example, expand the tilemap, and add a moving camera, you can clearly see it.
@richard are you going to fix it?
fixed! version 0.1.2
