Bullet hell bullets?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Gunroar:Cannon()
Party member
Posts: 1143
Joined: Thu Dec 10, 2020 1:57 am

Bullet hell bullets?

Post by Gunroar:Cannon() »

Just wondering how one would make bullet patterns for, example, a bullet hell like thing. I already have bullets (easy) with angular velocity, but I can't seem to think of any way to coordinate them in different ways.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
MrFariator
Party member
Posts: 559
Joined: Wed Oct 05, 2016 11:53 am

Re: Bullet hell bullets?

Post by MrFariator »

If you can spawn a bullet that might swerve or curve, in a radial, sine wave or whatever other manner, you're basically already done. Next you just have to spawn a bunch of them at different positions, angles and timings. You could do reusable functions by hand for each pattern, enemy or boss type (how I imagine fair few games might do it), or you could try to create some sort of system that just takes a number of inputs and produces a certain kind of bullet pattern. The tricky part is making those waves of bullets fun to weave through and dodge, so player doesn't get frustrated by 'cheap' patterns.
User avatar
Gunroar:Cannon()
Party member
Posts: 1143
Joined: Thu Dec 10, 2020 1:57 am

Re: Bullet hell bullets?

Post by Gunroar:Cannon() »

Okay, so now I can think of a few patterns I could do, like a circle that moves out...

Code: Select all

angle = 360
for x = 1, bulletNum do
   angle = angle/bulletNum
   newBullet(angle) -- velocity from angle, got that
end
To make it a sine wave could I do angle=sine...wait no. The bullets velocity should now be changing always. How would I go about that.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
MrFariator
Party member
Posts: 559
Joined: Wed Oct 05, 2016 11:53 am

Re: Bullet hell bullets?

Post by MrFariator »

Generally any time a bullet is updated (whether it's done by some object maintaining the bullets, or each bullet being its own object and updating independently), you simply apply the desired change in angle each game tick for a given bullet. How you go about doing that is up to you and your code.
User avatar
Gunroar:Cannon()
Party member
Posts: 1143
Joined: Thu Dec 10, 2020 1:57 am

Re: Bullet hell bullets?

Post by Gunroar:Cannon() »

Code: Select all

update(dt)
    self.angle = math.sin(self.x)
    self.vx, self.vy = getVelocityFromAngle()
end
Something like that? Since sine should change angle based on x position, right?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
MrFariator
Party member
Posts: 559
Joined: Wed Oct 05, 2016 11:53 am

Re: Bullet hell bullets?

Post by MrFariator »

For a sine wave I think it'd be better to do it based on the time the bullet has been alive on the screen, not its x/y position. This is because you might have the bullet travel on a line, at a specific angle (ie. think a boss shooting sine wave bullets, directed at player's current position, from where the boss is at the time), and you'd want the bullet to sine wave along that line. Tracking on x/y position works if you just want the bullet to travel horizontally or vertically, though.

Of course, it depends on the end goal of the specific curving you want that streak of bullets to perform. Just generally it might be easier to think any curving and waving happening as a function of time, rather than current position.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests