Tried to take input tick into account in updatePosition but it still doesn't seem to work
--- a/src/Graphics.cc Mon Dec 08 00:16:43 2008 +0000
+++ b/src/Graphics.cc Mon Dec 08 00:36:24 2008 +0000
@@ -20,7 +20,7 @@
update_timer.start();
}
-void Graphics::check_input (void) {
+void Graphics::check_input (TimeMS dt) {
LocalPlayer *player;
PlayerInput input_mask = 0;
@@ -47,7 +47,7 @@
// apply input if there was any
if (input_mask)
- player->handleInput(input_mask);
+ player->handleInput(input_mask, dt);
}
static PixelDimension value_between (PixelDimension low, PixelDimension value, PixelDimension high) {
@@ -92,7 +92,7 @@
void Graphics::on_update (TimeMS tick_length) {
// check keyboard input
- check_input();
+ check_input(tick_length);
// redraw display
do_redraw();
--- a/src/Graphics.hh Mon Dec 08 00:16:43 2008 +0000
+++ b/src/Graphics.hh Mon Dec 08 00:36:24 2008 +0000
@@ -38,7 +38,7 @@
CL_Font& getSimpleFont (void) { return simple_font; }
private:
- void check_input (void);
+ void check_input (TimeMS dt);
void do_redraw (void);
void on_update (TimeMS tick_length);
--- a/src/Network/Server.cc Mon Dec 08 00:16:43 2008 +0000
+++ b/src/Network/Server.cc Mon Dec 08 00:36:24 2008 +0000
@@ -186,7 +186,7 @@
// Engine::log(INFO, "server_player.on_input") << "player=" << obj << ", old_pos=" << position << ", input=" << input;
// apply input
- handleInput(input);
+ handleInput(input, 10);
// send position update
send_position_update();
--- a/src/PhysicsObject.cc Mon Dec 08 00:16:43 2008 +0000
+++ b/src/PhysicsObject.cc Mon Dec 08 00:36:24 2008 +0000
@@ -133,8 +133,8 @@
Force total;
while (!forceq.empty()) {
force = forceq.front();
- if (force.second > PHYSICS_TICK_MS) {
- force.second -= PHYSICS_TICK_MS;
+ if (force.second > dt) {
+ force.second -= dt;
newfq.push(force);
}
total += force.first;
--- a/src/Player.cc Mon Dec 08 00:16:43 2008 +0000
+++ b/src/Player.cc Mon Dec 08 00:36:24 2008 +0000
@@ -107,7 +107,7 @@
handleChangeWeapon((weapons.size() + selectedWeapon + delta) % weapons.size());
}
-void LocalPlayer::handleInput (PlayerInput input) {
+void LocalPlayer::handleInput (PlayerInput input, TimeMS dt) {
// Movement force, vertical is always zero
Vector move_force = Vector(0, 0);
@@ -190,7 +190,7 @@
// apply force
if (!move_force.zero())
- applyForce(move_force);
+ applyForce(move_force, dt);
}
Weapon* Player::getCurrentWeapon() {
--- a/src/Player.hh Mon Dec 08 00:16:43 2008 +0000
+++ b/src/Player.hh Mon Dec 08 00:36:24 2008 +0000
@@ -16,26 +16,26 @@
class Player : public PhysicsObject {
friend class Rope;
- public:
- GameState &state;
-
- protected:
- // XXX: not used
- bool visible;
-
- // our weapons
- std::vector<Weapon*> weapons;
+public:
+ GameState &state;
- // the index of the currently selected weapon
- unsigned int selectedWeapon;
+protected:
+ // XXX: not used
+ bool visible;
+
+ // our weapons
+ std::vector<Weapon*> weapons;
+
+ // the index of the currently selected weapon
+ unsigned int selectedWeapon;
- // we have a rope
- Rope rope;
+ // we have a rope
+ Rope rope;
- // XXX: hmm... updated where?
- int animation_step;
+ // XXX: hmm... updated where?
+ int animation_step;
- /**
+ /**
* Default constructor for use with virtual inheritance... it's not defined, and must not be called
*/
Player (void);
@@ -44,75 +44,75 @@
* Initialize params, and add ourselves to GameState
*/
Player (GameState &state, Vector position, bool visible);
-
+
/**
* Remove player from state players list
*/
~Player (void);
- /*
- * Used by the network code to execute various actions
- */
- virtual void handleDig (Vector position, float radius);
- virtual void handleCreateProjectile (Weapon *weapon, Vector position, Vector velocity);
- virtual void handleChangeWeapon (unsigned int weaponIndex);
-
- // Called by rope to handle state changes, these don't do anything by default
- virtual void handleRopeState (RopeState state);
- virtual void handleRopeLength (float length);
-
- /*
- * The currently selected weapon
- */
- Weapon* getCurrentWeapon();
+ /*
+ * Used by the network code to execute various actions
+ */
+ virtual void handleDig (Vector position, float radius);
+ virtual void handleCreateProjectile (Weapon *weapon, Vector position, Vector velocity);
+ virtual void handleChangeWeapon (unsigned int weaponIndex);
- public:
- /*
- * Prints random things via Engine::log
- */
- void printDebugInfo ();
+ // Called by rope to handle state changes, these don't do anything by default
+ virtual void handleRopeState (RopeState state);
+ virtual void handleRopeLength (float length);
+
+ /*
+ * The currently selected weapon
+ */
+ Weapon* getCurrentWeapon();
- /*
- * Overrides PhysicsObject::tick to also advance game state
- */
- virtual void tick (TimeMS dt);
+public:
+ /*
+ * Prints random things via Engine::log
+ */
+ void printDebugInfo ();
- /*
- * Drawing requires the skin texture, which is loaded on-demand when draw is called
- */
- static bool skin_loaded;
- static CL_Surface skin_surface;
- virtual void draw (Graphics *g, PixelCoordinate camera);
+ /*
+ * Overrides PhysicsObject::tick to also advance game state
+ */
+ virtual void tick (TimeMS dt);
+
+ /*
+ * Drawing requires the skin texture, which is loaded on-demand when draw is called
+ */
+ static bool skin_loaded;
+ static CL_Surface skin_surface;
+ virtual void draw (Graphics *g, PixelCoordinate camera);
};
class LocalPlayer : public virtual Player {
- private:
- /*
- * Calculates projectil position/velocity and calls handleCreateProjectile
- */
- void fireWeapon (Weapon *weapon);
+private:
+ /*
+ * Calculates projectil position/velocity and calls handleCreateProjectile
+ */
+ void fireWeapon (Weapon *weapon);
- /*
- * Change weapon index, should be negative or positive 1
- */
- void changeWeapon (int delta);
+ /*
+ * Change weapon index, should be negative or positive 1
+ */
+ void changeWeapon (int delta);
- public:
- /*
- * Called to invoke some action on this player that we control, either by Graphics or NetworkServer.
- *
- * NetworkClientLocalPlayer overrides this to send the input to the server, which then handles it
- */
- virtual void handleInput (PlayerInput input);
+public:
+ /*
+ * Called to invoke some action on this player that we control, either by Graphics or NetworkServer.
+ *
+ * NetworkClientLocalPlayer overrides this to send the input to the server, which then handles it
+ */
+ virtual void handleInput (PlayerInput input, TimeMS dt);
- /*
- * As Player, but also draws the current weapon name if displayWeapon
- */
- virtual void draw (Graphics *g, bool displayWeapon, PixelCoordinate camera);
+ /*
+ * As Player, but also draws the current weapon name if displayWeapon
+ */
+ virtual void draw (Graphics *g, bool displayWeapon, PixelCoordinate camera);
};
class RemotePlayer : public virtual Player {
- protected:
+protected:
};
--- a/src/Weapons.cc Mon Dec 08 00:16:43 2008 +0000
+++ b/src/Weapons.cc Mon Dec 08 00:36:24 2008 +0000
@@ -11,7 +11,7 @@
std::string name;
} WEAPON_PARAMS[] = {
/* age speed recoil expRadius radius reloadTime name */
- { 10000, 5 * 80 + 50, 0 * 5 + 4000, 0 * 6 + 5, 1, 0 * 100 + 50, "Weapon 1" },
+ { 10000, 5 * 80 + 50, 0 * 5 + 10000, 0 * 6 + 5, 1, 0 * 100 + 50, "Weapon 1" },
{ 10000, 4 * 80 + 50, 2 * 5 + 5, 1 * 6 + 5, 2, 1 * 100 + 50, "Weapon 2" },
{ 10000, 3 * 80 + 50, 3 * 5 + 5, 2 * 6 + 5, 3, 2 * 100 + 50, "Weapon 3" },
{ 10000, 2 * 80 + 50, 4 * 5 + 5, 3 * 6 + 5, 4, 3 * 100 + 50, "Weapon 4" },