Skip to content
Snippets Groups Projects
Commit c91bdf67 authored by Alrik Appelfeldt's avatar Alrik Appelfeldt
Browse files

Upload New File

parent b2a1a889
No related branches found
No related tags found
No related merge requests found
#include "ghost.h"
//ghost
Ghost::Ghost(std::string const &color, Point const &start_pos):
color_index(color), pos(start_pos)
{}
void Ghost::set_pos( Point &new_pos)
{
new_pos.x = pos.x;
new_pos.y = pos.y;
}
Point Ghost::get_pos()
{
return Point{pos.x, pos.y};
}
//clyde
Clyde::Clyde(std::string const &color, Point const &start_pos):
Ghost("orange", start_pos)
{}
Point Clyde::get_scatter(const Point &pos_pacman)
{
return Point{0,0};
}
Point Clyde::get_pos()
{
return Point{pos.x, pos.y};
}
void Clyde::set_pos( Point &new_pos)
{
Ghost::set_pos(new_pos);
}
string Clyde::get_color() const
{
return "orange";
}
Point Clyde::get_chase(const Point &pos_pacman, const Point &dir_pacman)
{
int proximity = abs(pos.x - pos_pacman.x) + abs(pos.y - pos_pacman.y);
if (proximity >= 2)
{
return pos_pacman;
}
else
{
return Point{0,0};
}
}
//pinky
Pinky::Pinky(std::string const &color, Point const &start_pos):
Ghost("pink", start_pos)
{}
Point Pinky::get_scatter(const Point &pos_pacman)
{
return Point{0,21};
}
Point Pinky::get_pos()
{
return Point{pos.x, pos.y};
}
void Pinky::set_pos( Point &new_pos)
{
Ghost::set_pos(new_pos);
}
string Pinky::get_color() const
{
return "pink";
}
Point Pinky::get_chase(const Point &pos_pacman, const Point &dir_pacman) //skriv om allt typ
{
Point target = pos_pacman;
if(dir_pacman.x == 0 && dir_pacman.y == -1)
{
target.y = (target.y - 2);
}
else if(dir_pacman.x == 0 && dir_pacman.y == 1)
{
target.y = (target.y + 2);
}
else if(dir_pacman.x == -1 && dir_pacman.y == 0)
{
target.x = (target.x -2 );
}
else if(dir_pacman.x == 1 && dir_pacman.y == 0);
{
target.x = (target.x -2);
}
return target;
}
//blinky
Blinky::Blinky(std::string const &color, Point const &start_pos)
: Ghost("red", start_pos)
{}
void Blinky::set_pos(Point &new_pos) {
set_pos(new_pos);
}
Point Blinky::get_scatter(const Point &pos_pacman) {
if (angry == true)
{
return Point{pos_pacman.x, pos_pacman.y}; // stämmer?
} else
{
return Point{6, 6};
}
}
Point Blinky::get_chase(const Point &pos_pacman, const Point &dir_pacman) {
return Point{pos_pacman.x, pos_pacman.y};
}
Point Blinky::get_pos() {
return pos;
}
std::string Blinky::get_color()const
{
return "pink";
}
bool Blinky::get_angry(){
return angry;
}
void Blinky::set_angry(bool state) {
angry = state;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment