projectile help

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Crossing
Prole
Posts: 41
Joined: Sat Mar 21, 2015 3:37 pm

projectile help

Post by Crossing » Sat Oct 12, 2019 9:25 am

Hey guys making a little game and having some trouble with the bullets. never really done anything shooter related and having trouble making some code to shoot, detect, and remove bullets. If you spam click and just click around you'll notice some bullets disappear for no reason. also for some reason i get occasional stutters anyone know why?



note a lot of aliens might go to the earth (its random chance) just testing the collision, which is the same thing i used for the projectiles but no problems like the projectiles?
Attachments
WorldsatWar.love
(23.72 KiB) Downloaded 2 times

User avatar
pgimeno
Party member
Posts: 1818
Joined: Sun Oct 18, 2015 2:58 pm

Re: projectile help

Post by pgimeno » Sat Oct 12, 2019 10:26 am

Crossing wrote:
Sat Oct 12, 2019 9:25 am
note a lot of aliens might go to the earth (its random chance) just testing the collision, which is the same thing i used for the projectiles but no problems like the projectiles?
No, it's not the same thing.

To mark the aliens for deletion, you use: table.insert(RaidHit, i) but for the bullets, you use: ProjectileTrash[i] = i. The latter is not correct, because the index of the bullet is not valid as an index into the ProjectileTrash array. It creates holes in the ProjectileTrash array; you're lucky it works at all.

You can use table.insert, like with the aliens, or you can use a variable that you initialize with zero, and tells you how many elements are there in the ProjectileTrash array.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests