-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathLevel_Load.h
More file actions
95 lines (82 loc) · 2.87 KB
/
Level_Load.h
File metadata and controls
95 lines (82 loc) · 2.87 KB
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
#ifndef LEVEL_LOAD
#define LEVEL_LOAD
#include <string>
#include <fstream>
#include <vector>
#include <Windows.h>
#include "BoolEngine/BoolEngine.h"
const float SCREEN_WIDTH = GetSystemMetrics(SM_CXSCREEN);
const float SCREEN_HEIGHT = GetSystemMetrics(SM_CYSCREEN) - GetSystemMetrics(SM_CYSCREEN) * 1 / 10;
const std::string LEVEL_DATAPATH = "/levels/";
//Files will be located in this directory
const std::string MAP_INFO = "levels.lv";
const std::string EXTENSION = ".lv";
//This file indexes all of the other map files
const double PI = 3.14159265358979323846264338327950288419716939937510582097;
const float INITIAL_LEVEL_POS_X = SCREEN_WIDTH * 1 / 4;
const float INITIAL_LEVEL_POS_Y = SCREEN_HEIGHT * 1 / 4;
const float LEVEL_LENGTH_X = SCREEN_WIDTH * 1 / 2;
const float LEVEL_LENGTH_Y = SCREEN_HEIGHT * 2 / 3;
enum tGame_Element
{
CLOSED_WALL, HORIZ_OPEN_WALL, VERT_OPEN_WALL, CLOSED_WALL_3_0DEG, CLOSED_WALL_3_90DEG, CLOSED_WALL_3_180DEG,
CLOSED_WALL_3_270DEG, CLOSED_WALL_2_0DEG, CLOSED_WALL_2_90DEG, CLOSED_WALL_2_180DEG, CLOSED_WALL_2_270DEG,
INTERIOR_WALL, CLOSED_WALL_1_0DEG, CLOSED_WALL_1_90DEG, CLOSED_WALL_1_180DEG, CLOSED_WALL_1_270DEG, PELLET,
POWER_UP, PLAYER, RED_GHOST, BLUE_GHOST, ORANGE_GHOST, PINK_GHOST, CHERRY, PINEAPPLE, WATERMELON, EMPTY,
EMPTY_WALL, MISTAKE, INITIAL, BONUS_POINT
};
struct tGame {
tGame_Element elem;
ALLEGRO_BITMAP *sprite;
float pixel_position[2];
};
class Level
{
public:
Level();
void GameReset();
void LoadLevel();
void NextLevel();
void SetMapElem(int i, int j, tGame_Element elem);
tGame_Element CharacterTransform(const char& c);
ALLEGRO_BITMAP *GameElementToBitmap(const tGame_Element elem);
float AngleFromElement(const tGame_Element & aux); //Check angles
void IncreaseLevel();
void ResetBonusCounter();
void SetBonusCounter(int i);
void setCurrentLevel(int l);
void RefreshBonus();
int GetNumMap() const;
int GetCurrentLevel() const;
int GetSize(int i = -1) const;
int GetObjective() const;
tGame_Element GetElement(int i, int j) const;
ALLEGRO_BITMAP *GetBitmap(int i, int j) const;
float GetPixelPositionX(int j) const;
float GetPixelPositionY(int i) const;
std::vector<std::vector<tGame>> GetMap() const;
int GetRowPixelElem() const;
int GetColumnPixelElem() const;
int GetBonusCounter() const;
int GetPacmanXPos() const;
int GetPacmanYPos() const;
int GetRedGhostXPos() const;
int GetRedGhostYPos() const;
int GetPinkGhostXPos() const;
int GetPinkGhostYPos() const;
int GetOrangeGhostXPos() const;
int GetOrangeGhostYPos() const;
int GetBlueGhostXPos() const;
int GetBlueGhostYPos() const;
int GetHouseXPos() const;
int GetHouseYPos() const;
~Level();
private:
void destroyMap();
int currentLevel, num_map, objective,
pacman_pos[2], rg_pos[2], pg_pos[2], og_pos[2],
bg_pos[2], house_pos[2], bonus_pos[2], bonus_counter;
std::vector<std::vector<tGame>> map;
float row_pixel_elem, column_pixel_elem;
};
#endif