src/Player.hh
author nireco
Sat, 31 Jan 2009 12:33:08 +0200
changeset 443 5d1119729f58
parent 417 c503e0c6a740
permissions -rw-r--r--
worm02 two pics to comment
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"
225
22ecb9cb9245 Rope can be drawn.
ekku
parents: 223
diff changeset
    12
#include "Rope.hh"
296
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
    13
#include "Types.hh"
414
cede5463b845 port Input to new Graphics, still a bit hacky, but everything seems to work now
Tero Marttila <terom@fixme.fi>
parents: 412
diff changeset
    14
#include "Input.hh"
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    15
411
106aaf6eadfe there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents: 393
diff changeset
    16
#include "Graphics/Drawable.hh"
106aaf6eadfe there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents: 393
diff changeset
    17
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    18
#include <vector>
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    19
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
    20
/**
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
    21
 * 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
    22
 * 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
    23
 */
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
    24
class Player : public PhysicsObject {
228
dbc1bb7a98b5 Rope has forces
ekku
parents: 225
diff changeset
    25
    friend class Rope;
dbc1bb7a98b5 Rope has forces
ekku
parents: 225
diff changeset
    26
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    27
public:
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    28
    GameState &state;
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    29
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    30
protected:
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    31
    // 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
    32
    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
    33
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    34
    // 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
    35
    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
    36
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    37
    // 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
    38
    unsigned int selectedWeapon;
239
550397d9d479 implement network weapon changes and fix weapon firing
terom
parents: 237
diff changeset
    39
        
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    40
    // 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
    41
    Rope rope;
296
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
    42
    
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
    43
    /** Our current health */
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
    44
    Health health;
295
ekku
parents: 289
diff changeset
    45
300
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    46
    /** Our respawn-timer */
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    47
    Timer respawn_timer;
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    48
    CL_Slot respawn_slot;
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    49
393
5dd4d782cf3a a basic implementation of game messages, plus some weird GameStateEvent stuff
Tero Marttila <terom@fixme.fi>
parents: 325
diff changeset
    50
    // 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
    51
    int animation_step;
219
ec472f8ac482 fixed walkingspeed and improved drawing
nireco
parents: 215
diff changeset
    52
306
4e774439e2c6 Added kills and deaths parameters. Not updated yet
saiam
parents: 302
diff changeset
    53
    //Player stats
4e774439e2c6 Added kills and deaths parameters. Not updated yet
saiam
parents: 302
diff changeset
    54
    uint16_t kills;
4e774439e2c6 Added kills and deaths parameters. Not updated yet
saiam
parents: 302
diff changeset
    55
    uint16_t deaths;
4e774439e2c6 Added kills and deaths parameters. Not updated yet
saiam
parents: 302
diff changeset
    56
276
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
     * 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
    59
     */
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    60
    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
    61
276
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
     * 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
    64
     */
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    65
    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
    66
276
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
     * 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
    69
     */
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
    70
    ~Player (void);
300
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    71
    
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    72
    /**
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    73
     * 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
    74
     */
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    75
    virtual void spawn (Vector position);
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    76
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    77
    /**
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    78
     * We die. Disable and prepare respawn_timer
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    79
     */
302
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 300
diff changeset
    80
    virtual void die (bool start_timer = true);
300
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    81
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    82
    /**
417183866f35 suicide key and respawning
terom
parents: 296
diff changeset
    83
     * 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
    84
     */
302
e734d8e9bbb5 make spawn/die work over the network
terom
parents: 300
diff changeset
    85
    virtual void respawn (TimeMS dt);
236
0048ba274152 move weapons definition out to Weapons.cc
terom
parents: 235
diff changeset
    86
295
ekku
parents: 289
diff changeset
    87
    /**
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    88
     *  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
    89
     */
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 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
    91
    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
    92
    virtual void handleChangeWeapon (unsigned int weaponIndex);
212
4389c1e6b9b8 Weapon.cc&hh
nireco
parents: 209
diff changeset
    93
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
    94
    // 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
    95
    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
    96
    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
    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
public:
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
     * 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
   101
     */
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
   102
    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
   103
        
276
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
     * 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
   106
     *
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
   107
     * @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
   108
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   109
    Weapon* getCurrentWeapon();
221
fbc5db6fce45 reorganize the weapons code and input handling code
terom
parents: 220
diff changeset
   110
276
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
     * 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
   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
     * @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
   115
     */
87434abc1ba1 ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents: 275
diff changeset
   116
    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
   117
295
ekku
parents: 289
diff changeset
   118
    /**
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   119
     * 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
   120
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   121
    void printDebugInfo ();
220
1c92222af6d3 use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents: 219
diff changeset
   122
295
ekku
parents: 289
diff changeset
   123
    /**
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   124
     * 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
   125
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   126
    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
   127
295
ekku
parents: 289
diff changeset
   128
    /**
ekku
parents: 289
diff changeset
   129
     * This is called when the player collides with the terrain or with some other object.
ekku
parents: 289
diff changeset
   130
     */
ekku
parents: 289
diff changeset
   131
    void onCollision (Vector collisionPoint, PhysicsObject *other);
ekku
parents: 289
diff changeset
   132
296
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
     * 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
   135
     *
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
   136
     * 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
   137
     */
308
60f4b55d5713 Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents: 306
diff changeset
   138
    void takeDamage (Projectile *source);
60f4b55d5713 Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents: 306
diff changeset
   139
60f4b55d5713 Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents: 306
diff changeset
   140
    /**
322
f94a5c192097 Rope fixing
ekku
parents: 315
diff changeset
   141
     * If the player has a pivot calculate the force it causes.
f94a5c192097 Rope fixing
ekku
parents: 315
diff changeset
   142
     */
f94a5c192097 Rope fixing
ekku
parents: 315
diff changeset
   143
    Vector getPivotForce (void);
f94a5c192097 Rope fixing
ekku
parents: 315
diff changeset
   144
f94a5c192097 Rope fixing
ekku
parents: 315
diff changeset
   145
    /**
312
10743f190aab info box
nireco
parents: 308
diff changeset
   146
     * Gives player's health in percents from maximum
10743f190aab info box
nireco
parents: 308
diff changeset
   147
     */
10743f190aab info box
nireco
parents: 308
diff changeset
   148
    float getHealthPercent() const;
10743f190aab info box
nireco
parents: 308
diff changeset
   149
10743f190aab info box
nireco
parents: 308
diff changeset
   150
    /**
308
60f4b55d5713 Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents: 306
diff changeset
   151
     * Increment player killcounter by one.
60f4b55d5713 Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents: 306
diff changeset
   152
     */
60f4b55d5713 Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents: 306
diff changeset
   153
    void addKill ();
296
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
   154
417
c503e0c6a740 support for building without Network/Graphics, although the disable-graphics case is kind of hackish still
Tero Marttila <terom@fixme.fi>
parents: 414
diff changeset
   155
#if GRAPHICS_ENABLED    
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   156
    /*
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   157
     * 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
   158
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   159
    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
   160
    static CL_Surface skin_surface;
411
106aaf6eadfe there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents: 393
diff changeset
   161
106aaf6eadfe there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents: 393
diff changeset
   162
    /**
106aaf6eadfe there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents: 393
diff changeset
   163
     * Draw this player
106aaf6eadfe there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents: 393
diff changeset
   164
     */
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
   165
    virtual void draw (graphics::Display &display, PixelCoordinate camera);
417
c503e0c6a740 support for building without Network/Graphics, although the disable-graphics case is kind of hackish still
Tero Marttila <terom@fixme.fi>
parents: 414
diff changeset
   166
#endif
c503e0c6a740 support for building without Network/Graphics, although the disable-graphics case is kind of hackish still
Tero Marttila <terom@fixme.fi>
parents: 414
diff changeset
   167
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
   168
    /**
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
   169
     * Returns statistics on the number of kills for this player
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
   170
     */
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
   171
    uint16_t getKills() { return kills; }
296
4d3ebaa29430 add separate Types.hh, and fix projectile-worm collisions on network
terom
parents: 295
diff changeset
   172
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
   173
    /**
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
   174
     * Returns statistics on the number of deaths for this player
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
   175
     */
325
a19c78786d7f kills, deaths and weapon name is displayed in right place
nireco
parents: 322
diff changeset
   176
    uint16_t getDeaths() { return deaths; }
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   177
};
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   178
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   179
/**
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   180
 * 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
   181
 * 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
   182
 *
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   183
 * 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
   184
 */
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
   185
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
   186
