diff options
-rw-r--r-- | engine/enemy.cpp | 7 | ||||
-rw-r--r-- | engine/enemy.h | 4 | ||||
-rw-r--r-- | engine/stage.cpp | 16 |
3 files changed, 16 insertions, 11 deletions
diff --git a/engine/enemy.cpp b/engine/enemy.cpp index 09f1da8..ed07dec 100644 --- a/engine/enemy.cpp +++ b/engine/enemy.cpp @@ -4,14 +4,15 @@ #include <SDL/SDL_opengl.h> -Enemy::Enemy(const Vector2& initpos) { +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))); } void Enemy::update() { - } void Enemy::draw() { @@ -26,4 +27,4 @@ void Enemy::draw() { glEnd(); glDisable(GL_TEXTURE_2D); -}
\ No newline at end of file +} diff --git a/engine/enemy.h b/engine/enemy.h index d27760b..9ccdc86 100644 --- a/engine/enemy.h +++ b/engine/enemy.h @@ -11,10 +11,10 @@ class Enemy { protected: Vector2 pos; Texture* texture; - std::vector<BulletPattern*> patterns; + std::vector<BulletPattern*>& patterns; public: - Enemy(const Vector2& initpos); + Enemy(const Vector2& initpos, std::vector<BulletPattern*>& stage_patterns); void update(); diff --git a/engine/stage.cpp b/engine/stage.cpp index 6bcd622..84a4cc7 100644 --- a/engine/stage.cpp +++ b/engine/stage.cpp @@ -15,15 +15,15 @@ Stage::Stage() { texture = new TextureSDL("textures/shot1.png"); shader = new GLShaderProgram(); - enemy_list.push_back(new Enemy(Vector2(0.25, 0.75))); - enemy_list.push_back(new Enemy(Vector2(0.75, 0.75))); + enemy_list.push_back(new Enemy(Vector2(0.25, 0.75), patterns)); + enemy_list.push_back(new Enemy(Vector2(0.75, 0.75), patterns)); - patterns.push_back(new BulletPattern3(Vector2(0.5, 0.5))); - patterns.push_back(new BulletPattern1(Vector2(0.5, 0.8))); + //patterns.push_back(new BulletPattern3(Vector2(0.5, 0.5))); + //patterns.push_back(new BulletPattern1(Vector2(0.5, 0.8))); //patterns.push_back(new BulletPattern2(Vector2(0.2, 0.5))); - patterns.push_back(new BulletPattern2(Vector2(0.5, 0.5))); + //patterns.push_back(new BulletPattern2(Vector2(0.5, 0.5))); //patterns.push_back(new BulletPattern2(Vector2(0.8, 0.5))); - patterns.push_back(new BulletPattern4(Vector2(0.5, 0.8))); + //patterns.push_back(new BulletPattern4(Vector2(0.5, 0.8))); GLFragmentShader shader1("shaders/bullet_fragment.glsl"); GLVertexShader shader2("shaders/bullet_vertex.glsl"); @@ -34,6 +34,10 @@ Stage::Stage() { void Stage::update() { player->update(); + + for(std::vector<Enemy*>::iterator it = enemy_list.begin(); it < enemy_list.end(); it++) { + (*it)->update(); + } for(std::vector<BulletPattern*>::iterator it = patterns.begin(); it < patterns.end(); it++) { (*it)->update(); |