Space Shooter Issues

Just a thought. If you are setting all the rect (aka mesh) properties each frame, then the rects are effectively anonymous, and there is no need to assign them to specific rasteroids.

Just loop through the list of asteroids and modify rects from 1 onwards, then zero the positions of any rects not used.

Then there is no need for destroying, recycling or any other recordkeeping, you simply use the rects you need and ignore the rest.

Yes, if you’re not setting any other properties of the rect, such as color or texCoord, then it would be simpler to treat them anonymously. Good idea. Plus you might need to do that in order to handle Z distance draw order (rects are drawn in the order of their creation).

Then it’s easy just to sort the asteroid array by distance before setting the rect properties.

Although, if the asteroids are created at the same distance, and move towards the player at the same speed (not sure if this would quite work as the asteroids do have slightly differing trajectories ), you won’t need to sort, you could just go through the table in reverse order, as the newest asteroids would always be furthest.

that’s probably good enough for a simple game!

@Yojimbo2000 I think I kinda followed most of that. Haha! It sounds really cool, and I want to try it out!

@Ignatz I agree! This wasn’t meant to be a super complicated game, I just wanted to try out a few new things. I’m sure there are plenty of asteroid shooting games out there. Do you have any blog posts on meshes in 2D?

@Dwins - try my ebook on Codea, from here

https://www.dropbox.com/sh/mr2yzp07vffskxt/AACqVnmzpAKOkNDWENPmN4psa