Divebombing foes, more collision stuff

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
GungnirDev
Party member
Posts: 119
Joined: Thu Jun 28, 2012 10:31 pm

Divebombing foes, more collision stuff

Post by GungnirDev »

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?
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
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Re: Divebombing foes, more collision stuff

Post by Santos »

Try removing lines 68 to 75 in ship.lua.

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
Otherwise things get removed twice (again on lines 90 to 96). :D
User avatar
kalium
Prole
Posts: 9
Joined: Fri Jul 06, 2012 6:36 pm
Location: Rio de Janeiro

Re: Divebombing foes, more collision stuff

Post by kalium »

Secondary question: I want the divebomber enemies to zig-zag as they falls. Easiest way to do this?
You could try using a sine function to control the enemies' horizontal positions.

Something like

Code: Select all

posX = initialX + math.sin(time);
time = time + dt;
Where 'time' is the total time in the game, initialX is the 'central' position of the ondulation, and dt is the time variation between frames.
Multiply 'dt' by a factor to define how fast he zigzags.
User avatar
GungnirDev
Party member
Posts: 119
Joined: Thu Jun 28, 2012 10:31 pm

Re: Divebombing foes, more collision stuff

Post by GungnirDev »

@ 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.
Bullets are the beauty of the blistering sky
Bullets are the beauty and I don't know why
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest