--- a/src/Player.cc Sat Dec 06 22:36:38 2008 +0000
+++ b/src/Player.cc Sat Dec 06 22:47:08 2008 +0000
@@ -1,6 +1,7 @@
+#include "Player.hh"
#include "Engine.hh"
-#include "Player.hh"
+#include "Graphics.hh"
#include <cstdlib>
#include <ClanLib/display.h>
@@ -139,17 +140,10 @@
// XXX: currently not network safe
if (input & INPUT_CHANGE) {
- if (changing) {
+ selectedWeapon = (selectedWeapon + 1) % arsenal.size();
+ Engine::log(DEBUG, "player.input ") << "changed weapon to " << selectedWeapon;
+ }
- } else {
- changing = true;
- selectedWeapon = (selectedWeapon + 1) % arsenal.size();
- Engine::log(DEBUG, "Player.cc:input ") << "changed weapon " << selectedWeapon;
- }
- } else {
- changing = false;
- }
-
// validate shoot events, and then outsource to handleShoot so Network can intercept it
if (input & INPUT_SHOOT && getWeapon().canShoot())
fireWeapon(getWeapon());
@@ -183,7 +177,9 @@
return arsenal[selectedWeapon % arsenal.size()];
}
-void Player::draw (CL_GraphicContext *gc) {
+void Player::draw (Graphics *g) {
+ CL_GraphicContext *gc = g->get_gc();
+
int aim_img_idx = (int)((1 - (getAim()+KG_PI/2)/KG_PI)*img_num_aim);
int step_img_idx = animation_step%img_num_step;
@@ -228,6 +224,21 @@
y - std::sin(aim)*chlen,
CL_Color::black);
}
+
+ rope.draw(g);
}
+void LocalPlayer::draw (Graphics *g, bool displayWeapon) {
+ // superclass draw
+ Player::draw(g);
+ // display weapon name?
+ if (displayWeapon) {
+ g->getSimpleFont().draw(
+ position.x - g->getSimpleFont().get_width(getWeapon().getName()) / 2,
+ position.y + 10,
+ getWeapon().getName(),
+ g->get_gc()
+ );
+ }
+}