Now that I've figured out how to make my bullets and enemies mutually remove themselves from the world I've decided to try the same thing with my new divebombing enemy type (which looks a tad like Pac-Man cosplaying as Wolverine) and and the player.
Main question: Why isn't my collision working? All I get out of this (in ship.lua) is that now killing one enemy will also also kill another enemy next to the first enemy, which doesn't seem right, and they still can't kill the player's ship. Could someone please explain for future reference why my current code doesn't remove player and enemy? The code is the same it's just the targets that are different.
Secondary question: I want the divebomber enemies to zig-zag as they falls. Easiest way to do this?
Divebombing foes, more collision stuff
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- GungnirDev
- Party member
- Posts: 119
- Joined: Thu Jun 28, 2012 10:31 pm
Divebombing foes, more collision stuff
- Attachments
-
- shmup.love
- (695.65 KiB) Downloaded 142 times
Bullets are the beauty of the blistering sky
Bullets are the beauty and I don't know why
Bullets are the beauty and I don't know why
Re: Divebombing foes, more collision stuff
Try removing lines 68 to 75 in ship.lua.
Otherwise things get removed twice (again on lines 90 to 96).
Code: Select all
-- remove the marked enemies
for i,v in ipairs(remEnemy) do
table.remove(enemies, v)
end
for i,v in ipairs(remShot) do
table.remove(player.shots, v)
end
Re: Divebombing foes, more collision stuff
You could try using a sine function to control the enemies' horizontal positions.Secondary question: I want the divebomber enemies to zig-zag as they falls. Easiest way to do this?
Something like
Code: Select all
posX = initialX + math.sin(time);
time = time + dt;
Multiply 'dt' by a factor to define how fast he zigzags.
- GungnirDev
- Party member
- Posts: 119
- Joined: Thu Jun 28, 2012 10:31 pm
Re: Divebombing foes, more collision stuff
@ kalium: It worked! Thanks, I'll play with this a bit. EDIT: sin was too big, so I used cos instead.
@ Santos: That fixed the multiple-kill problem, but the enemies still can't remove the player.
@ Santos: That fixed the multiple-kill problem, but the enemies still can't remove the player.
Bullets are the beauty of the blistering sky
Bullets are the beauty and I don't know why
Bullets are the beauty and I don't know why
Who is online
Users browsing this forum: Ahrefs [Bot] and 9 guests