src/Rope.cc
changeset 311 440763821484
parent 305 56799ec8d7be
child 322 f94a5c192097
equal deleted inserted replaced
310:7e0cfc5f0944 311:440763821484
     4 #include "Graphics.hh"
     4 #include "Graphics.hh"
     5 #include <math.h>
     5 #include <math.h>
     6 #include <stdexcept>
     6 #include <stdexcept>
     7 
     7 
     8 Rope::Rope(Player &player) : 
     8 Rope::Rope(Player &player) : 
     9     PhysicsObject(player.state.world, ROPE_MASS, Vector(0,0), Vector(0,0), ROPE, 0.00, false), player(player), state(ROPE_FOLDED), pivotObject(NULL) 
     9     PhysicsObject(player.state.world, ROPE_MASS, Vector(0,0), Vector(0,0), ROPE, 0.00, false), 
       
    10     player(player), 
       
    11     pivotObject(NULL),
       
    12     state(ROPE_FOLDED) 
    10 {
    13 {
    11     // XXX: better shape
    14     // XXX: better shape
    12     std::vector<Vector> shape(4);
    15     std::vector<Vector> shape(4);
    13     shape[0] = Vector(-1, -1);
    16     shape[0] = Vector(-1, -1);
    14     shape[1] = Vector(-1, 1);
    17     shape[1] = Vector(-1, 1);
    36     // inform network
    39     // inform network
    37     player.handleRopeState(state);
    40     player.handleRopeState(state);
    38 }
    41 }
    39 
    42 
    40 void Rope::onCollision (Vector collisionPoint, PhysicsObject *other) {
    43 void Rope::onCollision (Vector collisionPoint, PhysicsObject *other) {
    41 
       
    42     if (other != NULL) {
    44     if (other != NULL) {
    43         if (other->getType() == PLAYER) {
    45         if (other->getType() == PLAYER) {
    44             Player *target = dynamic_cast<Player*>(other);
    46             Player *target = dynamic_cast<Player*>(other);
    45             if (target == &(this->player))
    47             if (target == &(this->player))
    46                 return;
    48                 return;