Adding template code for enemy!

This commit is contained in:
zombidust 2014-04-15 20:26:01 +03:00
parent 5b0d656068
commit d598c7dc37
2 changed files with 39 additions and 5 deletions

14
source/enemy.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "entities.h"
int Enemy::findPlayer(int *xVel, int *yVel) {
//Nedko svurshi si rabotata
//pip
}
void Enemy::move() {
int xVel;
int yVel;
direction_ = findPlayer(&xVel, &yVel);
origin_.setX(origin_.getX() + xVel);
origin_.setY(origin_.getY() + yVel);
}

View File

@ -7,17 +7,18 @@
#include <vector>
class Player {
protected:
Point origin_;
Point map_;
int direction_;
int size_;
int speed_;
std::vector<SDL_Rect> *obstacles_;
private:
void checkDirection(int dir, int *xVel, int *yVel) const;
public:
public:
Player()
: origin_(1,1),
map_(640,480),
@ -27,10 +28,29 @@ public:
obstacles_(NULL)
{}
Player(Point origin, Point map, int dir, int size, int speed, std::vector<SDL_Rect> *obstacles)
: origin_(origin.getX(),origin.getY()),
map_(map.getX(),map.getY()),
direction_(dir),
size_(size),
speed_(speed),
obstacles_(obstacles)
{}
Point getPosition() const;
int getDirection() const;
void movePlayer(int dir);
void move(int dir);
void init(Point origin, int size, int dir, Point map, std::vector<SDL_Rect> *obstacles, int speed);
};
class Enemy::public Player {
Player player_;
int findPlayer(int *xVel, int *yVel);
public:
Enemy(Point origin, Point map, int dir, int size, int speed, std::vector<SDL_Rect> *obstacles, Player player)
: Player(origin, map, dir, size, speed, obstacles),
player_(player)
{}
void move();
};
#endif