Adding template code for enemy!
This commit is contained in:
parent
5b0d656068
commit
d598c7dc37
14
source/enemy.cpp
Normal file
14
source/enemy.cpp
Normal 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);
|
||||||
|
}
|
||||||
@ -7,17 +7,18 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class Player {
|
class Player {
|
||||||
|
protected:
|
||||||
Point origin_;
|
Point origin_;
|
||||||
Point map_;
|
Point map_;
|
||||||
int direction_;
|
int direction_;
|
||||||
int size_;
|
int size_;
|
||||||
int speed_;
|
int speed_;
|
||||||
std::vector<SDL_Rect> *obstacles_;
|
std::vector<SDL_Rect> *obstacles_;
|
||||||
|
|
||||||
|
private:
|
||||||
void checkDirection(int dir, int *xVel, int *yVel) const;
|
void checkDirection(int dir, int *xVel, int *yVel) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Player()
|
Player()
|
||||||
: origin_(1,1),
|
: origin_(1,1),
|
||||||
map_(640,480),
|
map_(640,480),
|
||||||
@ -27,10 +28,29 @@ public:
|
|||||||
obstacles_(NULL)
|
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;
|
Point getPosition() const;
|
||||||
int getDirection() 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);
|
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
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user