src/Player.hh
author terom
Sat, 06 Dec 2008 22:47:08 +0000
changeset 233 ff4ecea83cf5
parent 228 dbc1bb7a98b5
child 235 0a0c729365ee
permissions -rw-r--r--
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
     1
#ifndef PLAYER_HH
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
     2
#define PLAYER_HH
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
     3
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
     4
class Player;
199
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 198
diff changeset
     5
class LocalPlayer;
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 198
diff changeset
     6
class RemotePlayer;
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
     7
233
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 228
diff changeset
     8
#include "Weapon.hh"
199
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 198
diff changeset
     9
#include "GameState.hh"
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    10
#include "PhysicsObject.hh"
205
905028e58ed1 implement a new tick-timer that doesn't suck
terom
parents: 200
diff changeset
    11
#include "Input.hh"
225
22ecb9cb9245 Rope can be drawn.
ekku
parents: 223
diff changeset
    12
#include "Rope.hh"
233
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 228
diff changeset
    13
#include "GraphicsPointer.hh"
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    14
#include <vector>
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    15
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    16
class Player : public PhysicsObject {
228
dbc1bb7a98b5 Rope has forces
ekku
parents: 225
diff changeset
    17
    friend class Rope;
dbc1bb7a98b5 Rope has forces
ekku
parents: 225
diff changeset
    18
222
293ddf4c067d reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents: 221
diff changeset
    19
    public:
293ddf4c067d reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents: 221
diff changeset
    20
        GameState &state;
293ddf4c067d reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents: 221
diff changeset
    21
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    22
    protected:
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    23
        bool visible;
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    24
        std::vector<Weapon> arsenal;
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    25
        unsigned int selectedWeapon; //unsigned for x%sW not to fail
213
5bd5afab4673 some stuff to Weapon and shoot
nireco
parents: 212
diff changeset
    26
        bool changing;
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    27
225
22ecb9cb9245 Rope can be drawn.
ekku
parents: 223
diff changeset
    28
        Rope rope;
219
ec472f8ac482 fixed walkingspeed and improved drawing
nireco
parents: 215
diff changeset
    29
        int animation_step;
ec472f8ac482 fixed walkingspeed and improved drawing
nireco
parents: 215
diff changeset
    30
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    31
        // default constructor for use with virtual inheritance... it's not defined
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    32
        Player (void);
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    33
        Player (GameState &state, Vector position, bool visible); 
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    34
        
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    35
        // used by the network code to execute actions for players
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    36
        virtual void handleDig (Vector position, float radius);
223
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    37
        virtual void handleCreateProjectile (Weapon &weapon, Vector position, Vector velocity);
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    38
        
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    39
        /*
223
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    40
         * The currently selected weapon
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    41
         */
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    42
        Weapon& getWeapon();
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    43
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    44
    public:
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    45
        /*
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    46
         * Prints random things via Engine::log
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    47
         */
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    48
        void printDebugInfo ();
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    49
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    50
        /*
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    51
         * Overrides PhysicsObject::tick to also advance game state
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    52
         */
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    53
        virtual void tick (TimeMS dt);
220
1c92222af6d3 use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents: 219
diff changeset
    54
1c92222af6d3 use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents: 219
diff changeset
    55
        /*
1c92222af6d3 use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents: 219
diff changeset
    56
         * Drawing requires the skin texture, which is loaded on-demand when draw is called
1c92222af6d3 use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents: 219
diff changeset
    57
         */
1c92222af6d3 use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents: 219
diff changeset
    58
        static bool skin_loaded;
1c92222af6d3 use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents: 219
diff changeset
    59
        static CL_Surface skin_surface;
233
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 228
diff changeset
    60
        virtual void draw (Graphics *g);
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    61
};
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    62
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    63
class LocalPlayer : public virtual Player {
223
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    64
    private:
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    65
        void fireWeapon (Weapon &weapon);
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
    66
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    67
    public:
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    68
        /*
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    69
         * Called to invoke some action on this player that we control, either by Graphics or NetworkServer.
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    70
         *
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    71
         * NetworkClientLocalPlayer overrides this to send the input to the server, which then handles it
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    72
         */
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    73
        virtual void handleInput (PlayerInput input);
233
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 228
diff changeset
    74
        
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 228
diff changeset
    75
        /*
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 228
diff changeset
    76
         * As Player, but also draws the current weapon name if displayWeapon
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 228
diff changeset
    77
         */
ff4ecea83cf5 start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents: 228
diff changeset
    78
        virtual void draw (Graphics *g, bool displayWeapon);
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    79
};
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    80
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    81
class RemotePlayer : public virtual Player {
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    82
    protected:
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    83
};
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    84
 
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    85
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    86
#endif