Author Topic: ChainFire Pinball Library  (Read 15636 times)

0 Members and 1 Guest are viewing this topic.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
ChainFire Pinball Library
« 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

« Last Edit: February 12, 2011, 01:36:06 pm by Builderboy »

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: ChainFire Pinball Library
« Reply #1 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.
In-progress: Graviter (...)

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: ChainFire Pinball Library
« Reply #2 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:
« Last Edit: February 12, 2011, 02:33:12 am by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: ChainFire Pinball Library
« Reply #3 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.

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: ChainFire Pinball Library
« Reply #4 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
Vy'o'us pleorsdti thl'e gjaemue

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: ChainFire Pinball Library
« Reply #5 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. ^^

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: ChainFire Pinball Library
« Reply #6 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 ;)

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: ChainFire Pinball Library
« Reply #7 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
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: ChainFire Pinball Library
« Reply #8 on: February 12, 2011, 03:55:41 am »
What do you mean?

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: ChainFire Pinball Library
« Reply #9 on: February 12, 2011, 04:27:08 am »
Is that like a 2d modeling engine to draw polygons on the screen?

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: ChainFire Pinball Library
« Reply #10 on: February 12, 2011, 04:33:51 am »
Well, I was hoping for something like a 3D physics engine...

j/k
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: ChainFire Pinball Library
« Reply #11 on: February 12, 2011, 07:55:54 am »
Cool stuff as always Builderboy! =)

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: ChainFire Pinball Library
« Reply #12 on: February 12, 2011, 09:27:38 am »
Looks great!  It's really fun to play with. ;D

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: ChainFire Pinball Library
« Reply #13 on: February 12, 2011, 12:49:38 pm »
I can't seem to find a download for this.  Is there one yet?

Offline Madskillz

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 488
  • Rating: +32/-2
    • View Profile
Re: ChainFire Pinball Library
« Reply #14 on: February 12, 2011, 12:51:07 pm »
As always the physics look awesome.

Don't think there is a download yet graphmastur