Rectangles and circles

Advanced game related topics
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Rectangles and circles

Post by Psychophanta »

Not a game, but if i have time i will do it because i have new ideas.
At the moment, you can play a bit (you manage a ball using mouse):

Get here
And also may be you get new ideas.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

An interesting derivation from your mechanics collision simulation.

Keep them coming. Interesting, informative and FUN. :D

cheers
..::Origin::..
Enthusiast
Enthusiast
Posts: 125
Joined: Sat Jun 17, 2006 3:15 pm

Post by ..::Origin::.. »

Wow, nice, fast, Accurate. Great work Psycho.

Quite amazing, i have no skill with physics what-so ever... Best i've done recently was to determine if something was inside a invisibly drawn rectangle.. One line of code, but it worked so i was happy! Lol!

Nice work, - ..::Origin::..
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post by djes »

Terrific! :P
Anonymous

Post by Anonymous »

Excelent :D ! Nice work, thank for shared :wink:

@++
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Thank you all :D
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Michael Vogel
Addict
Addict
Posts: 2811
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Post by Michael Vogel »

Great - but I had to add some definitions to get rid of some error messages (PB4)...

I added these names:
StaticRubCoefficient.d
VEfectiva.d

...after these definitions:
Structure Ball Extends Masa
Structure Capsule Extends Masa
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

Nice. Your forte, Pyscho.
Dare2 cut down to size
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Michael Vogel wrote:I had to add some definitions to get rid of some error messages (PB4)...
How? The code is PB4 plug&play! How is it possible? :o
The .d is already done in the structures, etc.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post by benny »

Outstanding work, psycho :!: :shock:
regards,
benny!
-
pe0ple ar3 str4nge!!!
User avatar
Michael Vogel
Addict
Addict
Posts: 2811
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Post by Michael Vogel »

Psychophanta wrote:
Michael Vogel wrote:I had to add some definitions to get rid of some error messages (PB4)...
How? The code is PB4 plug&play! How is it possible? :o
The .d is already done in the structures, etc.
My error, I clicked on Get here, got the source text in the browser, selected all text and pasted it into the PB IDE - the "missing" definition is then behind a comment of the previous line...

Sometimes a fast cut and paste is not the best way... :cry:
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Oops! you are right, that's wierd!
So, just download it to you computer, and then rename to .pb extension instead of .txt one.
(I will never upload a thing without being compressed, grrr).

Thank you Benny and Dare, the best part is not to find it nice, but to know it is a cpu faithful real mechanics simulation. :)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Anonymous

Post by Anonymous »

do you plan to make a library ? :D

With easy control ?

ex : Make_Bouding_Box(x1,y1,w,l)


:wink:
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Cpl.Bator wrote:do you plan to make a library ? :D

With easy control ?

ex : Make_Bouding_Box(x1,y1,w,l)
:wink:
I have not such plan, because there is a big difference for real mechanic simulation (which should be fine faithful with the real world) and simulations for games, etc.
I think there is too hard besides of a nonsense to make a lib of funtions for real mechanics simulations for games and general programming. That lib should be good for technical and scientific purposes.

However, the function you mention is already done in the code (it is the heart of all the code)

Code: Select all

ParticleAndBarbellShock(l=0.1,R=0.65,W=0.91,m1=0.3411,m2=0.1411,V1=0.0,V2=0.0,e=1.0,K=/3.0)
where l is the lengh (from the barbell center) where the particle collides.
R is the half lenght of the barbell.
W is the omega (angular speed) at which the barbell is rotating before collision.
m1: mass of the particle
m2: mass of the barbell
V1: particle linear speed before collision
V2: barbell linear speed before collision (refered to the center of barbell, of course).
e is a constant from 0 to 1 which defines the features of the collision (1 => total elastic: no kinetic energy is transformed in the process; 0 => all the initial kinetic energy is transformed in deformation and heat, and objects don't bound, but after collision it remains stopped one respect to the other). The case of a 2 cars collision would be about an e=0.2 or so; and for billiards would be about e=0.99 . e=1 is an ideal situation.
K is a factor for the Inertial momentum; the factor depends on the geometry of the rotating object [1/3 for a barbell (considering its half-lenght as its radius), 1/3 for a rectangle (considering its half-diagonal as its radius), 1/2 for a disc, 2/5 for a sphere... etc. ].
NOTE that the function outputs the new omega after collision, the new V1 , and the new V2.

As said, that function is the heart of the code, but i had to translate a particle-barbell collision to a particle-rectangle collision, that is: GoParticleAndBarbell(). And that's what really caused me hard pain and headache. But finally i did it.

EDIT: After all, besides of all, you need to tell to the box what are the items which will collide with it and what aren't; you need to detect the collision, which is easy but large; you should give certain properties for the collision to the box; etc.
Thus, you have the code, which is a good resource to do things :wink:
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Anonymous

Post by Anonymous »

Ok, thanks.

Do you have a good link for 2D games physics ? , because i'm interesting for (re)make my pseudo "Sonic" game.
I've already start it, but , physics blocks me at coding... :cry:

Oct05-Sonic demo

I don't want use an "prefab engine"
Post Reply