blob: ae12e2b86c895163e0a411a1ea6bd46896e7197b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#ifndef rocks_h
#define rocks_h
#define BIG_ROCK_SIZE 16
#define MEDIUM_ROCK_SIZE 8
#define SMALL_ROCK_SIZE 4
#define BIG_ROCK_SPIN 2
#define MEDIUM_ROCK_SPIN 5
#define SMALL_ROCK_SPIN 10
#include "flyingObject.h"
#include <vector>
using namespace std;
class Rock : public FlyingObject
{
protected:
int rotationDegPerFrame;
int size;
float angle;
public:
Rock() : FlyingObject() , rotationDegPerFrame ( 0 ) , size ( 1 ) , angle ( 0 ) {}
Rock ( int degPerFrame , int size , float angle ) : rotationDegPerFrame ( degPerFrame ) , size ( size ) , angle ( angle ) {}
int getRotationDegPerFrame() { return rotationDegPerFrame; }
int getSize () { return size; }
float getAngle() { return angle; }
void setAngle ( const float angle ) { this->angle = angle; }
void setRotationDegPerFrame ( const int degPerFrame ) { this->rotationDegPerFrame = degPerFrame; }
void setSize ( const int size ) { this->size = size; }
void advance() { this->angle += rotationDegPerFrame; FlyingObject::advance(); }
virtual void draw() {};
virtual vector<Rock *> destroy() = 0;
};
class BigRock : public Rock
{
public:
BigRock ( const Point &point , const Velocity &velocity )
{
setPoint ( point );
setAngle ( 0 );
setSize ( BIG_ROCK_SIZE );
setRotationDegPerFrame ( BIG_ROCK_SPIN );
setAngle ( random ( 0 , 360 ) );
setVelocity ( velocity );
}
vector<Rock *> destroy();
void draw();
};
class MediumRock : public Rock
{
public:
MediumRock ( const Point &point , const Velocity &vel ) {
this->point = point;
this->velocity = vel;
setAngle ( 0 );
setRotationDegPerFrame ( MEDIUM_ROCK_SPIN );
setSize ( MEDIUM_ROCK_SIZE );
}
vector<Rock *> destroy();
void draw();
};
class SmallRock : public Rock
{
public:
SmallRock( const Point &point , const Velocity &vel ) {
this->point = point;
this->velocity = vel;
setAngle ( 0 );
setRotationDegPerFrame ( SMALL_ROCK_SPIN );
setSize ( SMALL_ROCK_SIZE );
}
vector<Rock *> destroy();
void draw();
};
#endif /* rocks_h */
|