In my next game, (which is a collab with Battlesquid) I need to handle projectiles, so I have a list, L2, and am storing various sets of data in it, each with 5, “data points” per item. (In this case, it is a position, a direction, a speed, and a value that indicates damage inflicted if it hits an enemy)

Once every cycle of this game, I move the projectiles one step (based on their speed) forward in their direction. Inevitably, they will hit enemies, walls, or the boundaries of the screen.

Once I calculate damage and such, I then need to dispose of the projectile data, because my list would fill up otherwise. The other projectiles’ data points (if they were behind the deleted data point in the list) need to move down the list.

The code I need will be run only when a projectile’s data needs to be deleted. For simplicity, the projectile’s number will be stored in “A”.

The projectile’s number is its position in the list. The position of the first element in the list where data for projectile n is stored is 5n-4

(Yes, I know this post doesn’t make sense, because I read it over. I’m hoping that someone is able to see through my inability to preform the basic task of putting concepts into words when their phone’s battery is at 2% and give me some form of useful response)
Let me point you to this, in case that helps. Smile
If you want to remove multiple non-sequential elements from L2, with the indices of these elements stored in L3, you could do this:

This is so creative and yet so ... convoluted compared to indexing one list with another list (which the calculator can't do).

As in

L1(L2)->L3 %
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum