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,6 +7,7 @@
|
||||
#include <vector>
|
||||
|
||||
class Player {
|
||||
protected:
|
||||
Point origin_;
|
||||
Point map_;
|
||||
int direction_;
|
||||
@ -14,10 +15,10 @@ class Player {
|
||||
int speed_;
|
||||
std::vector<SDL_Rect> *obstacles_;
|
||||
|
||||
private:
|
||||
void checkDirection(int dir, int *xVel, int *yVel) const;
|
||||
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user