Omnimaga

Calculator Community => Major Community Projects => The Axe Parser Project => Topic started by: Builderboy on February 12, 2011, 02:20:55 am

Title: ChainFire Pinball Library
Post by: Builderboy on February 12, 2011, 02:20:55 am
So with the recent influx of physics related games, as well as a recent increase in the interest of ball physics, I have become a bit more interested in it myself, and so I spent all of Bio the other day and a considerable amount of time out of class writing this pinball physics engine for pixel based collision.  It uses the onscreen pixels only for collision, although it could easily be changed to a backbuffer or alternative buffer.  This is developed for pinball games in mind, and has several changeable variables which can change the way the ball behaves:

Collision Elasticity: from 0% to 100% How much energy the ball retains after a collision with a wall or object
Rolling Angle Threshold: from 0 to 90 degrees, this value changes how small of an angle the ball has to hit the wall to switch to rolling physics.  If this number is very small, the ball will bound around a lot, if this number is very large, the ball will tend to 'stick' to walls.

These values are currently hardcoded into the code, but in the future I hope to release a flexible engine with a large number of changeable parameters.  As for the engine itself, this is how it works:

The balls position is first backed up, and then incremented by the velocity.  If the ball collides with anything, we enter the collision test segment.  The ball checks the pixels around it to determine the surface normal vector of the wall it collided with.  It then normalizes that vector and uses it to move the ball backwards out of the wall.  If the vector is not accurate enough to get the ball out of the wall, the balls backed up position value is used instead.  We then find the dot product of the balls velocity and the surface normal vector, resulting in a value from -M to M, where M is the magnitude of the velocity of the ball.  If this value is greater than the Rolling angle threshold, perform the vector transformations to subtract the perpendicular vector component from the velocity of the ball.  If the value is less than the Rolling angle threshold, the perpendicular vector is negated, and then multiplied by the Collision Elasticity value.  

Thats a lot of technical mumbo jumbo, lets just get to the screenshots, enjoy!  The screenshot it running with a collision elasticity of 0.5 and a rolling angle threshold of 22.5 degrees

Title: Re: ChainFire Pinball Library
Post by: leafy on February 12, 2011, 02:32:43 am
That looks freaking amazing. Reminds me of that sonic ball physics thing you did a while back.
Title: Re: ChainFire Pinball Library
Post by: Darl181 on February 12, 2011, 02:32:48 am
Wow, this looks awesome ;D
Is this the start of a pinball clone by any chance, or is it just a proof of concept?

EDIT 600 posts :w00t:
Title: Re: ChainFire Pinball Library
Post by: Builderboy on February 12, 2011, 02:35:10 am
Thanks :D My hope was to get it looking as good as the sonic physics engine ^^ That uses a much more stable algorithm than this one, and so it was a lot easier to get good physics, plus it was tile based.  For this, it was a lot more difficult, so my hope was to get it as good looking as sonic :)

And this is just a library I will be releasing to the public for anybody to use for anything they want :) This is in the same branch as Zedd, its a physics library made to make it easier for people to write games with high physics elements in them.
Title: Re: ChainFire Pinball Library
Post by: Darl181 on February 12, 2011, 02:49:40 am
And at this rate, it looks like something's going to crop up soon...
If Tio weren't keeping me busy, I would try it in a blink ;D
Title: Re: ChainFire Pinball Library
Post by: Builderboy on February 12, 2011, 02:54:29 am
Thats my goal :) To make it as easy as possible for people to get advanced physics in their games. ^^
Title: Re: ChainFire Pinball Library
Post by: Hot_Dog on February 12, 2011, 03:33:53 am
Builderboy, this is so amazing that I wish you would make your own pinball game :D

No pressure ;)
Title: Re: ChainFire Pinball Library
Post by: AngelFish on February 12, 2011, 03:43:20 am
Thats my goal :) To make it as easy as possible for people to get advanced physics in their games. ^^

I'll take a modeling engine, please :P
Title: Re: ChainFire Pinball Library
Post by: Builderboy on February 12, 2011, 03:55:41 am
What do you mean?
Title: Re: ChainFire Pinball Library
Post by: z80man on February 12, 2011, 04:27:08 am
Is that like a 2d modeling engine to draw polygons on the screen?
Title: Re: ChainFire Pinball Library
Post by: AngelFish on February 12, 2011, 04:33:51 am
Well, I was hoping for something like a 3D physics engine...

j/k
Title: Re: ChainFire Pinball Library
Post by: TIfanx1999 on February 12, 2011, 07:55:54 am
Cool stuff as always Builderboy! =)
Title: Re: ChainFire Pinball Library
Post by: ztrumpet on February 12, 2011, 09:27:38 am
Looks great!  It's really fun to play with. ;D
Title: Re: ChainFire Pinball Library
Post by: jnesselr on February 12, 2011, 12:49:38 pm
I can't seem to find a download for this.  Is there one yet?
Title: Re: ChainFire Pinball Library
Post by: Madskillz on February 12, 2011, 12:51:07 pm
As always the physics look awesome.

