summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-06-26 20:08:51 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2010-06-26 20:08:51 +0200
commit761d6d077042c7d679606bbc113050118eb60fc1 (patch)
treea1496def76256c59ef64c9d1cf8761fb0d62c5d7 /engine
parentaa3e66d13703eaf7e45350f339fd95d7cb877324 (diff)
Introduced Enemy1-2 and delayed pattern spawning.
Diffstat (limited to 'engine')
-rw-r--r--engine/enemy.cpp28
-rw-r--r--engine/enemy.h22
-rw-r--r--engine/stage.cpp5
3 files changed, 49 insertions, 6 deletions
diff --git a/engine/enemy.cpp b/engine/enemy.cpp
index ed07dec..87e9e87 100644
--- a/engine/enemy.cpp
+++ b/engine/enemy.cpp
@@ -6,10 +6,8 @@
Enemy::Enemy(const Vector2& initpos, std::vector<BulletPattern*>& stage_patterns) : patterns(stage_patterns) {
pos = initpos;
-
- texture = new TextureSDL("textures/enemy.png");
- patterns.push_back(new BulletPattern1(Vector2(0.5, 0.8)));
+ texture = new TextureSDL("textures/enemy.png");
}
void Enemy::update() {
@@ -28,3 +26,27 @@ void Enemy::draw() {
glDisable(GL_TEXTURE_2D);
}
+
+Enemy1::Enemy1(const Vector2& initpos, std::vector<BulletPattern*>& stage_patterns) : Enemy(initpos, stage_patterns) {
+ steps = 0;
+
+ patterns.push_back(new BulletPattern1(initpos));
+}
+
+void Enemy1::update() {
+ steps++;
+ if(steps == 180) {
+ patterns.push_back(new BulletPattern2(pos));
+ }
+}
+
+Enemy2::Enemy2(const Vector2& initpos, std::vector<BulletPattern*>& stage_patterns) : Enemy(initpos, stage_patterns) {
+ steps = 0;
+}
+
+void Enemy2::update() {
+ steps++;
+ if(steps == 660) {
+ patterns.push_back(new BulletPattern3(pos));
+ }
+}
diff --git a/engine/enemy.h b/engine/enemy.h
index 9ccdc86..9a5c4d3 100644
--- a/engine/enemy.h
+++ b/engine/enemy.h
@@ -16,9 +16,29 @@ class Enemy {
public:
Enemy(const Vector2& initpos, std::vector<BulletPattern*>& stage_patterns);
- void update();
+ virtual void update();
void draw();
};
+class Enemy1 : public Enemy {
+ protected:
+ unsigned int steps;
+
+ public:
+ Enemy1(const Vector2& initpos, std::vector<BulletPattern*>& stage_patterns);
+
+ virtual void update();
+};
+
+class Enemy2 : public Enemy {
+ protected:
+ unsigned int steps;
+
+ public:
+ Enemy2(const Vector2& initpos, std::vector<BulletPattern*>& stage_patterns);
+
+ virtual void update();
+};
+
#endif
diff --git a/engine/stage.cpp b/engine/stage.cpp
index 84a4cc7..59fda88 100644
--- a/engine/stage.cpp
+++ b/engine/stage.cpp
@@ -15,8 +15,9 @@ Stage::Stage() {
texture = new TextureSDL("textures/shot1.png");
shader = new GLShaderProgram();
- enemy_list.push_back(new Enemy(Vector2(0.25, 0.75), patterns));
- enemy_list.push_back(new Enemy(Vector2(0.75, 0.75), patterns));
+ enemy_list.push_back(new Enemy1(Vector2(0.25, 0.75), patterns));
+ enemy_list.push_back(new Enemy1(Vector2(0.75, 0.75), patterns));
+ enemy_list.push_back(new Enemy2(Vector2(0.50, 0.80), patterns));
//patterns.push_back(new BulletPattern3(Vector2(0.5, 0.5)));
//patterns.push_back(new BulletPattern1(Vector2(0.5, 0.8)));