src/Player.hh
author Tero Marttila <terom@fixme.fi>
Tue, 13 Jan 2009 23:15:47 +0200
changeset 393 5dd4d782cf3a
parent 325 a19c78786d7f
child 411 106aaf6eadfe
permissions -rw-r--r--
a basic implementation of game messages, plus some weird GameStateEvent stuff
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"
308
60f4b55d5713 Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents: 306
diff changeset
     9
#include "Projectile.hh"
199
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 198
diff changeset
    10
#include "GameState.hh"
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    11
#include "PhysicsObject.hh"
205
905028e58ed1 implement a new tick-timer that doesn't suck
terom
parents: 200
diff changeset
    12
#include "Input.hh"
225
22ecb9cb9245 Rope can be drawn.
ekku
parents: 223
diff changeset
    13
#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
    14
#include "GraphicsPointer.hh"
296
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
    15
#include "Types.hh"
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    16
#include <vector>
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    17
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
    18
/**
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
    19
 * A Player is a PhysicsObject that represents a player - a remote client on the server, a local singleplayer player, a
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
    20
 * local network-client player, a remote network-client player, etc.
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
    21
 */
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    22
class Player : public PhysicsObject {
228
dbc1bb7a98b5 Rope has forces
ekku
parents: 225
diff changeset
    23
    friend class Rope;
dbc1bb7a98b5 Rope has forces
ekku
parents: 225
diff changeset
    24
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    25
public:
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    26
    GameState &state;
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    27
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    28
protected:
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    29
    // XXX: not used
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    30
    bool visible;
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    31
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    32
    // our weapons
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    33
    std::vector<Weapon*> weapons;
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    34
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    35
    // the index of the currently selected weapon
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    36
    unsigned int selectedWeapon;
239
550397d9d479 implement network weapon changes and fix weapon firing
terom
parents: 237
diff changeset
    37
        
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    38
    // we have a rope
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    39
    Rope rope;
296
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
    40
    
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
    41
    /** Our current health */
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
    42
    Health health;
295
ekku
parents: 289
diff changeset
    43
300
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    44
    /** Our respawn-timer */
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    45
    Timer respawn_timer;
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    46
    CL_Slot respawn_slot;
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    47
393
5dd4d782cf3a a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents: 325
diff changeset
    48
    // XXX: updated where?
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    49
    int animation_step;
219
ec472f8ac482 fixed walkingspeed and improved drawing
nireco
parents: 215
diff changeset
    50
306
4e774439e2c6 Added kills and deaths parameters. Not updated yet
saiam
parents: 302
diff changeset
    51
    //Player stats
4e774439e2c6 Added kills and deaths parameters. Not updated yet
saiam
parents: 302
diff changeset
    52
    uint16_t kills;
4e774439e2c6 Added kills and deaths parameters. Not updated yet
saiam
parents: 302
diff changeset
    53
    uint16_t deaths;
4e774439e2c6 Added kills and deaths parameters. Not updated yet
saiam
parents: 302
diff changeset
    54
276
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    55
    /**
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    56
     * Default constructor for use with virtual inheritance... it's not defined, and must not be called
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    57
     */
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    58
    Player (void);
274
c35307e8645c add comments, move addPlayer/removePlayer to Player.cc, and refactor Network code to inherit from NetworkObject
terom
parents: 255
diff changeset
    59
276
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    60
    /**
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    61
     * Initialize params, and add ourselves to GameState
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    62
     */
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    63
    Player (GameState &state, Vector position, bool visible); 
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    64
276
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    65
    /**
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    66
     * Remove player from state players list
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    67
     */
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    68
    ~Player (void);
300
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    69
    
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    70
    /**
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    71
     * Move the worm to the given position, removeGround to dig a hole there, and enable ourselves
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    72
     */
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    73
    virtual void spawn (Vector position);
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    74
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    75
    /**
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    76
     * We die. Disable and prepare respawn_timer
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    77
     */
302
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 300
diff changeset
    78
    virtual void die (bool start_timer = true);
300
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    79
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    80
    /**
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    81
     * Calculate a new position for the worm, and respawn there. Also set health back to 100%
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    82
     */
302
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 300
diff changeset
    83
    virtual void respawn (TimeMS dt);
236
0048ba274152 move weapons definition out to Weapons.cc
terom
parents: 235
diff changeset
    84
295
ekku
parents: 289
diff changeset
    85
    /**
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    86
     *  Used by the network code to execute various actions
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    87
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    88
    virtual void handleDig (Vector position, float radius);
276
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    89
    virtual void handleFireWeapon (Weapon *weapon, Vector position, Vector velocity);
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    90
    virtual void handleChangeWeapon (unsigned int weaponIndex);
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    91
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    92
    // Called by rope to handle state changes, these don't do anything by default
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    93
    virtual void handleRopeState (RopeState state);
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    94
    virtual void handleRopeLength (float length);
276
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    95
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    96
public:
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    97
    /**
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    98
     * Called when a weapon is fired, this should apply recoil and reload the weapon
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    99
     */
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
   100
    void weaponFired (Weapon *weapon);
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   101
        
276
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
   102
    /**
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
   103
     * Get the currently selected weapon
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
   104
     *
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
   105
     * @return A pointer to the Weapon object
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   106
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   107
    Weapon* getCurrentWeapon();
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
   108
276
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
   109
    /**
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
   110
     * Get the weapon with the given index
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
   111
     *
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
   112
     * @return A pointer to a Weapon object if found, NULL otherwise
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
   113
     */
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
   114
    Weapon* getWeapon (WeaponID id);
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
   115
295
ekku
parents: 289
diff changeset
   116
    /**
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   117
     * Prints random things via Engine::log
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   118
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   119
    void printDebugInfo ();
220
1c92222af6d3 use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents: 219
diff changeset
   120
295
ekku
parents: 289
diff changeset
   121
    /**
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   122
     * Overrides PhysicsObject::tick to also advance game state
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   123
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   124
    virtual void tick (TimeMS dt);
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   125
295
ekku
parents: 289
diff changeset
   126
    /**
ekku
parents: 289
diff changeset
   127
     * This is called when the player collides with the terrain or with some other object.
ekku
parents: 289
diff changeset
   128
     */
ekku
parents: 289
diff changeset
   129
    void onCollision (Vector collisionPoint, PhysicsObject *other);
ekku
parents: 289
diff changeset
   130
296
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
   131
    /**
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
   132
     * We have been hit by something, and therefore take some damage.
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
   133
     *
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
   134
     * XXX: should this take the Projectile instead or somesuch?
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
   135
     */
308
60f4b55d5713 Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents: 306
diff changeset
   136
    void takeDamage (Projectile *source);
60f4b55d5713 Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents: 306
diff changeset
   137
60f4b55d5713 Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents: 306
diff changeset
   138
    /**
322
f94a5c192097 Rope fixing
ekku
parents: 315
diff changeset
   139
     * If the player has a pivot calculate the force it causes.
f94a5c192097 Rope fixing
ekku
parents: 315
diff changeset
   140
     */
f94a5c192097 Rope fixing
ekku
parents: 315
diff changeset
   141
    Vector getPivotForce (void);
f94a5c192097 Rope fixing
ekku
parents: 315
diff changeset
   142
f94a5c192097 Rope fixing
ekku
parents: 315
diff changeset
   143
    /**
312
10743f190aab info box
nireco
parents: 308
diff changeset
   144
     * Gives player's health in percents from maximum
10743f190aab info box
nireco
parents: 308
diff changeset
   145
     */
10743f190aab info box
nireco
parents: 308
diff changeset
   146
    float getHealthPercent() const;
10743f190aab info box
nireco
parents: 308
diff changeset
   147
10743f190aab info box
nireco
parents: 308
diff changeset
   148
    /**
308
60f4b55d5713 Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents: 306
diff changeset
   149
     * Increment player killcounter by one.
60f4b55d5713 Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents: 306
diff changeset
   150
     */
60f4b55d5713 Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents: 306
diff changeset
   151
    void addKill ();
296
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
   152
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   153
    /*
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   154
     * Drawing requires the skin texture, which is loaded on-demand when draw is called
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   155
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   156
    static bool skin_loaded;
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   157
    static CL_Surface skin_surface;
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   158
    virtual void draw (Graphics *g, PixelCoordinate camera);
296
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
   159
325
a19c78786d7f kills, deaths and weapon name is displayed in right place
nireco
parents: 322
diff changeset
   160
    uint16_t getKills() { return kills; }
a19c78786d7f kills, deaths and weapon name is displayed in right place
nireco
parents: 322
diff changeset
   161
    uint16_t getDeaths() { return deaths; }
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   162
};
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   163
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   164
/**
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   165
 * A LocalPlayer is a Player that we handle input for - so this is our own player on the client/singleplayer, or all
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   166
 * the remote clients on a server - the name is a bit misleading.
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   167
 *
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   168
 * This inherits virtually from Player so that subclasses can also define custom behaviour for the base Player class.
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   169
 */
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
   170
class LocalPlayer : public virtual Player {
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   171
private:
312
10743f190aab info box
nireco
parents: 308
diff changeset
   172
    /**
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   173
     * Calculates projectil position/velocity and calls handleCreateProjectile
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   174
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   175
    void fireWeapon (Weapon *weapon);
237
3d5465bcb67d tweak weapon params and improve weapon changing
terom
parents: 236
diff changeset
   176
        
312
10743f190aab info box
nireco
parents: 308
diff changeset
   177
    /**
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   178
     * Change weapon index, should be negative or positive 1
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   179
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   180
    void changeWeapon (int delta);
223
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
   181
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   182
public:
312
10743f190aab info box
nireco
parents: 308
diff changeset
   183
    /**
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   184
     * Called to invoke some action on this player that we control, either by Graphics or NetworkServer.
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   185
     *
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   186
     * NetworkClientLocalPlayer overrides this to send the input to the server, which then handles it
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   187
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   188
    virtual void handleInput (PlayerInput input, TimeMS dt);
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
   189
        
312
10743f190aab info box
nireco
parents: 308
diff changeset
   190
    /**
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   191
     * As Player, but also draws the current weapon name if displayWeapon
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   192
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   193
    virtual void draw (Graphics *g, bool displayWeapon, PixelCoordinate camera);
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   194
};
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   195
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   196
/**
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   197
 * A RemotePlayer is a Player that we don't handle input for - they are a remote client connected to a remote server.
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   198
 *
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   199
 * This inherits virtually from Player so that subclasses can also define custom behaviour for the base Player class.
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   200
 */
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   201
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
   202
class RemotePlayer : public virtual Player {
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   203
protected:
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   204
};
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   205
 
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   206
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   207
#endif