I want to know the process of erasing bullets in a shooting game
Posted: Thu Nov 12, 2020 9:54 am
Hello everyone.
I have something to ask you, so I will post it in the forum for the first time.
I'm developing a shooting game sample.
I heard on the LOVE2D learning site that "the bullets should be put in a table and implemented", and the player succeeded in firing the bullets in the same way.
What I want to implement now is "the bullets will disappear from the screen after a certain amount of time".
A timer variable (mainshot_remove_timer) is prepared, and when the upper limit value (mainshot_remove_time) is reached, the bullet is erased.
When removing a bullet from the table, it is processed to erase [1] of the table so that it will be erased from the bullet fired first. The process has been successful, but I find this a bad idea.
Is the table-less approach more effective? I also thought, but I don't know what kind of approach is suitable.
How do you deal with such a problem (the process of multiple same objects appearing on the screen and erasing only a specific object)?
(If there is a good method, I would like to apply that method to erase the enemies whose life has become 0 from among the enemies that appear a lot)
I will attach a file that extracts only the game scene. The process of removing bullets is in "bullet_amattMain.lua". Fire a bullet with the "z" key.
I would be grateful if you could give me some advice!
I have something to ask you, so I will post it in the forum for the first time.
I'm developing a shooting game sample.
I heard on the LOVE2D learning site that "the bullets should be put in a table and implemented", and the player succeeded in firing the bullets in the same way.
What I want to implement now is "the bullets will disappear from the screen after a certain amount of time".
A timer variable (mainshot_remove_timer) is prepared, and when the upper limit value (mainshot_remove_time) is reached, the bullet is erased.
When removing a bullet from the table, it is processed to erase [1] of the table so that it will be erased from the bullet fired first. The process has been successful, but I find this a bad idea.
Is the table-less approach more effective? I also thought, but I don't know what kind of approach is suitable.
How do you deal with such a problem (the process of multiple same objects appearing on the screen and erasing only a specific object)?
(If there is a good method, I would like to apply that method to erase the enemies whose life has become 0 from among the enemies that appear a lot)
I will attach a file that extracts only the game scene. The process of removing bullets is in "bullet_amattMain.lua". Fire a bullet with the "z" key.
I would be grateful if you could give me some advice!