Added Enemy class.

This commit is contained in:
Felix Ableitner 2012-09-11 16:22:47 +02:00
parent f09eee6828
commit 4419a76dfa
3 changed files with 56 additions and 2 deletions

View file

@ -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<Sprite>(new Cover(Vector2f(i, i), Vector2i(20, 20),
mWorld)), Collection::LEVEL_STATIC);
}
mTileManager.generate();
mWorld.SetContactListener(this);
mCollection.insert(std::shared_ptr<Sprite>(new Enemy(mWorld, Vector2f(400.0f, 200.0f))),
Collection::LEVEL_ACTOR);
}
/**

22
source/sprite/Enemy.cpp Normal file
View file

@ -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) {
}

27
source/sprite/Enemy.h Normal file
View file

@ -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_ */