Don't think there is a download yet graphmastur
Title: Re: ChainFire Pinball Library
Post by: Builderboy on February 12, 2011, 01:37:07 pm
There is a download now :) Be warned that there are still some small bugs that you might encounter.  Nothing engine crippling, but it will present some oddities.
Title: Re: ChainFire Pinball Library
Post by: jnesselr on February 12, 2011, 03:13:41 pm
Oooh, I do see some oddities.  Other than that, it's pretty interesting.  does it support of the screen were to scroll?
Title: Re: ChainFire Pinball Library
Post by: DJ Omnimaga on February 12, 2011, 07:41:19 pm
O.O
/me wonders if Builderboy is planning to port Acelgoyobis or Sonic to Axe...
Title: Re: ChainFire Pinball Library
Post by: jnesselr on February 12, 2011, 10:17:59 pm
O.O
/me wonders if Builderboy is planning to port Acelgoyobis or Sonic to Axe...
Noting all the things he's been doing with physics, I wouldn't doubt it.
Title: Re: ChainFire Pinball Library
Post by: ztrumpet on February 12, 2011, 10:27:58 pm
O.O
/me wonders if Builderboy is planning to port Acelgoyobis or Sonic to Axe...
Noting all the things he's been doing with physics, I wouldn't doubt it.
Nah, it's neither of these two...
(The hints stop there... maybe)
Title: Re: ChainFire Pinball Library
Post by: AngelFish on February 12, 2011, 10:31:23 pm
And now for color physics...  :P
Title: Re: ChainFire Pinball Library
Post by: jnesselr on February 12, 2011, 10:31:54 pm
And now for color physics...  :P
Oh, so you will give us screenies soon, right....
Title: Re: ChainFire Pinball Library
Post by: AngelFish on February 12, 2011, 10:32:36 pm
...on the TI-84+
Title: Re: ChainFire Pinball Library
Post by: jnesselr on February 12, 2011, 10:33:03 pm
...on the TI-84+
oh. No, on the prizm. Like. now...
Title: Re: ChainFire Pinball Library
Post by: AngelFish on February 12, 2011, 10:33:56 pm
I need the screen address first. Once I have that, then I can start writing and testing physics routines.
Title: Re: ChainFire Pinball Library
Post by: Builderboy on February 13, 2011, 01:14:18 am
Nah, it's neither of these two...
(The hints stop there... maybe)

Why whatever could you mean ztrumpet, its almost as if you are implying you know something... ;)
Title: Re: ChainFire Pinball Library
Post by: DJ Omnimaga on February 13, 2011, 03:58:29 am
:O
/me pokes Builderboy for working again on some games
Title: Re: ChainFire Pinball Library
Post by: Munchor on February 13, 2011, 10:23:26 am
This looks awesome Deep Thought! Pure epic! It looks so real (the physics)!
Title: Re: ChainFire Pinball Library
Post by: Builderboy on February 13, 2011, 12:41:15 pm
Deep Thought?
Title: Re: ChainFire Pinball Library
Post by: Munchor on February 13, 2011, 02:58:34 pm
Deep Thought?

Builderboy* Yeah, sorry, we were talking on IRC at the time.
Title: Re: ChainFire Pinball Library
Post by: Builderboy on February 13, 2011, 02:59:06 pm
Hahah gotcha, thanks :D
Title: Re: ChainFire Pinball Library
Post by: DJ Omnimaga on August 29, 2011, 11:21:51 pm
So I wonder if anyone could make Sonic with this? Also would Nspire Lua be fast enough for this?
Title: Re: ChainFire Pinball Library
Post by: shmibs on August 30, 2011, 12:32:46 am
someone probably could, but i don't know how well it would work with screen scrolling. that would probably slow things down considerably. there's not really any reason for calc sonic to have physics this advanced (eg, all the sticking to walls stuff). it could just determine by your speed upon entering a loop/half loop or something whether or not you are going fast enough to make it around.
Title: Re: ChainFire Pinball Library
Post by: Builderboy on August 30, 2011, 01:40:58 am
This is not the engine you would want to use, that one would be this:

http://ourl.ca/7764

Which is a lot less computationally intensive than chainFire, and it replicates the physics of sonic using the specific algorithms and method that the original sonic used!  And adding scrolling wouldn't harm the physics calculations in the slightest, it would just add the computational time of doing the actual scrolling.
Title: Re: ChainFire Pinball Library
Post by: DJ Omnimaga on October 17, 2011, 02:30:05 am
Ah ok thanks for the info. I guess at such small resolution not as much precision is needed indeed. Now for a Sonic project, someone would have to make the tiles and sprites, though. :P