-
Notifications
You must be signed in to change notification settings - Fork 2
/
Npc.h
57 lines (34 loc) · 1.04 KB
/
Npc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// Created by fredr on 08.04.2020.
//
#ifndef PACMAN_NPC_H
#define PACMAN_NPC_H
#include "GameObject.h"
#include "Pacman.h"
#include <set>
#include <algorithm>
class Npc : public GameObject {
public:
Npc(const char *path, SDL_Point pos);
~Npc() override;
void moveLeft();
void moveRight();
void moveDown();
void moveUp();
void move() override;
void update() override;
std::vector<SDL_Point> findPath(SDL_Point start, SDL_Point dest);
void
calculatePath(std::vector<SDL_Point> &stack, std::vector<SDL_Point> &alreadyVisted, SDL_Point current,
const Rails &rail);
std::vector<SDL_Point> getAdjacents(SDL_Point point);
static bool isPointIn(const std::vector<SDL_Point> &alreadyVisted, SDL_Point point);
bool isPathTo(std::vector<SDL_Point> &stack, Rails rail);
bool isValidPoint(SDL_Point point);
void checkCollision();
protected:
SDL_Point destination = SDL_Point{0, 0};
SDL_Point goal;
std::vector<SDL_Point> path;
};
#endif //PACMAN_NPC_H