src/Player.hh
author ekku
Sat, 06 Dec 2008 17:51:19 +0000
changeset 222 293ddf4c067d
parent 221 fbc5db6fce45
child 223 2fcaf54ed37b
permissions -rw-r--r--
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
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
199
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 198
diff changeset
     8
#include "GameState.hh"
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
     9
#include "PhysicsObject.hh"
205
905028e58ed1 implement a new tick-timer that doesn't suck
terom
parents: 200
diff changeset
    10
#include "Input.hh"
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    11
#include "Weapon.hh"
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
    12
//#include "Rope.hh"
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    13
#include <vector>
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    14
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    15
class Player : public PhysicsObject {
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
    16
    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
    17
        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
    18
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    19
    protected:
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    20
        bool visible;
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    21
        std::vector<Weapon> arsenal;
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    22
        unsigned int selectedWeapon; //unsigned for x%sW not to fail
213
5bd5afab4673 some stuff to Weapon and shoot
nireco
parents: 212
diff changeset
    23
        bool changing;
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    24
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
    25
//        Rope rope;
219
ec472f8ac482 fixed walkingspeed and improved drawing
nireco
parents: 215
diff changeset
    26
        int animation_step;
ec472f8ac482 fixed walkingspeed and improved drawing
nireco
parents: 215
diff changeset
    27
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    28
        // 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
    29
        Player (void);
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    30
        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
    31
        
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    32
        // 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
    33
        virtual void handleDig (Vector position, float radius);
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    34
        virtual void handleShoot (Weapon &weapon);
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    35
        
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    36
        /*
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    37
         *
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    38
         */
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    39
        Weapon& getWeapon();
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    40
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    41
    public:
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    42
        /*
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    43
         * Prints random things via Engine::log
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    44
         */
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    45
        void printDebugInfo ();
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    46
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
         * Overrides PhysicsObject::tick to also advance game state
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
        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
    51
1c92222af6d3 use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents: 219
diff changeset
    52
        /*
1c92222af6d3 use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents: 219
diff changeset
    53
         * 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
    54
         */
1c92222af6d3 use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents: 219
diff changeset
    55
        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
    56
        static CL_Surface skin_surface;
215
69de8d9fcc0a image is working.. well.. run it from build/src folder.
nireco
parents: 213
diff changeset
    57
        virtual void draw(CL_GraphicContext* gc);
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    58
};
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    59
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    60
class LocalPlayer : public virtual Player {
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    61
    public:
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    62
        /*
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    63
         * 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
    64
         *
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    65
         * 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
    66
         */
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
    67
        virtual void handleInput (PlayerInput input);
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    68
};
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    69
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    70
class RemotePlayer : public virtual Player {
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
    71
    protected:
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    72
};
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    73
 
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    74
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    75
#endif