-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayerPac.h
127 lines (103 loc) · 3.65 KB
/
PlayerPac.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#pragma once
#include <iostream>
#include<ctime>
#include<sstream>
#include <conio.h>
#include <math.h>
#include<SFML/Graphics.hpp>
#include<SFML/System.hpp>
#include<SFML/Window.hpp>
#include<SFML/Audio.hpp>
#include<SFML/Network.hpp>
enum PLAYER_ANIMATION_STATES { IDLE = 0, MOVING_LEFT, MOVING_RIGHT, MOVING_UP, MOVING_DOWN };
//Global Variables
const int rows = 31;
const int cols = 28;
const int cell = 30;
const int wallxspc = 220;
const int wallyspc = 35;
const int dotxspc = 230;
const int dotyspc = 45;
static int score = -1;
static int lives = 3;
static int fr_timer = 0;
//static bool back = false;
static int back = 0;
static int apple[4][2] = { {3,1},{3,26},{23,1}, {23,27} };
static int Blinky_fr_rate = 0;
static int Pinky_fr_rate = 0;
static int Inky_fr_rate = 0;
static int Clyde_fr_rate = 0;
//INITILLIZING MAP
static int Map[rows][cols] = {
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},//1
{1,0,2,2,2,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2,1},//2
{1,2,1,1,1,1,2,1,1,1,1,1,2,1,1,2,1,1,1,1,1,2,1,1,1,1,2,1},//3
{1,3,1,0,0,1,2,1,0,0,0,1,2,1,1,2,1,0,0,0,1,2,1,0,0,1,3,1},//4
{1,2,1,1,1,1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,1,1,1,1,2,1,1,2,1,1,1,1,1,2,1,1,1,1,2,1},//22
{1,2,1,1,1,1,2,1,1,1,1,1,2,1,1,2,1,1,1,1,1,2,1,1,1,1,2,1},//23
{1,3,2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,2,2,3,1},//24
{1,1,1,2,1,1,2,1,1,2,1,1,1,1,1,1,1,1,2,1,1,2,1,1,2,1,1,1},//25
{1,1,1,2,1,1,2,1,1,2,1,1,1,1,1,1,1,1,2,1,1,2,1,1,2,1,1,1},//26
{1,2,2,2,2,2,2,1,1,2,2,2,2,1,1,2,2,2,2,1,1,2,2,2,2,2,2,1},//27
{1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1},//28
{1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1},//29
{1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1},//30
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} };//31
struct Position
{
int x;
int y;
};
class PlayerPac
{
private:
sf::Sprite pacman;
sf::Texture pacsheet;
bool pacmoving;
sf::Clock animationTimerpac;
short animStatepac;
sf::IntRect currentFramepac;
//Game* g;
/*int px;
int py;*/
//Game* g;
void initTexture();
void initSprite();
void initAnimations();
public:
void initVariables();
//friends function
//void collide_ghost(bool, int&, int&, int&, int&, char&);
int displacement(int, int, int, int);
void frighten_end(bool&, bool&);
char direction;
//char direct;
bool powered;
Position pos;
//bool scared;
PlayerPac();
void updateMovement();
void updateAnimations();
void update();
void setDirection(char dir);
void render(sf::RenderTarget& target);
~PlayerPac();
};