Добавлены локации и перемещение по ним
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "player.h"
|
||||
#pragma once
|
||||
#include "player.h"
|
||||
#include "location.h"
|
||||
#include <vector>
|
||||
|
||||
class Game {
|
||||
public:
|
||||
@@ -7,11 +9,20 @@ public:
|
||||
|
||||
private:
|
||||
bool isRunning = true;
|
||||
|
||||
Player player;
|
||||
std::vector<Location> locations;
|
||||
|
||||
void showMainMenu();
|
||||
void processCommand();
|
||||
void render();
|
||||
};
|
||||
|
||||
#pragma once
|
||||
void loadLocations();
|
||||
Location* getCurrentLocation();
|
||||
|
||||
void render();
|
||||
void processCommand();
|
||||
|
||||
void movePlayer(int dx, int dy);
|
||||
void handleTile(char tile);
|
||||
|
||||
bool solveRiddle(Location& location);
|
||||
};
|
||||
61
include/location.h
Normal file
61
include/location.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct Point {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
};
|
||||
|
||||
struct Chest {
|
||||
Point pos;
|
||||
int gold = 0;
|
||||
bool opened = false;
|
||||
};
|
||||
|
||||
struct Enemy {
|
||||
Point pos;
|
||||
std::string type;
|
||||
int hp = 50;
|
||||
};
|
||||
|
||||
struct NPC {
|
||||
Point pos;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
struct Riddle {
|
||||
int type = 0;
|
||||
std::string text;
|
||||
std::string answer;
|
||||
bool isSolved = false;
|
||||
};
|
||||
|
||||
class Location {
|
||||
public:
|
||||
int id = 0;
|
||||
std::string title;
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
int north = 0;
|
||||
int south = 0;
|
||||
int west = 0;
|
||||
int east = 0;
|
||||
|
||||
Point startPosition;
|
||||
Riddle riddle;
|
||||
|
||||
std::vector<std::string> map;
|
||||
std::vector<Chest> chests;
|
||||
std::vector<Enemy> enemies;
|
||||
std::vector<NPC> npcs;
|
||||
|
||||
bool loadFromFile(const std::string& path);
|
||||
|
||||
void draw(const Point& playerPosition) const;
|
||||
|
||||
bool isWalkable(int x, int y) const;
|
||||
char getTile(int x, int y) const;
|
||||
};
|
||||
@@ -1,20 +1,24 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "location.h"
|
||||
|
||||
class Player {
|
||||
public:
|
||||
std::string name = "Character Name";
|
||||
|
||||
int hp = 100;
|
||||
int atk = 1;
|
||||
int atk = 10;
|
||||
int gold = 0;
|
||||
|
||||
int currentLocation = 1;
|
||||
Point position;
|
||||
|
||||
int weaponId = 101;
|
||||
std::vector<int> items;
|
||||
|
||||
Player() {};
|
||||
Player(std::string _name);
|
||||
void showStats();
|
||||
};
|
||||
Player() = default;
|
||||
Player(std::string name);
|
||||
|
||||
#pragma once
|
||||
void showStats() const;
|
||||
};
|
||||
Reference in New Issue
Block a user