Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / How would I make an explosion?

Author
Message
Urist McCoder
19
Years of Service
User Offline
Joined: 27th Sep 2005
Location: At the computer.
Posted: 4th Mar 2009 02:52
I've been wanting to make a game where their are explosions that blast nearby objects back. I know how to make particles fly everywhere, but I need to know how to make stuff be moved by the explosion.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Mar 2009 05:28
Well, if you decide on a radius of influence of the explosion, the closer to the center of the explosion, the more force can be applied to what you want to move. Let's you decide there will be a force of 10 and the maximum radius of influence of the explosion would be 10. So, if the object to be moved was within 0 to 1 units of the explosion center, then the force applied would be 10. If the object to be move was within 9 to 10 units then the force applied would be 1.

Once you get the force based on the distance from the center of the explosion, use that to calculate how far the object is pushed. You can use real physics or you can fake the values.

If it's in 3d, and y is up, then you can find the distance between the center of the explosion and the object using the distance formula.

You can find the y angle that the object would be pushed with
angle=atan(objectx-explosionx,objectz-explosionz).

Move the object with newxvalue and newzvalue
newx=newxvalue(objx,angle,distance based on the force)
newz=newzvalue(objz,angle,distance based on the force)
position object obj,newx,objy,newz

There's other things to consider like if the object is above the explosion it might be lifted into the air.

But the principal is the same. You may have to calculate trajectory.

Enjoy your day.
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 5th Mar 2009 00:54 Edited at: 5th Mar 2009 00:55
interesting look on the question latch, i took the question as how do i make an object "explode" into either a fiery ball or into fragments of the object. Im not too experienced but there is prolly a way to do my method using memblocks, ask bn2 or some1 else

[edit]
that was dumb, i didnt read the actual post, i just went by the subject, 4get i said nething
Urist McCoder
19
Years of Service
User Offline
Joined: 27th Sep 2005
Location: At the computer.
Posted: 5th Mar 2009 01:59
Thanks Latch! I think I get it now.

Login to post a reply

Server time is: 2025-05-17 16:55:48
Your offset time is: 2025-05-17 16:55:48