parent
6f25b81081
commit
56c4f158fc
@ -0,0 +1,168 @@
|
||||
#include "App.h"
|
||||
#include <windows.h>
|
||||
#include <iostream>
|
||||
#include "Map.h"
|
||||
|
||||
|
||||
// ========== Constructors =============
|
||||
App::App() {
|
||||
window = new sf::RenderWindow(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "SFML works!");
|
||||
}
|
||||
App::~App() { }
|
||||
|
||||
// ========== Mutes =============
|
||||
void App::Init() {
|
||||
|
||||
// Set up the background texture
|
||||
background_texture = new sf::Texture();
|
||||
background_texture->loadFromFile("background.png");
|
||||
|
||||
backgroundSprite.setTexture(*background_texture);
|
||||
|
||||
_pixelArray = new sf::Uint8[WINDOW_WIDTH * WINDOW_HEIGHT * 4];
|
||||
pixel_array_texture.create(WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||
|
||||
explorer = new Explorer(&map);
|
||||
}
|
||||
|
||||
void App::Input() {
|
||||
while (window->pollEvent(event)) {
|
||||
if (event.type == sf::Event::Closed)
|
||||
window->close();
|
||||
if (event.type == sf::Event::KeyPressed) {
|
||||
if (event.key.code == sf::Keyboard::Space) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void App::Update(double step_size) {
|
||||
Input();
|
||||
}
|
||||
|
||||
void App::Render() {
|
||||
|
||||
|
||||
// HOUSEKEEPING
|
||||
// Get the physics fps for the last render cycle
|
||||
physics_fps = physics_frame_count * render_fps;
|
||||
|
||||
// Frame time in seconds
|
||||
frame_time = delta_time * 1000;
|
||||
|
||||
// And the render fps
|
||||
render_fps = 1000 / frame_time;
|
||||
|
||||
|
||||
|
||||
// RENDERING
|
||||
|
||||
window->clear(sf::Color::Blue);
|
||||
window->draw(backgroundSprite);
|
||||
|
||||
sf::Vector2i pos;
|
||||
for (int i = 0; i < WINDOW_WIDTH * WINDOW_HEIGHT * 4; i++) {
|
||||
_pixelArray[i] = 0;
|
||||
}
|
||||
|
||||
// Draw the tiles
|
||||
for (int x = 0; x < Map::CELLS_WIDTH; x++) {
|
||||
for (int y = 0; y < Map::CELLS_HEIGHT; y++) {
|
||||
|
||||
pos.x = x;
|
||||
pos.y = y;
|
||||
sf::Color thing = map.getTile(pos)->getColor();
|
||||
|
||||
|
||||
for (int x2 = 1; x2 < 5; x2++) {
|
||||
for (int y2 = 1; y2 < 5; y2++) {
|
||||
|
||||
int pixel_x = (x * 5) + x2;
|
||||
int pixel_y = (y * 5) + y2;
|
||||
|
||||
_pixelArray[(pixel_y * WINDOW_WIDTH + pixel_x) * 4] = thing.r; // Red
|
||||
_pixelArray[(pixel_y * WINDOW_WIDTH + pixel_x) * 4 + 1] = thing.g; // Green
|
||||
_pixelArray[(pixel_y * WINDOW_WIDTH + pixel_x) * 4 + 2] = thing.b; // Blue
|
||||
_pixelArray[(pixel_y * WINDOW_WIDTH + pixel_x) * 4 + 3] = thing.a; // Alpha
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the player
|
||||
|
||||
for (int x2 = 1; x2 < 5; x2++) {
|
||||
for (int y2 = 1; y2 < 5; y2++) {
|
||||
|
||||
int pixel_x = (explorer->getPosition().x * 5) + x2;
|
||||
int pixel_y = (explorer->getPosition().y * 5) + y2;
|
||||
|
||||
sf::Color color = explorer->getColor();
|
||||
|
||||
_pixelArray[(pixel_y * WINDOW_WIDTH + pixel_x) * 4] = color.r; // Red
|
||||
_pixelArray[(pixel_y * WINDOW_WIDTH + pixel_x) * 4 + 1] = color.g; // Green
|
||||
_pixelArray[(pixel_y * WINDOW_WIDTH + pixel_x) * 4 + 2] = color.b; // Blue
|
||||
_pixelArray[(pixel_y * WINDOW_WIDTH + pixel_x) * 4 + 3] = color.a; // Alpha
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
pixel_array_texture.update(_pixelArray);
|
||||
|
||||
pixel_array_sprite.setTexture(pixel_array_texture);
|
||||
window->draw(pixel_array_sprite);
|
||||
|
||||
window->display();
|
||||
}
|
||||
|
||||
|
||||
void App::Run() {
|
||||
Init();
|
||||
|
||||
while (window->isOpen()) {
|
||||
// Time since app start
|
||||
elapsed_time = time();
|
||||
|
||||
// Time between last frame start and this frame
|
||||
// 2 seconds = 30 seconds - 28 seconds
|
||||
delta_time = elapsed_time - current_time;
|
||||
current_time = elapsed_time;
|
||||
|
||||
// Make sure we aren't taking too big of steps when lagging
|
||||
if (delta_time > 0.02f)
|
||||
delta_time = 0.02f;
|
||||
|
||||
// Add the delta time to the leftover time from the last frame
|
||||
accumulator_time += delta_time;
|
||||
|
||||
// While there is time left
|
||||
while ((accumulator_time - step_size) >= step_size) {
|
||||
// Take away the time we will be simulating
|
||||
accumulator_time -= step_size;
|
||||
|
||||
// Update the game for the timestep
|
||||
Update(step_size);
|
||||
|
||||
physics_frame_count++;
|
||||
}
|
||||
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
float App::time() {
|
||||
static __int64 start = 0;
|
||||
static __int64 frequency = 0;
|
||||
|
||||
if (start == 0) {
|
||||
QueryPerformanceCounter((LARGE_INTEGER*)&start);
|
||||
QueryPerformanceFrequency((LARGE_INTEGER*)&frequency);
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
__int64 counter = 0;
|
||||
QueryPerformanceCounter((LARGE_INTEGER*)&counter);
|
||||
return (float)((counter - start) / double(frequency));
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
#pragma once
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include "Map.h"
|
||||
#include "Explorer.h"
|
||||
|
||||
class App {
|
||||
public:
|
||||
// Constants
|
||||
static const int WINDOW_HEIGHT = 766;
|
||||
static const int WINDOW_WIDTH = 1596;
|
||||
const double PI = 3.141592653589793238462643383279;
|
||||
|
||||
App();
|
||||
~App();
|
||||
|
||||
// Start the app
|
||||
void Run();
|
||||
|
||||
private:
|
||||
|
||||
Map map;
|
||||
sf::Uint8* _pixelArray;
|
||||
sf::Sprite pixel_array_sprite;
|
||||
sf::Texture pixel_array_texture;
|
||||
|
||||
Explorer* explorer;
|
||||
|
||||
// Art assets
|
||||
sf::Texture* background_texture;
|
||||
|
||||
sf::Sprite backgroundSprite;
|
||||
|
||||
void Init();
|
||||
void Input();
|
||||
void Update(double step_size);
|
||||
void Render();
|
||||
|
||||
// The main render window, probably should think about supporting multiple of these
|
||||
sf::RenderWindow* window;
|
||||
// The events for the event handler
|
||||
sf::Event event;
|
||||
|
||||
// Loop management data, black magic, need to redo
|
||||
float time();
|
||||
|
||||
// Size of the physics steps to take
|
||||
float step_size = 0.005f;
|
||||
|
||||
double current_time = 0.0;
|
||||
double frame_time = 0.0;
|
||||
double instant_fps = 0.0;
|
||||
double accumulator_time = 0.0;
|
||||
|
||||
int render_frame_count = 0;
|
||||
double render_fps = 0;
|
||||
|
||||
int physics_frame_count = 0;
|
||||
double physics_fps = 0;
|
||||
|
||||
double elapsed_time = 0;
|
||||
double delta_time = 0;
|
||||
};
|
@ -0,0 +1,79 @@
|
||||
#include "Explorer.h"
|
||||
#include <iostream>
|
||||
|
||||
Explorer::Explorer(Map* map_) {
|
||||
color = sf::Color::Blue;
|
||||
position = sf::Vector2i(10, 10);
|
||||
map = map_;
|
||||
}
|
||||
|
||||
|
||||
Explorer::~Explorer() {
|
||||
}
|
||||
|
||||
sf::Vector2i Explorer::getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
sf::Color Explorer::getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
bool Explorer::move() {
|
||||
|
||||
// While there are moves for us to take
|
||||
if (!movement_stack.empty()) {
|
||||
bool valid = false; // If the next move is valid, collision
|
||||
int x = movement_stack.top();
|
||||
|
||||
switch (x) {
|
||||
|
||||
case 0: // North
|
||||
if (!map->getTile(position.x, position.y - 1)->isSolid()) {
|
||||
valid = true;
|
||||
position = sf::Vector2i(position.x, position.y - 1);
|
||||
}
|
||||
break;
|
||||
case 1: // East
|
||||
if (!map->getTile(position.x + 1, position.y)->isSolid()) {
|
||||
valid = true;
|
||||
position = sf::Vector2i(position.x + 1, position.y);
|
||||
}
|
||||
break;
|
||||
case 2: // South
|
||||
if (!map->getTile(position.x, position.y + 1)->isSolid()) {
|
||||
valid = true;
|
||||
position = sf::Vector2i(position.x, position.y + 1);
|
||||
}
|
||||
break;
|
||||
case 3: // West
|
||||
if (!map->getTile(position.x - 1, position.y)->isSolid()) {
|
||||
valid = true;
|
||||
position = sf::Vector2i(position.x - 1, position.y);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// If the path was blocked
|
||||
if (!valid) {
|
||||
std::cout << "Path blocked" << std::endl;
|
||||
// Flush the moves list
|
||||
while(!movement_stack.empty()) {
|
||||
movement_stack.pop();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// If everything went well, pop and return true
|
||||
movement_stack.pop();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// A*
|
||||
bool Explorer::plan(sf::Vector2i destination_) {
|
||||
|
||||
return true;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <stack>
|
||||
#include "Map.h"
|
||||
|
||||
class Explorer {
|
||||
public:
|
||||
Explorer(Map* map_);
|
||||
~Explorer();
|
||||
sf::Vector2i getPosition();
|
||||
sf::Color getColor();
|
||||
private:
|
||||
sf::Color color;
|
||||
sf::Vector2i position;
|
||||
Map* map;
|
||||
|
||||
std::stack<int> movement_stack;
|
||||
bool move();
|
||||
bool plan(sf::Vector2i destination_);
|
||||
};
|
||||
|
@ -0,0 +1,56 @@
|
||||
#include "Map.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
Map::Map() {
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
Map::~Map() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
Tile* Map::getTile(sf::Vector2i position_) {
|
||||
if (position_.x > CELLS_WIDTH || position_.x < 0
|
||||
|| position_.y > CELLS_HEIGHT || position_.y < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return tileArray[position_.x][position_.y];
|
||||
}
|
||||
|
||||
bool Map::isTileSolid(sf::Vector2i position_) {
|
||||
if (position_.x > CELLS_WIDTH || position_.x < 0
|
||||
|| position_.y > CELLS_HEIGHT || position_.y < 0) {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return tileArray[position_.x][position_.y]->isSolid();
|
||||
}
|
||||
Tile* Map::getTile(int x_, int y_) {
|
||||
return tileArray[x_][y_];
|
||||
}
|
||||
|
||||
void Map::setTile(sf::Vector2i position, Tile* data) {
|
||||
delete tileArray[position.x][position.y];
|
||||
tileArray[position.x][position.y] = data;
|
||||
}
|
||||
|
||||
void Map::Init() {
|
||||
int q;
|
||||
|
||||
for (int x = 0; x < CELLS_WIDTH; x++) {
|
||||
for (int y = 0; y < CELLS_HEIGHT; y++) {
|
||||
q = rand() % 100;
|
||||
if (q > 70) {
|
||||
tileArray[x][y] = new Tile(true, 100.0, sf::Color::Cyan);
|
||||
}
|
||||
else {
|
||||
tileArray[x][y] = new Tile(false, 0.0, sf::Color::Red);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "Tile.h"
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
|
||||
class Map {
|
||||
public:
|
||||
static const int CELLS_HEIGHT = 153;
|
||||
static const int CELLS_WIDTH = 319;
|
||||
|
||||
Map();
|
||||
~Map();
|
||||
|
||||
|
||||
Tile* getTile(sf::Vector2i position);
|
||||
Tile* getTile(int x_, int y_);
|
||||
bool isTileSolid(sf::Vector2i);
|
||||
void setTile(sf::Vector2i position, Tile* data);
|
||||
|
||||
private:
|
||||
void Init();
|
||||
|
||||
Tile* tileArray[319][153];
|
||||
};
|
||||
|
@ -0,0 +1,197 @@
|
||||
#include "Pather.h"
|
||||
#include <iostream>
|
||||
|
||||
node::node(sf::Vector2i XY, int h, int cF, int cL, node* p, Pather* pather_) {
|
||||
xy = XY;
|
||||
hueristic = h;
|
||||
cameFrom = cF;
|
||||
closedList = cL;
|
||||
parent = p;
|
||||
pather = pather_;
|
||||
}
|
||||
node::node() {
|
||||
|
||||
}
|
||||
node::~node() {
|
||||
|
||||
}
|
||||
|
||||
void node::neighbors() {
|
||||
|
||||
int x = pather->getEndNodePosition().x;
|
||||
int y = pather->getEndNodePosition().y;
|
||||
|
||||
sf::Vector2i dest0XY(xy.x, xy.y - 1); // North
|
||||
if (!pather->map->isTileSolid(dest0XY) && pather->visitedMap[dest0XY.x][dest0XY.y] != 1) {
|
||||
// If so, find the distance between this node and the end node, the hueristic
|
||||
int tempx = (x - dest0XY.x);
|
||||
int tempy = (y - dest0XY.y);
|
||||
|
||||
// I think dv is the hueristic??
|
||||
double dv = sqrt((tempx * tempx) + (tempy * tempy));
|
||||
|
||||
int v = static_cast<int>(dv);
|
||||
|
||||
// Take that value and create a new node
|
||||
pather->openList.emplace(new node(dest0XY, v, 0, 1, pather->active_node, pather), v);
|
||||
|
||||
// Set that tile as visited so we don't get stuck in a loop
|
||||
pather->visitedMap[dest0XY.x][dest0XY.y] = 1;
|
||||
}
|
||||
|
||||
sf::Vector2i dest1XY(xy.x + 1, xy.y); // East
|
||||
if (!pather->map->isTileSolid(dest1XY) && pather->visitedMap[dest1XY.x][dest1XY.y] != 1) {
|
||||
// If so, find the distance between this node and the end node, the hueristic
|
||||
int tempx = (x - dest1XY.x);
|
||||
int tempy = (y - dest1XY.y);
|
||||
|
||||
// I think dv is the hueristic??
|
||||
double dv = sqrt((tempx * tempx) + (tempy * tempy));
|
||||
|
||||
int v = static_cast<int>(dv);
|
||||
|
||||
// Take that value and create a new node
|
||||
pather->openList.emplace(new node(dest1XY, v, 0, 1, pather->active_node, pather), v);
|
||||
|
||||
// Set that tile as visited so we don't get stuck in a loop
|
||||
pather->visitedMap[dest1XY.x][dest1XY.y] = 1;
|
||||
}
|
||||
|
||||
sf::Vector2i dest2XY(xy.x, xy.y + 1); // South
|
||||
if (!pather->map->isTileSolid(dest2XY) && pather->visitedMap[dest2XY.x][dest2XY.y] != 1) {
|
||||
// If so, find the distance between this node and the end node, the hueristic
|
||||
int tempx = (x - dest2XY.x);
|
||||
int tempy = (y - dest2XY.y);
|
||||
|
||||
// I think dv is the hueristic??
|
||||
double dv = sqrt((tempx * tempx) + (tempy * tempy));
|
||||
|
||||
int v = static_cast<int>(dv);
|
||||
|
||||
// Take that value and create a new node
|
||||
pather->openList.emplace(new node(dest2XY, v, 0, 1, pather->active_node, pather), v);
|
||||
|
||||
// Set that tile as visited so we don't get stuck in a loop
|
||||
pather->visitedMap[dest2XY.x][dest2XY.y] = 1;
|
||||
}
|
||||
|
||||
sf::Vector2i dest3XY(xy.x - 1, xy.y); // West
|
||||
if (!pather->map->isTileSolid(dest3XY) && pather->visitedMap[dest3XY.x][dest3XY.y] != 1) {
|
||||
// If so, find the distance between this node and the end node, the hueristic
|
||||
int tempx = (x - dest3XY.x);
|
||||
int tempy = (y - dest3XY.y);
|
||||
|
||||
// I think dv is the hueristic??
|
||||
double dv = sqrt((tempx * tempx) + (tempy * tempy));
|
||||
|
||||
int v = static_cast<int>(dv);
|
||||
|
||||
// Take that value and create a new node
|
||||
pather->openList.emplace(new node(dest3XY, v, 0, 1, pather->active_node, pather), v);
|
||||
|
||||
// Set that tile as visited so we don't get stuck in a loop
|
||||
pather->visitedMap[dest3XY.x][dest3XY.y] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Pather::Pather(Map* map_) {
|
||||
map = map_;
|
||||
}
|
||||
|
||||
Pather::~Pather() {
|
||||
}
|
||||
|
||||
sf::Vector2i Pather::getEndNodePosition() {
|
||||
return end_node->xy;
|
||||
}
|
||||
|
||||
std::vector<int> Pather::pathTo(sf::Vector2i start, sf::Vector2i end) {
|
||||
|
||||
// Clear the visited map for erroneous data
|
||||
for (int i = 0; i < Map::CELLS_WIDTH; i++) {
|
||||
for (int l = 0; l < Map::CELLS_HEIGHT; l++) {
|
||||
visitedMap[i][l] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Place the start and end nodes
|
||||
start_node = new node(start, 0, 0, 0, nullptr, this);
|
||||
end_node = new node(end, 0, 0, 0, nullptr, this);
|
||||
|
||||
// Set the entry point, clean up any stray data from last run
|
||||
active_node = start_node;
|
||||
openList.clear();
|
||||
closedList.clear();
|
||||
|
||||
// Seed for the loop
|
||||
openList.emplace(start_node, 0);
|
||||
|
||||
early_exit = false;
|
||||
//path_list = Loop();
|
||||
|
||||
return path_list;
|
||||
}
|
||||
|
||||
|
||||
std::vector<int> Pather::loop() {
|
||||
while (!openList.empty() && !early_exit) {
|
||||
// Early exit jankyness, need to change this
|
||||
if (closedList.size() > 3000) {
|
||||
no_path = true;
|
||||
early_exit = true;
|
||||
break;
|
||||
}
|
||||
else if (active_node->xy.x == end_node->xy.x && end_node->xy.y == end_node->xy.y) {
|
||||
early_exit = true;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// Find the pair with the lowest hueristic
|
||||
// 5/10
|
||||
std::pair<node*, int> bestMin;
|
||||
for (auto testMin: openList) {
|
||||
if (bestMin.second < testMin.second)
|
||||
bestMin = testMin;
|
||||
}
|
||||
|
||||
// Find the neighbors for that node
|
||||
active_node->neighbors();
|
||||
|
||||
// Remove the active node from the openlist as you have visited it and called its neighbors
|
||||
openList.erase(active_node);
|
||||
|
||||
// Check to see if the node has already been added to the closed list, if not, add it
|
||||
if (closedList.count(active_node) > 0) {
|
||||
closedList.emplace(active_node, active_node->hueristic);
|
||||
}
|
||||
|
||||
// Set the new active node to the lowest hueristic that we found earlier
|
||||
active_node = bestMin.first;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> return_path = returnPath();
|
||||
if (no_path || return_path.empty()) {
|
||||
return std::vector<int>(0, 0);
|
||||
std::cout << " no return path " << std::endl;
|
||||
}
|
||||
|
||||
return return_path;
|
||||
}
|
||||
|
||||
std::vector<int> Pather::returnPath() {
|
||||
std::vector<int> path;
|
||||
|
||||
while (active_node != nullptr) {
|
||||
path.push_back(active_node->cameFrom);
|
||||
delete active_node;
|
||||
active_node = active_node->parent;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
#include <map>
|
||||
#include "App.h"
|
||||
#include <unordered_map>
|
||||
|
||||
class Pather;
|
||||
|
||||
class node {
|
||||
public:
|
||||
|
||||
node(sf::Vector2i XY, int h, int cF, int cL, node* p, Pather* pather_);
|
||||
node();
|
||||
~node();
|
||||
|
||||
sf::Vector2i xy;
|
||||
|
||||
// Ugh, pointers, ugh c++
|
||||
node* parent;
|
||||
int hueristic;
|
||||
int cameFrom;
|
||||
int closedList;
|
||||
Pather* pather;
|
||||
|
||||
void neighbors();
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
class Pather {
|
||||
public:
|
||||
Pather(Map* map_);
|
||||
~Pather();
|
||||
|
||||
Map* map;
|
||||
|
||||
std::unordered_map<node*, int> openList;
|
||||
std::unordered_map<node*, int> closedList;
|
||||
int visitedMap[App::WINDOW_HEIGHT][App::WINDOW_WIDTH];
|
||||
|
||||
std::vector<int> pathTo(sf::Vector2i start, sf::Vector2i end);
|
||||
std::vector<int> loop();
|
||||
std::vector<int> returnPath();
|
||||
|
||||
sf::Vector2i getEndNodePosition();
|
||||
|
||||
node* start_node;
|
||||
node* active_node;
|
||||
|
||||
bool no_path = false;
|
||||
bool early_exit;
|
||||
|
||||
private:
|
||||
|
||||
std::vector<int> path_list;
|
||||
node* end_node;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
#include "Tile.h"
|
||||
|
||||
|
||||
|
||||
Tile::Tile(bool solid_, double movement_penalty_, sf::Color color_) {
|
||||
solid = solid_;
|
||||
movement_penalty = movement_penalty_;
|
||||
color = color_;
|
||||
}
|
||||
|
||||
|
||||
Tile::Tile() {
|
||||
solid = false;
|
||||
movement_penalty = 0.0;
|
||||
color = sf::Color::Red;
|
||||
}
|
||||
|
||||
Tile::~Tile() {
|
||||
}
|
||||
|
||||
bool Tile::isSolid() {
|
||||
return solid;
|
||||
}
|
||||
|
||||
double Tile::getPenalty() {
|
||||
return movement_penalty;
|
||||
}
|
||||
|
||||
sf::Color Tile::getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
void Tile::Rewrite(bool solid_, double movement_penalty_, sf::Color color_) {
|
||||
solid = solid_;
|
||||
movement_penalty = movement_penalty_;
|
||||
color = color_;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include <SFML\Graphics.hpp>
|
||||
|
||||
class Tile {
|
||||
public:
|
||||
Tile(bool solid_, double movement_penalty_, sf::Color color_);
|
||||
Tile();
|
||||
~Tile();
|
||||
|
||||
bool isSolid();
|
||||
double getPenalty();
|
||||
sf::Color getColor();
|
||||
void Rewrite(bool solid_, double movement_penalty_, sf::Color color_);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
bool solid = false;
|
||||
double movement_penalty = 0.0;
|
||||
sf::Color color;
|
||||
};
|
||||
|
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="App.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Map.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Explorer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Tile.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Pather.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="App.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Map.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Explorer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Tile.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Pather.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
After Width: | Height: | Size: 6.2 KiB |
@ -0,0 +1,12 @@
|
||||
#include <SFML/Window.hpp>
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include "App.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
App app;
|
||||
app.Run();
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
Loading…
Reference in new issue