[Solved]How to create "explosions" no PS or Physics?

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
AlexCalv
Prole
Posts: 49
Joined: Fri Aug 08, 2014 7:12 pm
Contact:

[Solved]How to create "explosions" no PS or Physics?

Post by AlexCalv »

I'm trying to create a sort of sim where you can launch fireworks and they explode and whatnot. I'm avoiding the particle system and physics modules entirely. I can't for the life of me figure out how to make my particles actually, like, fly out however. I really want to just avoid the modules Love provides just so that I can understand how they work better in general. I also like to handicap myself for whatever reason. Here is my current .love.

Edit:
Here is a pic if you don't know what I'm trying to achieve.
https://love2d.org/imgmirrur/82XH4CN.png
I want the particles to explode outward like that. Not how they just drop like they do now.
Attachments
fireworks.love
(1.02 KiB) Downloaded 116 times
Last edited by AlexCalv on Sat Jul 04, 2015 7:39 am, edited 1 time in total.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: How to create "explosions" no PS or Physics?

Post by micha »

Hey, you are on the right track. The change you need is this: When you spawn one of the small particles, you need to give it a random x- and y-velocity once. Then while it is flying do not use any randomness, but only physics.

Here are the lines you need to change:

Code: Select all

function particles.Spawn(x, y, amount)
	for i = 1, amount do
		local xVel = love.math.randomNormal()*100
		local yVel = love.math.randomNormal()*100
		table.insert(particles, {x = x, y = y, xVel = xVel, yVel = yVel, amount = amount})
	end
end
(By the way you can leave away the "amount=amount" in the particle table.

And then also remove the randomness from the movement:

Code: Select all

		--v.xVel = v.xVel + love.math.random(-500, 500) * dt
The next think, you can play with is some sort of damping/friction.
User avatar
AlexCalv
Prole
Posts: 49
Joined: Fri Aug 08, 2014 7:12 pm
Contact:

Re: How to create "explosions" no PS or Physics?

Post by AlexCalv »

micha wrote:Hey, you are on the right track. The change you need is this: When you spawn one of the small particles, you need to give it a random x- and y-velocity once. Then while it is flying do not use any randomness, but only physics.

Here are the lines you need to change:

Code: Select all

function particles.Spawn(x, y, amount)
	for i = 1, amount do
		local xVel = love.math.randomNormal()*100
		local yVel = love.math.randomNormal()*100
		table.insert(particles, {x = x, y = y, xVel = xVel, yVel = yVel, amount = amount})
	end
end
(By the way you can leave away the "amount=amount" in the particle table.

And then also remove the randomness from the movement:

Code: Select all

		--v.xVel = v.xVel + love.math.random(-500, 500) * dt
The next think, you can play with is some sort of damping/friction.
Wow! Thank you so much! It really is just a wonder how you can overlook such simple things haha!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 39 guests