1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: Silvan Nellen |
---|
13 | co-programmer: Benjamin Knecht |
---|
14 | */ |
---|
15 | |
---|
16 | #include "player.h" |
---|
17 | |
---|
18 | #include "factory.h" |
---|
19 | |
---|
20 | #include "list.h" |
---|
21 | |
---|
22 | #include "event_handler.h" |
---|
23 | |
---|
24 | #include "event.h" |
---|
25 | |
---|
26 | using namespace std; |
---|
27 | |
---|
28 | |
---|
29 | /** |
---|
30 | * creates a new Player |
---|
31 | */ |
---|
32 | Player::Player() |
---|
33 | { |
---|
34 | this->init(); |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | /** |
---|
39 | * destructs the player, deletes alocated memory |
---|
40 | */ |
---|
41 | Player::~Player () |
---|
42 | { |
---|
43 | } |
---|
44 | |
---|
45 | |
---|
46 | /** |
---|
47 | * initializes a Player |
---|
48 | */ |
---|
49 | void Player::init() |
---|
50 | { |
---|
51 | // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); |
---|
52 | this->setClassID(CL_PLAYER, "Player"); |
---|
53 | |
---|
54 | PRINTF(4)("PLAYER INIT\n"); |
---|
55 | |
---|
56 | } |
---|
57 | |
---|
58 | /** |
---|
59 | * subscribe to all events the controllable needs |
---|
60 | */ |
---|
61 | void Player::subscribeEvents() |
---|
62 | { |
---|
63 | /*EventHandler* evh = EventHandler::getInstance(); |
---|
64 | for (int i = 1; i < SDLK_LAST; i++) |
---|
65 | { |
---|
66 | if (!evh->isSubscribed(ES_GAME, i)) |
---|
67 | evh->subscribe(this, ES_GAME, i); |
---|
68 | } |
---|
69 | */ |
---|
70 | } |
---|
71 | |
---|
72 | void Player::process(const Event &event) |
---|
73 | { |
---|
74 | this->controllable->process(event); |
---|
75 | } |
---|
76 | |
---|
77 | |
---|
78 | void Player::setControllable(Playable* controllalble) |
---|
79 | { |
---|
80 | //todo get keyset an subscribe to the needed keys |
---|
81 | this->controllable = controllable; |
---|
82 | } |
---|
83 | |
---|
84 | |
---|
85 | |
---|
86 | Playable* Player::getControllable() |
---|
87 | { |
---|
88 | return controllable; |
---|
89 | } |
---|
90 | |
---|