Added fileCommon, added freebie font, start listening to SDL Keyboard text input
This commit is contained in:
@@ -12,4 +12,4 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/room.cpp
|
||||
|
||||
add_library(Engine SHARED ${SOURCES})
|
||||
target_include_directories(Engine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/headers)
|
||||
target_include_directories(Engine PUBLIC ${CMAKE_SOURCE_DIR}/Extern)
|
||||
target_include_directories(Engine PUBLIC ${CMAKE_SOURCE_DIR}/Extern ${CMAKE_SOURCE_DIR}/Common)
|
||||
|
||||
@@ -50,39 +50,39 @@ int CommandParser::Parse() {
|
||||
FUNCTION toRun;
|
||||
|
||||
|
||||
printf("Please Enter a command \n");
|
||||
printf("> ");
|
||||
getline(std::cin, cmd);
|
||||
std::cin.clear();
|
||||
cmd[0] = toupper(cmd[0]);
|
||||
std::stringstream c(cmd);
|
||||
/*
|
||||
printf("Please Enter a command \n");
|
||||
printf("> ");
|
||||
|
||||
verbs = Verb(c);
|
||||
nouns = Noun(c);
|
||||
cmd[0] = toupper(cmd[0]);
|
||||
std::stringstream c(cmd);
|
||||
|
||||
for (const auto &verb: verbs) {
|
||||
if (!commands[verb]) {
|
||||
CommandUnrecognized();
|
||||
break;
|
||||
verbs = Verb(c);
|
||||
nouns = Noun(c);
|
||||
|
||||
for (const auto &verb: verbs) {
|
||||
if (!commands[verb]) {
|
||||
CommandUnrecognized();
|
||||
break;
|
||||
}
|
||||
|
||||
for (const auto &n: nouns) {
|
||||
noun = n;
|
||||
}
|
||||
|
||||
toRun = commands[verb];
|
||||
}
|
||||
|
||||
for (const auto &n: nouns) {
|
||||
noun = n;
|
||||
if (toRun) {
|
||||
toRun(noun);
|
||||
}
|
||||
|
||||
toRun = commands[verb];
|
||||
}
|
||||
cmd.clear();
|
||||
word.clear();
|
||||
verbs.clear();
|
||||
nouns.clear();
|
||||
c.clear();
|
||||
|
||||
if (toRun) {
|
||||
toRun(noun);
|
||||
}
|
||||
cmd.clear();
|
||||
word.clear();
|
||||
verbs.clear();
|
||||
nouns.clear();
|
||||
c.clear();
|
||||
|
||||
toRun = nullptr;
|
||||
toRun = nullptr;*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+10
-18
@@ -1,7 +1,7 @@
|
||||
#include "game.h"
|
||||
#include <cstdio>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include "fileCommon.h"
|
||||
#include "player.h"
|
||||
|
||||
std::vector<std::vector<Room>> rooms;
|
||||
@@ -21,38 +21,30 @@ bool Game::Init() {
|
||||
rooms[i].resize(MAP_WIDTH);
|
||||
}
|
||||
|
||||
filePath = fs::absolute(filePath);
|
||||
|
||||
|
||||
if (!fs::exists(filePath)) {
|
||||
printf("File Read error! Could not find Json at: \n");
|
||||
printf("%s", filePath.c_str());
|
||||
isActive = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Read rooms into buffer
|
||||
stream.open(absolute(filePath));
|
||||
json = nlohmann::json::parse(stream);
|
||||
isActive = OpenFile(filePath);
|
||||
json = GetData();
|
||||
isActive = (json != NULL);
|
||||
|
||||
rooms = json.get<std::vector<std::vector<Room>>>();
|
||||
player.Init();
|
||||
parser = CommandParser();
|
||||
|
||||
CloseFileStream(); // We're done with it. Let's make sure it's closed!
|
||||
|
||||
parser = CommandParser();
|
||||
parser.AddCommand("Exit", Quit);
|
||||
parser.AddCommand("Move", Move);
|
||||
parser.AddCommand("Look", Look);
|
||||
|
||||
ChangeRoom(rooms[0][0]);
|
||||
|
||||
return true;
|
||||
return isActive;
|
||||
}
|
||||
|
||||
|
||||
void Game::Run() {
|
||||
parser.Parse();
|
||||
// Process game logic in here
|
||||
parser.Parse();
|
||||
// Process game logic in here
|
||||
}
|
||||
|
||||
bool Game::Save() { return false; }
|
||||
|
||||
Reference in New Issue
Block a user