Page 1 of 2

Rectangles and circles

Posted: Thu Aug 24, 2006 3:50 pm
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.

Posted: Thu Aug 24, 2006 7:16 pm
by rsts
An interesting derivation from your mechanics collision simulation.

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

cheers

Posted: Fri Aug 25, 2006 10:43 am
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::..

Posted: Sat Aug 26, 2006 11:32 am
by djes
Terrific! :P

Posted: Mon Aug 28, 2006 11:56 pm
by Anonymous
Excelent :D ! Nice work, thank for shared :wink:

@++

Posted: Tue Aug 29, 2006 8:16 am
by Psychophanta
Thank you all :D

Posted: Tue Aug 29, 2006 10:02 am
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

Posted: Tue Aug 29, 2006 12:11 pm
by Dare
Nice. Your forte, Pyscho.

Posted: Tue Aug 29, 2006 1:14 pm
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.

Posted: Tue Aug 29, 2006 1:38 pm
by benny
Outstanding work, psycho :!: :shock:

Posted: Wed Aug 30, 2006 12:24 pm
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:

Posted: Wed Aug 30, 2006 12:58 pm
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. :)

Posted: Wed Aug 30, 2006 2:21 pm
by Anonymous
do you plan to make a library ? :D

With easy control ?

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


:wink:

Posted: Wed Aug 30, 2006 4:43 pm
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:

Posted: Wed Aug 30, 2006 5:44 pm
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"