[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/actions bomber.cxx,1.17,1.18 slider.c
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/actions bomber.cxx,1.17,1.18 slider.cxx,1.13,1.14 |
Date: |
12 Oct 2002 00:24:28 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/actions
In directory dark:/tmp/cvs-serv9541/actions
Modified Files:
bomber.cxx slider.cxx
Log Message:
removed PinguAction* from the public API
- added Gervases experimental bomber code
Index: bomber.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/bomber.cxx,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- bomber.cxx 6 Oct 2002 23:14:33 -0000 1.17
+++ bomber.cxx 12 Oct 2002 00:24:26 -0000 1.18
@@ -17,6 +17,10 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#include <math.h>
+#include <iostream>
+#include "../debug.hxx"
+#include "../globals.hxx"
#include "../col_map.hxx"
#include "../force_vector.hxx"
#include "../graphic_context.hxx"
@@ -84,11 +88,64 @@
{
sprite.update ();
- // Make a Bomber act like a Floater
- pingu->set_velocity(Vector(0.0, 0.0));
+ Vector newp = pingu->get_velocity();
+
+ // Subtract velocity due to the fact that the Pingu is ballooning up before
+ // applying it.
+ newp.y -= 1.0f;
+
+ // Apply all forces
+ pingu->set_velocity(ForcesHolder::apply_forces(pingu->get_pos(), newp));
+
+ newp = pingu->get_velocity();
+
+ //pout(PINGUS_DEBUG_ACTIONS) << "x" << newp.x << std::endl;
+ //pout(PINGUS_DEBUG_ACTIONS) << "y" << newp.y << std::endl;
- if (rel_getpixel(0, -1) == Groundtype::GP_NOTHING)
- pingu->set_y(pingu->get_y() + 1);
+ // If going right
+ if (newp.x > 0)
+ {
+ // Move Pingu gradually to the right. As the velocity may be a fraction,
+ // stop within 1 unit.
+ while (newp.x >= 1 && rel_getpixel(1, 0) == Groundtype::GP_NOTHING)
+ {
+ pingu->set_x(pingu->get_x() + 1);
+ newp.x--;
+ }
+ }
+ else
+ {
+ // Move Pingu gradually to the left. As the velocity may be a fraction,
+ // stop within 1 unit.
+ while (newp.x <= -1 && rel_getpixel(-1, 0) == Groundtype::GP_NOTHING)
+ {
+ pingu->set_x(pingu->get_x() - 1);
+ newp.x++;
+ }
+ }
+
+ // If going down
+ if (newp.y > 0)
+ {
+ // Move Pingu down gradually. As the velocity may be a fraction,
+ // stop within 1 unit.
+ while (newp.y >= 1 && rel_getpixel(0, -1) == Groundtype::GP_NOTHING)
+ {
+ pingu->set_y(pingu->get_y() + 1);
+ newp.y--;
+ }
+ }
+ else
+ {
+ // Move Pingu up gradually. As the velocity may be a fraction,
+ // stop within 1 unit.
+ while (newp.y <= -1
+ && rel_getpixel(0, pingu_height) == Groundtype::GP_NOTHING)
+ {
+ pingu->set_y(pingu->get_y() - 1);
+ newp.y++;
+ }
+ }
if (sprite.get_frame () > 9 && !sound_played) {
WorldObj::get_world()->play_wav("sounds/plop.wav", pingu->get_pos ());
Index: slider.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/slider.cxx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- slider.cxx 4 Oct 2002 11:38:29 -0000 1.13
+++ slider.cxx 12 Oct 2002 00:24:26 -0000 1.14
@@ -63,12 +63,16 @@
}
pingu->set_action(Actions::Walker);
+ return;
}
}
speed -= 7 * 0.025f;
if (speed < 1)
- pingu->set_action(Actions::Walker);
+ {
+ pingu->set_action(Actions::Walker);
+ return;
+ }
}
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/actions bomber.cxx,1.17,1.18 slider.cxx,1.13,1.14,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjsdata surface_background_data.cxx,1.4,1.5
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs exit.cxx,1.5,1.6 fake_exit.cxx,1.9,1.10 hammer.cxx,1.9,1.10 laser_exit.cxx,1.8,1.9 smasher.cxx,1.12,1.13
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjsdata surface_background_data.cxx,1.4,1.5
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs exit.cxx,1.5,1.6 fake_exit.cxx,1.9,1.10 hammer.cxx,1.9,1.10 laser_exit.cxx,1.8,1.9 smasher.cxx,1.12,1.13
- Index(es):