-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPinky.cpp
More file actions
30 lines (27 loc) · 792 Bytes
/
Pinky.cpp
File metadata and controls
30 lines (27 loc) · 792 Bytes
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
#include "Pinky.h"
Pinky::Pinky(QWidget *parent, int initialXX, int initialYY, Pacman *pacman) : Ghost(parent, initialXX, initialYY, QPixmap("pacman-art/ghosts/pinky.png"), pacman)
{
scaredPosition = new QPoint(3, -3);
}
void Pinky::makeMove()
{
QPoint *p;
if (isScared)
{
p = new QPoint(scaredPosition->x(), scaredPosition->y());
}
else
{
p = new QPoint(pacman->position->x(), pacman->position->y());
if (pacman->direction == RIGHT)
p->setX(p->x() + 4);
if (pacman->direction == LEFT)
p->setX(p->x() - 4);
if (pacman->direction == UP)
p->setY(p->y() - 4);
if (pacman->direction == DOWN)
p->setY(p->y() + 4);
}
followPoint(*p);
Character::makeMove();
}