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 //Projectile.h - Deklaration der Klasse CProjectile 00021 //CProjectile wird für das Verwalten der Schüße der Waffen benuzt 00022 //Steffen Nörtershäuser 00024 00025 00027 //Schutz vor Mehrfach Deklaration 00028 #ifndef PROJECTILE_H 00029 #define PROJECTILE_H 00030 00031 #include <string> 00032 #include <SFML/Graphics.hpp> 00033 00034 #include "CollisionSystem.hpp" 00035 #include "Singletons.hpp" 00036 00038 00039 struct sProjectileData 00040 { 00041 std::string FileName; 00042 int FrameCount; 00043 int FrameWidth; 00044 int FrameHeight; 00045 long FrameDelay; 00046 std::string CollisionFile; 00047 float X; 00048 float Y; 00049 float SpeedX; 00050 float SpeedY; 00051 float AccelX; 00052 float AccelY; 00053 float SpeedLimitX; 00054 float SpeedLimitY; 00055 bool SpeedLimitXSmaller; 00056 bool SpeedLimitYSmaller; 00057 bool AutoRotate; 00058 }; 00059 00063 class CProjectile 00064 { 00065 public: 00066 //Konstrukor und Destruktor 00067 CProjectile(); 00068 ~CProjectile(); 00069 00070 //Diese Funktion intialisiert das Projektil 00071 void Init(sProjectileData ProjectileData); 00072 00073 //Diese Funktion zeichnet das Projektil 00074 void Draw() 00075 { 00076 sgl::get_window().Draw(m_Sprite); 00077 m_CollisionSystem.Draw(); 00078 } 00079 00080 //Diese Funktion aktualisiert das Projektil 00081 void Update(); 00082 00083 //Diese Funktion gibt die X-Position des Projektils zurück 00084 float GetXPosition() const { return m_Sprite.GetPosition().y; } 00085 00086 //Diese Funktion gibt die Y-Position des Projektils zurück 00087 float GetYPosition() const { return m_Sprite.GetPosition().y; } 00088 00089 //Diese Funktion gibt das KollisionSystem zurück 00090 const CCollisionSystem * GetCollisionSystem() const { return &m_CollisionSystem; } 00091 00092 //Diese Funktion gibt die Breite des KollisionSystems zurück 00093 float GetCollisionSystemWidth() const { return m_CollisionSystem.GetWidth(); } 00094 private: 00095 sf::Sprite m_Sprite; //Das Sprite des Schuß 00096 CCollisionSystem m_CollisionSystem; //Das KollisionSystem 00097 00098 float m_SpeedX; //Die Geschwindigkeit des Schuß 00099 float m_SpeedY; //Die Geschwindigkeit des Schuß 00100 00101 float m_SpeedLimitX; //Das Geschwindigkeits Limit des Schuß auf der X-Achse 00102 bool m_SpeedLimitXSmaller; //Ob es das Speedlimit auf der X-Achse kleiner als benutzt 00103 00104 float m_SpeedLimitY; //Das Geschwindigkeits Limit des Schuß auf der Y-Achse 00105 bool m_SpeedLimitYSmaller; //Ob es das Speedlimit auf der Y-Achse kleiner als benutzt 00106 00107 float m_AccelX; //Die Beschleunigung des Schußes 00108 float m_AccelY; //Die Beschleunigung des Schußes 00109 00110 bool m_AutoRotate; //Ob die Rotation des Sprites angepasst werden soll 00111 00112 long m_LastAniFrameInc; //Wann das letzte mal der Animationsframe inkrementiert wurde 00113 long m_AniFrameDelay; //Wie lange zwischen dem inkrementieren des Animationsframes gewartet wird 00114 }; 00115 00116 #endif