00001 /* This Spaceshooter is an small space adventure game 00002 * Copyright (C) 2006,2007 Steffen Nörtershäuser 00003 * Copyright (C) 2008 Christoph Egger 00004 * 00005 * This program is free software: you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation, either version 3 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00020 //Player.h - Deklaration der Klasse CPlayer 00021 //CPlayer Klasse die für das Verwalten der Spieler benutzt wird 00022 //Steffen Nörtershäuser 00024 00025 00027 //Schutz vor Mehrfach Deklaration 00028 #ifndef PLAYER_H 00029 #define PLAYER_H 00030 00031 #include "Ship.hpp" 00032 00033 #include <string> 00034 00035 00036 static const unsigned int PLAYER_INITIAL_LIVES = 3; 00037 00038 static const unsigned int PLAYER_RESPAWN_TIME = 2000; 00039 00041 00045 class CPlayer 00046 { 00047 public: 00049 CPlayer(); 00050 ~CPlayer(); 00051 00053 void Init(const std::string& FileName); 00054 00056 void Draw() { m_Ship->Draw(); } 00057 00059 void Update(); 00060 00062 float GetXPosition() const { return m_Ship->GetXPosition(); } 00063 00065 float GetYPosition() const { return m_Ship->GetYPosition(); } 00066 00068 CShip* GetShip() { return m_Ship; } 00069 00070 const CShip* GetShip() const {return m_Ship;} 00071 00073 void EquipWeapon(std::string Name) { m_Ship->EquipWeapon(Name); } 00074 00076 void ResetWeapons() { m_Ship->ResetWeapons(); } 00077 00079 bool CheckCollision(CPowerUp* CounterPart) { return m_Ship->CheckCollision(CounterPart); } 00080 00083 bool CheckCollision(CShip* CounterPart) { return m_Ship->CheckCollision(CounterPart); } 00084 00086 bool IsDead() const { return m_Ship->IsDead(); } 00087 00089 std::size_t GetProjectilCount() const { return m_Ship->GetProjectilCount(); } 00090 00092 float GetProjectilX(int Projectil) const { return m_Ship->GetProjectilXPosition(Projectil); } 00093 00095 float GetProjectilY(int Projectil) const { return m_Ship->GetProjectilYPosition(Projectil); } 00096 00098 float GetProjectilDamage(int Projectil) const { return m_Ship->GetProjectilDamage(Projectil); } 00099 00101 float GetProjectilWidth(int Projectil) const { return m_Ship->GetProjectilWidth(Projectil); } 00102 00103 00105 std::size_t GetWeaponCount() const { return m_Ship->GetWeaponCount(); } 00106 00108 int GetWeaponDamage(int Weapon) const { return m_Ship->GetWeaponDamage(Weapon); } 00109 00111 float GetCollisionSystemWidth() const { return m_Ship->GetCollisionSystemWidth(); } 00112 00113 00115 std::size_t GetWeaponTypeCount() const { return m_Ship->GetWeaponTypeCount(); } 00116 00118 std::string GetCurWeaponNameOfType(std::size_t GroupID) { return m_Ship->GetCurWeaponNameOfType(GroupID); } 00119 00121 const CWeapon* GetCurWeaponOfType(std::size_t GroupID) { return m_Ship->GetCurWeaponOfType(GroupID); } 00122 00123 00125 bool CanBeRemoved(); 00126 00127 00129 const std::string* GetLiveString() const { return &m_LiveString; } 00130 00132 int GetLives() const { return m_Lives; } 00133 00135 void SetLives(int Lives) 00136 { 00137 m_Lives = Lives; 00138 00139 char strBuf[50]; 00140 sprintf(strBuf,"Leben: %d",m_Lives); 00141 m_LiveString = strBuf; 00142 } 00143 00144 private: 00145 CShip* m_Ship; //Das Schiff des Spielers 00146 00147 int m_Lives; //Die Leben des Spielers 00148 std::string m_LiveString; //Die Leben als String gespeichert für das HUD 00149 00150 bool m_Respawning; //Ob der Spieler gerade wiederbelebt wird 00151 int m_LastDeadTime; //Wann der spieler das letzte mal gestorben 00152 }; 00153 00154 #endif