Skip to content

Commit

Permalink
Merge pull request #17 from beergame/develop
Browse files Browse the repository at this point in the history
V1.0
  • Loading branch information
victorbalssa authored May 5, 2017
2 parents 363bc65 + 3d1bf4c commit ef5a2df
Show file tree
Hide file tree
Showing 19 changed files with 755 additions and 166 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ include_directories("${PROJECT_BINARY_DIR}")

set(EXECUTABLE_NAME "PACKMAN")
set(SOURCE_FILES
Abstract/AbstractEntity.cpp Abstract/Character.cpp Entities/Packman.cpp Entities/Monster.cpp Entities/Map.cpp Manager/PlayerManager.cpp Manager/MonsterManager.cpp Manager/GameManager.cpp Utils/IObservable.hh Utils/IObserver.hh Utils/TimeManager.cpp Utils/Factory/MonsterFactory.cpp Utils/Factory/MapFactory.cpp config.h.in)
Abstract/AbstractEntity.cpp Abstract/Character.cpp Entities/Packman.cpp Entities/Monster.cpp Entities/Map.cpp Manager/PlayerManager.cpp Manager/MonsterManager.cpp Manager/GameManager.cpp Utils/IObservable.hh Utils/IObserver.hh Utils/TimeManager.cpp Utils/Factory/MonsterFactory.cpp Utils/Factory/MapFactory.cpp Menu/Menu.cpp config.h.in)

add_executable(${EXECUTABLE_NAME} Abstract/AbstractEntity.cpp Abstract/Character.cpp Entities/Packman.cpp Entities/Monster.cpp Entities/Map.cpp Manager/PlayerManager.cpp Manager/MonsterManager.cpp Manager/GameManager.cpp Utils/IObservable.hh Utils/IObserver.hh Utils/TimeManager.cpp Utils/Factory/MonsterFactory.cpp Utils/Factory/MapFactory.cpp config.h.in)
add_executable(${EXECUTABLE_NAME} Abstract/AbstractEntity.cpp Abstract/Character.cpp Entities/Packman.cpp Entities/Monster.cpp Entities/Map.cpp Manager/PlayerManager.cpp Manager/MonsterManager.cpp Manager/GameManager.cpp Utils/IObservable.hh Utils/IObserver.hh Utils/TimeManager.cpp Utils/Factory/MonsterFactory.cpp Utils/Factory/MapFactory.cpp Menu/Menu.cpp config.h.in)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
find_package(SFML 1.6 REQUIRED system window graphics network audio)
Expand Down
61 changes: 56 additions & 5 deletions Entities/Map.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <iostream>
#include "Map.hh"

/**
Expand All @@ -11,29 +12,79 @@
* 3 => wall
* 4 => bonus score (?)
*/
int Map::checkMap(double X, double Y) {

int Map::checkMap(double X, double Y)
{
int PositionX = (int) round(X);
int PositionY = (int) round(Y);

return map[PositionX][PositionY];
}

std::vector<std::vector<int> > Map::getMap() {
std::vector<std::vector<int>> Map::getMap()
{
return map;
}

Map::Map(std::vector<std::vector<int> > map) {
Map::Map(std::vector<std::vector<int>> map)
{
Map::map = map;
}

void Map::cleanElement(double X, double Y) {
void Map::cleanElement(double X, double Y)
{
int PositionX = (int) round(X);
int PositionY = (int) round(Y);

map[PositionX][PositionY] = 0;
}

void Map::Draw(sf::RenderWindow *window) {
void Map::movePackmanFp(int dir, int oldX, int oldY, int X, int Y)
{
if ((oldX != X) || (oldY != Y)) {
packmanPrint[0][0] = X;
packmanPrint[0][1] = Y;
switch (dir) {
case 1:
if (Y < 28 && Y > 4) {
packmanPrint[1][0] = X;
packmanPrint[1][1] = Y;
packmanPrint[2][0] = X;
packmanPrint[2][1] = Y;
}
break;
case 2:
if (X < 25 && X > 4) {
packmanPrint[1][0] = X;
packmanPrint[1][1] = Y;
packmanPrint[2][0] = X;
packmanPrint[2][1] = Y;
}
break;
case 3:
if (Y < 28 && Y > 4) {
packmanPrint[1][0] = X;
packmanPrint[1][1] = Y;
packmanPrint[2][0] = X;
packmanPrint[2][1] = Y;
}
break;
case 4:
if (X < 25 && X > 4) {
packmanPrint[1][0] = X;
packmanPrint[1][1] = Y;
packmanPrint[2][0] = X;
packmanPrint[2][1] = Y;
}
break;
default:
break;
}
}
}

void Map::Draw(sf::RenderWindow *window)
{
sf::Texture texture;
sf::Texture texture2;

Expand Down
38 changes: 24 additions & 14 deletions Entities/Map.hh
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
#ifndef PACKMAN_MAP_HH
#define PACKMAN_MAP_HH
# define PACKMAN_MAP_HH

#include <vector>
#include <math.h>
#include <SFML/Graphics.hpp>
#include <iterator>
# include <vector>
# include <math.h>
# include <SFML/Graphics.hpp>
# include <iterator>

class Map {
class Map
{
private:
std::vector<std::vector<int> > map;

std::vector<std::vector<int>> map;
public:
int checkMap(double, double);
Map(std::vector<std::vector<int> >);
std::vector<std::vector<int> > getMap();
void cleanElement(double, double);
void Draw(sf::RenderWindow*);
};
/* fingerprint packman for monster IA */
int packmanPrint[3][2];

int checkMap(double, double);

int checkWays(double, double);

Map(std::vector<std::vector<int>>);

std::vector<std::vector<int>> getMap();

void cleanElement(double, double);

void Draw(sf::RenderWindow *);

void movePackmanFp(int, int, int, int, int);
};

#endif //PACKMAN_MAP_HH
Loading

0 comments on commit ef5a2df

Please sign in to comment.