1 // 2 // Ship.hpp -- The player's ship. 3 // Copyright (C) 2008 Nick Gasson 4 // 5 // This program is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program. If not, see <http://www.gnu.org/licenses/>. 17 // 18 19 #ifndef INC_SHIP_HPP 20 #define INC_SHIP_HPP 21 22 #include "Platform.hpp" 23 #include "Geometry.hpp" 24 #include "Viewport.hpp" 25 #include "Emitter.hpp" 26 #include "Image.hpp" 27 #include "SoundEffect.hpp" 28 29 class Ship { 30 public: 31 Ship(Viewport* v); 32 33 void Reset(); 34 35 void Display() const; 36 void DrawExhaust(); 37 void DrawExplosion(); 38 void Move(); 39 void ProcessEffects(bool paused, bool exploding); 40 void ThrustOn(); 41 void ThrustOff(); 42 void Thrust(double speed); 43 void Turn(double delta); 44 void Bounce(); 45 void ApplyGravity(double gravity); 46 void CentreInViewport(); 47 48 bool CheckCollision(LineSegment& l, double dx=0, double dy=0) const; 49 bool HotSpotCollision(LineSegment& l, double dx=0, double dy=0) const; 50 bool BoxCollision(int x, int y, int w, int h) const; 51 GetX() const52 double GetX() const { return xpos; } GetY() const53 double GetY() const { return ypos; } GetXSpeed() const54 double GetXSpeed() const { return speedX; } GetYSpeed() const55 double GetYSpeed() const { return speedY; } GetAngle() const56 double GetAngle() const { return angle; } 57 58 static const int SHIP_START_Y = 100; 59 60 private: 61 void RotatePoints(const Point* pPoints, Point* pDest, int nCount, 62 double angle, int adjustx=0, int adjusty=0); 63 64 Image shipImage; 65 66 double xpos, ypos; 67 double speedX, speedY, angle; 68 69 Viewport* viewport; 70 Explosion explosion; 71 BlueSmokeTrail exhaust; 72 bool thrusting; 73 74 SoundEffect boingSound; 75 76 static const int NUM_HOTSPOTS = 8; 77 Point points[NUM_HOTSPOTS]; 78 static const Point hotspots[]; 79 }; 80 81 #endif 82