private:
312
10743f190aab info box
nireco
parents: 308
diff changeset
   187
    /**
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   188
     * 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
   189
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   190
    void fireWeapon (Weapon *weapon);
237
3d5465bcb67d tweak weapon params and improve weapon changing
terom
parents: 236
diff changeset
   191
        
312
10743f190aab info box
nireco
parents: 308
diff changeset
   192
    /**
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   193
     * 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
   194
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   195
    void changeWeapon (int delta);
223
2fcaf54ed37b basic network-projectiles
terom
parents: 222
diff changeset
   196
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   197
public:
312
10743f190aab info box
nireco
parents: 308
diff changeset
   198
    /**
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   199
     * 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
   200
     *
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   201
     * 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
   202
     */
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   203
    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
   204
        
417
c503e0c6a740 support for building without Network/Graphics, although the disable-graphics case is kind of hackish still
Tero Marttila <terom@fixme.fi>
parents: 414
diff changeset
   205
#if GRAPHICS_ENABLED    
312
10743f190aab info box
nireco
parents: 308
diff changeset
   206
    /**
275
fa44b905bc2e Tried to take input tick into account in updatePosition but it still doesn't seem to work
saiam
parents: 274
diff changeset
   207
     * 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
   208
     */
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
   209
    virtual void draw (graphics::Display &display, bool displayWeapon, PixelCoordinate camera);
417
c503e0c6a740 support for building without Network/Graphics, although the disable-graphics case is kind of hackish still
Tero Marttila <terom@fixme.fi>
parents: 414
diff changeset
   210
#endif    
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   211
};
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   212
283
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   213
/**
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   214
 * 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
   215
 *
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   216
 * 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
   217
 */
7540b0859579 start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents: 276
diff changeset
   218
209
68cc4248a508 sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents: 205
diff changeset
   219
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
   220
protected:
198
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   221
};
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   222
 
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   223
8698cbb101df ja viel? lis??
ekku
parents:
diff changeset
   224
#endif