Skip to content
Permalink
Browse files
Add starting maps
  • Loading branch information
soperd committed Mar 6, 2019
1 parent ffb0688 commit a82dad10447d918c0bbadd8e6b556737ae166ef2
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 7 deletions.
@@ -1,5 +1,12 @@
# cmake
build/
CMakeFiles/
CMakeCache.txt
cmake_install.cmake
Makefile

# output folder
bin/

# vscode
.vscode/
@@ -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)
@@ -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;
}
@@ -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.

0 comments on commit a82dad1

Please sign in to comment.