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)
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)