From c74b2de9719f0e0a386e5947b7dc4311d493cc0b Mon Sep 17 00:00:00 2001
From: Vegard Storheil Eriksen <zyp@jvnv.net>
Date: Sun, 23 May 2010 20:19:05 +0200
Subject: Added Enemy-class.

---
 engine/enemy.cpp | 29 +++++++++++++++++++++++++++++
 engine/enemy.h   | 24 ++++++++++++++++++++++++
 engine/stage.cpp |  8 ++++++++
 engine/stage.h   |  2 ++
 4 files changed, 63 insertions(+)
 create mode 100644 engine/enemy.cpp
 create mode 100644 engine/enemy.h

(limited to 'engine')

diff --git a/engine/enemy.cpp b/engine/enemy.cpp
new file mode 100644
index 0000000..bf4d5ee
--- /dev/null
+++ b/engine/enemy.cpp
@@ -0,0 +1,29 @@
+#include "enemy.h"
+
+#include "texturesdl.h"
+
+#include <SDL/SDL_opengl.h>
+
+Enemy::Enemy(const Vector2& initpos) {
+	pos = initpos;
+	
+	texture = new TextureSDL("textures/enemy.png");
+}
+
+void Enemy::update() {
+	
+}
+
+void Enemy::draw() {
+	glPointSize(32.0);
+
+	glColor4f(1, 1, 1, 1);
+	glEnable(GL_TEXTURE_2D);
+	glBindTexture(GL_TEXTURE_2D, texture->tex());
+
+	glBegin(GL_POINTS);
+	glVertex2f(pos.x, pos.y);
+	glEnd();
+
+	glDisable(GL_TEXTURE_2D);
+}
\ No newline at end of file
diff --git a/engine/enemy.h b/engine/enemy.h
new file mode 100644
index 0000000..7396b55
--- /dev/null
+++ b/engine/enemy.h
@@ -0,0 +1,24 @@
+#ifndef ENEMY_H
+#define ENEMY_H
+
+#include "vector.h"
+#include "texture.h"
+#include "bulletpattern.h"
+
+#include <vector>
+
+class Enemy {
+	protected:
+		Vector2 pos;
+		Texture* texture;
+		std::vector<BulletPattern*> patterns;
+	
+	public:
+		Enemy(const Vector2& initpos);
+		
+		void update();
+		
+		void draw();
+};
+
+#endif
diff --git a/engine/stage.cpp b/engine/stage.cpp
index 06ae1ef..53d7f59 100644
--- a/engine/stage.cpp
+++ b/engine/stage.cpp
@@ -11,6 +11,9 @@ 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)));
+	
 	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)));
@@ -35,6 +38,11 @@ void Stage::update() {
 void Stage::draw() {
 	player->draw();
 	
+	for(std::vector<Enemy*>::iterator it = enemy_list.begin(); it < enemy_list.end(); it++) {
+		Enemy* enemy = (*it);
+		enemy->draw();
+	}
+	
 	shader->use();
 	glPointSize(32.0);
 	glEnable(GL_TEXTURE_2D);
diff --git a/engine/stage.h b/engine/stage.h
index 4972795..ad59b90 100644
--- a/engine/stage.h
+++ b/engine/stage.h
@@ -4,6 +4,7 @@
 #include "player.h"
 #include "shader.h"
 #include "texture.h"
+#include "enemy.h"
 #include "bulletpattern.h"
 
 #include <vector>
@@ -15,6 +16,7 @@ class Stage {
 		GLShaderProgram* shader;
 		Texture* texture;
 		
+		std::vector<Enemy*> enemy_list;
 		std::vector<BulletPattern*> patterns;
 		
 	public:
-- 
cgit v1.2.3