pingus-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inconsistent fall survival & jumpers bouncing off


From: Gervase Lam
Subject: Re: Inconsistent fall survival & jumpers bouncing off
Date: Mon, 3 Nov 2003 23:47:49 +0000

> Date: Wed, 15 Oct 2003 00:09:41 +0100
> From: Gervase Lam <address@hidden>
> Subject: Re: Inconsistent fall survival & jumpers bouncing off

> One thing I realised before I started tidying up the PinguMidAirMover
> was that it can apply to any type of object.  So long as the object gets
> affected by gravity, it can use the mover.  So I've renamed it
> GravitationalMover.
>
> Also, I noticed that on each game update, the code uses a constant
> velocity in order to update the position of a falling Pingu.  This is
> not physically accurate, though it is better than it used to be.
>
> This evening, I came up with a very simple solution that is more
> accurate. As it is more accurate, that means it SHOULD be able to solve
> the problem of Pingus dying "inconsistently" from various fall heights.

Phew!  At last.  I have finished the GravitationalMover.  In the end, I 
decided to revert back to the GravitationalMover using the LinearMover.  
Doing otherwise in order to increase the accuracy in the way mentioned 
meant that things got more fiddly.

Initially, I had the GravitationalMover making objects bounce around with 
the mover in one update, with appropriate damping of the bounce.  The 
GravitationalMover would appropriately stop the bouncing around if the 
Pingu touches water, for example.  However, this meant that the Collider 
object that is supplied to the Mover with really had to be very 
sophisticated.

Though something sophisticated isn't really needed for a Pingu, for other 
objects that are moved by Movers, this might not be so.

For example, a large bouncy ball could be introduced in Pingus, which 
needs to be moved by Movers.  Depending on where around the ball a 
collision takes place determines how and at what angle it bounces.  Pingus 
only needs collisions on the sides, top and bottom to be handled.

Therefore, I decided to make the GravitationalMover stop when it collides 
with something.  It is then up to the function using the Mover to decided 
what damping is required by appropriately reducing the velocity of the 
object etc, etc...

Initially, I had Bombers using the GravitationalMover with an upthrust 
that increased as the Bomber inflated, thereby eventually completely 
counteracting gravity.  Its bounciness would also increase as it inflated.

However, it didn't look right when a Floater changed into a Bomber.  In 
the beginning, the Bomber would immediately start plummeting downwards as 
it was strongly affected by gravity.  However, the more it inflated, the 
more upthrust it got, which stabilised the velocity.  Though the Bomber 
acted correctly, it didn't look great.

What I decided to do is as soon as the Pingu turns into a Bomber, it has 
an upthrust that cancels out gravity.  Therefore, the velocity of a Bomber 
is constant.

In other words, the velocity never increases or decreases but stays the 
same as it was immediately before the Pingu changed into a Bomber.  Since 
a Floater moves downwards at 1 pixel per update, therefore when it changes 
into a Bomber, it will still moves downwards at 1 pixel per update.

Also, I have made Bombers bounce off the walls, ceiling and floor like a 
balloon that is as bouncy as Jumpers bouncing off walls.  The bounciness 
is constant.

One thing that I think I would have been handy while I was doing the 
GravitationalMover was to have an integer version of the Vector class.  
Would it be reasonable to have it as a template so that you could have 
integer and float Vectors?  Or another way to do it is to have a Vector 
base class and from it derive VectorFloat and VectorInt classes.

The current Vector class can, for example, return rotated Vectors by any 
angle or unit vectors, both of which are likely to make the x, y and z 
components fractional.  These things should  remain as float vectors, even 
when both operations are applied to an integer vector.

The reason I ask is because I think it is handy to pass the co-ordinates 
of where a Pingu collided using a Vector.

When using the current Vector class, in order to find out whether the 
Pingu moved upwards or downwards into a collision pixel, I had to static 
cast them.  This is quite awkward, as can be seen in "bomber.cxx", which 
contains a combination of the static casts used in "faller.cxx".

Now, finally, what cvs diff commands should I use considering that there 
are now two code branches of Pingus?  One is for ClanLib 0.6 while the 
other is for ClanLib 0.7.  I am currently on the ClanLib 0.6 version.  
What should I do?

Thanks,
Gervase.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]