image is working.. well.. run it from build/src folder.
--- a/src/Player.cc Sat Dec 06 11:33:07 2008 +0000
+++ b/src/Player.cc Sat Dec 06 12:35:40 2008 +0000
@@ -2,6 +2,11 @@
#include "Player.hh"
#include <cstdlib>
+#include <ClanLib/display.h>
+
+//Player::image = NULL;
+
+//Player::image = CL_Surface("../../pics/skin.png");
Player::Player(GameState &state, Vector position, bool visible) :
PhysicsObject(state.world, PLAYER_MASS, position, Vector(0, 0)), state(state), visible(visible), arsenal(), selectedWeapon(0), changing(false) {
@@ -11,6 +16,10 @@
arsenal.push_back(Weapon(10000, (5-i)*40+30, i*6+5, i*100+50, "asdf"));
}
+// if(Player::image == NULL) {
+// Player::image = CL_PNGProvider::create("../../pics/skin.png");
+// }
+
std::vector<Vector> shape(4);
shape[0] = Vector(0,-9);
shape[1] = Vector(6,0);
@@ -25,9 +34,9 @@
void Player::handleDig (Vector position, float radius) {
Vector unitVectorAim = facingRight ? Vector(std::cos(aim), -std::sin(aim)) :
Vector(-std::cos(aim), -std::sin(aim));
- float shotspeed = 40*PHYSICS_TICK_MS;
+ float shotspeed = 0*PHYSICS_TICK_MS;
Vector shotVelocity = unitVectorAim*shotspeed;
- new Projectile(this->state, this->position, shotVelocity, false, radius, 1);
+ new Projectile(this->state, this->position, shotVelocity, false, radius, 0);
}
@@ -121,3 +130,26 @@
Weapon& Player::getWeapon() {
return arsenal[selectedWeapon%arsenal.size()];
}
+
+void Player::draw(CL_GraphicContext *gc) {
+
+ CL_Surface dimage = CL_Surface("../../pics/skin.png");
+
+ dimage.draw(position.x, position.y, gc);
+
+ const uint16_t chlen = 10;
+ uint16_t x = position.x;
+ uint16_t y = position.y;
+ if (facingRight) {
+ gc->draw_line(x, y,
+ x + std::cos(aim)*chlen,
+ y - std::sin(aim)*chlen,
+ CL_Color::black);
+ } else {
+ gc->draw_line(x, y,
+ x - std::cos(aim)*chlen,
+ y - std::sin(aim)*chlen,
+ CL_Color::black);
+ }
+}
+
--- a/src/Player.hh Sat Dec 06 11:33:07 2008 +0000
+++ b/src/Player.hh Sat Dec 06 12:35:40 2008 +0000
@@ -29,6 +29,9 @@
public:
void debugInfo ();
+ virtual void draw(CL_GraphicContext* gc);
+
+ static CL_Surface image;
};
class LocalPlayer : public virtual Player {