Jeffery Hurley
/
Asteroids
Simple starter skeleton for asteroids video game.
Sprite.h@3:98aa3db6a48f, 2021-04-01 (annotated)
- Committer:
- jhurley31
- Date:
- Thu Apr 01 19:10:58 2021 +0000
- Revision:
- 3:98aa3db6a48f
- Parent:
- 2:30020ddfccf6
Initial commit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jhurley31 | 2:30020ddfccf6 | 1 | #pragma once |
jhurley31 | 2:30020ddfccf6 | 2 | |
jhurley31 | 3:98aa3db6a48f | 3 | #define NUM_POINTS 12 // reduce if you need to |
jhurley31 | 3:98aa3db6a48f | 4 | |
jhurley31 | 3:98aa3db6a48f | 5 | // Objects are created centered around the origin |
jhurley31 | 3:98aa3db6a48f | 6 | |
jhurley31 | 2:30020ddfccf6 | 7 | class Sprite |
jhurley31 | 2:30020ddfccf6 | 8 | { |
jhurley31 | 2:30020ddfccf6 | 9 | public: |
jhurley31 | 3:98aa3db6a48f | 10 | enum SPRITE_TYPES {SHIP, FIRE, SMALL_AST, MEDIUM_AST, LARGE_AST}; |
jhurley31 | 2:30020ddfccf6 | 11 | Sprite(); |
jhurley31 | 3:98aa3db6a48f | 12 | virtual ~Sprite(){}; |
jhurley31 | 2:30020ddfccf6 | 13 | |
jhurley31 | 3:98aa3db6a48f | 14 | virtual void move(); |
jhurley31 | 3:98aa3db6a48f | 15 | virtual void draw(bool bErase); |
jhurley31 | 3:98aa3db6a48f | 16 | virtual void addPoint(int x, int y); |
jhurley31 | 3:98aa3db6a48f | 17 | virtual bool checkCollision(const Sprite &InSprite) = 0; |
jhurley31 | 3:98aa3db6a48f | 18 | void setColor(int color){m_color = color;} |
jhurley31 | 3:98aa3db6a48f | 19 | void setNumPoints(int num){m_numPoints = num;} |
jhurley31 | 2:30020ddfccf6 | 20 | |
jhurley31 | 3:98aa3db6a48f | 21 | virtual bool isValid() { return m_bIsValid;} |
jhurley31 | 3:98aa3db6a48f | 22 | |
jhurley31 | 2:30020ddfccf6 | 23 | |
jhurley31 | 2:30020ddfccf6 | 24 | protected: |
jhurley31 | 3:98aa3db6a48f | 25 | |
jhurley31 | 3:98aa3db6a48f | 26 | double m_xCenter, m_yCenter; // center of mass |
jhurley31 | 3:98aa3db6a48f | 27 | double m_DirX, m_DirY; // unit vector |
jhurley31 | 3:98aa3db6a48f | 28 | float m_Velocity; |
jhurley31 | 2:30020ddfccf6 | 29 | |
jhurley31 | 3:98aa3db6a48f | 30 | int m_color; |
jhurley31 | 3:98aa3db6a48f | 31 | |
jhurley31 | 3:98aa3db6a48f | 32 | double m_RotationAmount; |
jhurley31 | 3:98aa3db6a48f | 33 | double m_RotationVelocity; // degrees/sec |
jhurley31 | 3:98aa3db6a48f | 34 | int m_RotationDirection; // -1 is left, 0 is not rotating , 1 is rotating right |
jhurley31 | 2:30020ddfccf6 | 35 | |
jhurley31 | 3:98aa3db6a48f | 36 | int m_numPoints; |
jhurley31 | 2:30020ddfccf6 | 37 | |
jhurley31 | 3:98aa3db6a48f | 38 | bool m_bIsValid; |
jhurley31 | 3:98aa3db6a48f | 39 | |
jhurley31 | 3:98aa3db6a48f | 40 | double m_xPoints[NUM_POINTS]; |
jhurley31 | 3:98aa3db6a48f | 41 | double m_yPoints[NUM_POINTS]; |
jhurley31 | 2:30020ddfccf6 | 42 | |
jhurley31 | 3:98aa3db6a48f | 43 | |
jhurley31 | 3:98aa3db6a48f | 44 | }; |
jhurley31 | 3:98aa3db6a48f | 45 | |
jhurley31 | 3:98aa3db6a48f | 46 |