1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
#ifndef header_fighter
#define header_fighter
#include <ClanLib/core.h>
#include "gameobject.h"
class Player;
class Fighter : public GameObject
{
// Construction:
public:
Fighter(World *world, Player *owner);
// Server constructor.
Fighter(World *world, CL_NetObject netobj);
// Client constructor.
virtual ~Fighter();
// Attributes:
public:
float get_position_x() const;
float get_position_y() const;
float get_direction() const;
float get_speed() const;
bool local_owner() const;
// Operations:
public:
void set_position_x(float pos);
void set_position_y(float pos);
void set_direction(float dir);
void rotate(float degrees);
void set_speed(float speed);
void set_keys(bool keyAccel, bool keyTurnLeft, bool keyTurnRight);
//!Overrideables:
public:
virtual void update(float time_elapsed);
virtual void write_full_update(CL_OutputSource &message);
virtual void read_full_update(CL_InputSource &message);
virtual void write_tick_update(CL_OutputSource &message);
virtual void read_tick_update(CL_InputSource &message);
// Implementation:
protected:
void init();
void read_talkback_position(const CL_NetComputer &computer, CL_InputSource &message);
void write_talkback_position(CL_OutputSource &message);
void send_talkback_position();
enum
{
talkback_position = 0
};
float position_x;
float position_y;
float angle;
float speed;
bool key_accel;
bool key_turn_left;
bool key_turn_right;
int last_update;
Player *owner;
CL_Slot slot_read_talkback_position;
};
#endif
|