Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
90 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
# cmake | ||
build/ | ||
CMakeFiles/ | ||
CMakeCache.txt | ||
cmake_install.cmake | ||
Makefile | ||
|
||
# output folder | ||
bin/ | ||
|
||
# vscode | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
cmake_minimum_required(VERSION 2.8) | ||
project(grandmaze-game) | ||
|
||
add_executable(grandmaze-game main.cpp) | ||
target_link_libraries(grandmaze-game ncurses) | ||
target_link_libraries(grandmaze-game grandmaze) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin") | ||
|
||
# get all cpp and hpp files | ||
file(GLOB source main.cpp main.hpp "*.cpp" "*.hpp") | ||
|
||
add_executable(grandmaze-game ${source}) | ||
|
||
target_link_libraries(grandmaze-game ncurses sqlite3 grandmaze) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,74 @@ | ||
#include <unistd.h> | ||
#include <cstring> | ||
#include <iostream> | ||
|
||
#include <ncurses.h> | ||
#include <libgrandmaze/colour.hpp> | ||
#include <libgrandmaze/mapfile.hpp> | ||
|
||
#include <libgrandmaze/room.hpp> | ||
#include "main.hpp" | ||
|
||
int main(int argc, char *argv[]) | ||
int initialise(void) | ||
{ | ||
int error = setCwd(); | ||
if (error) | ||
{ | ||
return error; | ||
} | ||
|
||
initHub(); | ||
|
||
initscr(); | ||
cbreak(); | ||
noecho(); | ||
|
||
start_color(); | ||
curs_set(0); | ||
keypad(stdscr, true); | ||
|
||
GrandMaze::Room r(GrandMaze::RoomType::Square, 0, 0); | ||
r.draw(stdscr); | ||
GrandMaze::initColour(); | ||
|
||
return 0; | ||
} | ||
|
||
int initHub(void) | ||
{ | ||
GrandMaze::FileMapReader r; | ||
CurrentMap = r.load(Cwd + "/maps/final_map.map"); | ||
|
||
return 0; | ||
} | ||
|
||
int setCwd(void) | ||
{ | ||
// set the current working directory | ||
char *tmp = new char[1024]; | ||
if (getcwd(tmp, 1024) == NULL) | ||
{ | ||
return errno; | ||
} | ||
|
||
Cwd = tmp; | ||
delete tmp; | ||
|
||
return 0; | ||
} | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
int error = initialise(); | ||
if (error) | ||
{ | ||
std::cerr << "An error occurred: " << strerror(error) << std::endl; | ||
return error; | ||
} | ||
|
||
CurrentMap->draw(stdscr); | ||
|
||
getch(); | ||
|
||
endwin(); | ||
delete CurrentMap; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef MAIN_H | ||
#define MAIN_H | ||
|
||
#include <string> | ||
|
||
#include <libgrandmaze/map.hpp> | ||
|
||
|
||
GrandMaze::Map *CurrentMap; | ||
std::string Cwd; | ||
|
||
int initialise(void); | ||
int initHub(void); | ||
int setCwd(void); | ||
|
||
#endif |
BIN
+213 Bytes
maps/final_map.map
Binary file not shown.
BIN
+42 Bytes
maps/hub.map
Binary file not shown.