diff --git a/source/Game.cpp b/source/Game.cpp index aefc7a2..a66fb24 100644 --- a/source/Game.cpp +++ b/source/Game.cpp @@ -9,6 +9,7 @@ #include "abstract/Actor.h" #include "sprite/Cover.h" +#include "sprite/Enemy.h" #include "util/Loader.h" #include "util/ResourceManager.h" #include "util/String.h" @@ -36,12 +37,16 @@ Game::Game(const Vector2i& resolution) : mPaused(false) { mWindow.setFramerateLimit(FPS_GOAL); mWindow.setKeyRepeatEnabled(true); + mWorld.SetContactListener(this); + + mTileManager.generate(); for (int i = 0; i < 500; i += 50) { mCollection.insert(std::shared_ptr(new Cover(Vector2f(i, i), Vector2i(20, 20), mWorld)), Collection::LEVEL_STATIC); } - mTileManager.generate(); - mWorld.SetContactListener(this); + mCollection.insert(std::shared_ptr(new Enemy(mWorld, Vector2f(400.0f, 200.0f))), + Collection::LEVEL_ACTOR); + } /** diff --git a/source/sprite/Enemy.cpp b/source/sprite/Enemy.cpp new file mode 100644 index 0000000..24e74e2 --- /dev/null +++ b/source/sprite/Enemy.cpp @@ -0,0 +1,22 @@ +/* + * Enemy.cpp + * + * Created on: 10.09.2012 + * Author: Felix + */ + +#include "Enemy.h" + +Enemy::Enemy(b2World& world, const Vector2f& position) : +Sprite("enemy.png", PhysicalData(position, Vector2i(50, 50), world, + CATEGORY_ACTOR, MASK_ALL, true)) { + +} + +Enemy::~Enemy() { +} + + +void +Enemy::onThink(float elapsedTime) { +} diff --git a/source/sprite/Enemy.h b/source/sprite/Enemy.h new file mode 100644 index 0000000..bf6aaf7 --- /dev/null +++ b/source/sprite/Enemy.h @@ -0,0 +1,27 @@ +/* + * Enemy.h + * + * Created on: 10.09.2012 + * Author: Felix + */ + +#ifndef DG_ENEMY_H_ +#define DG_ENEMY_H + +#include "../abstract/Actor.h" +#include "../abstract/Sprite.h" + +#include "../util/Vector.h" + +class Enemy : public Sprite, public Actor { +// Public functions. +public: + Enemy(b2World& world, const Vector2f& position); + ~Enemy(); + +// Private functions. +private: + void onThink(float elapsedTime); +}; + +#endif /* DG_ENEMY_H_ */