Skip to content

Commit

Permalink
An adventure game, written in C++ with an Enscripten based front end!
Browse files Browse the repository at this point in the history
  • Loading branch information
EdShaw committed Jun 11, 2013
0 parents commit 2d14125
Show file tree
Hide file tree
Showing 27 changed files with 147,352 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
79 changes: 79 additions & 0 deletions Advent_Err.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
.\"See Also:
.\"man mdoc.samples for a complete listing of options
.\"man mdoc for the short list of editing options
.\"/usr/share/misc/mdoc.template
.Dd 10/06/2013 \" DATE
.Dt Advent-Err 1 \" Program name and manual section number
.Os Darwin
.Sh NAME \" Section Header - required - don't modify
.Nm Advent-Err,
.\" The following lines are read in generating the apropos(man -k) database. Use only key
.\" words here as the database is built based on the words here and in the .ND line.
.Nm Other_name_for_same_program(),
.Nm Yet another name for the same program.
.\" Use .Nm macro to designate other names for the documented program.
.Nd This line parsed for whatis database.
.Sh SYNOPSIS \" Section Header - required - don't modify
.Nm
.Op Fl abcd \" [-abcd]
.Op Fl a Ar path \" [-a path]
.Op Ar file \" [file]
.Op Ar \" [file ...]
.Ar arg0 \" Underlined argument - use .Ar anywhere to underline
arg2 ... \" Arguments
.Sh DESCRIPTION \" Section Header - required - don't modify
Use the .Nm macro to refer to your program throughout the man page like such:
.Nm
Underlining is accomplished with the .Ar macro like this:
.Ar underlined text .
.Pp \" Inserts a space
A list of items with descriptions:
.Bl -tag -width -indent \" Begins a tagged list
.It item a \" Each item preceded by .It macro
Description of item a
.It item b
Description of item b
.El \" Ends the list
.Pp
A list of flags and their descriptions:
.Bl -tag -width -indent \" Differs from above in tag removed
.It Fl a \"-a flag as a list item
Description of -a flag
.It Fl b
Description of -b flag
.El \" Ends the list
.Pp
.\" .Sh ENVIRONMENT \" May not be needed
.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
.\" .It Ev ENV_VAR_1
.\" Description of ENV_VAR_1
.\" .It Ev ENV_VAR_2
.\" Description of ENV_VAR_2
.\" .El
.Sh FILES \" File used or created by the topic of the man page
.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
.It Pa /usr/share/file_name
FILE_1 description
.It Pa /Users/joeuser/Library/really_long_file_name
FILE_2 description
.El \" Ends the list
.\" .Sh DIAGNOSTICS \" May not be needed
.\" .Bl -diag
.\" .It Diagnostic Tag
.\" Diagnostic informtion here.
.\" .It Diagnostic Tag
.\" Diagnostic informtion here.
.\" .El
.Sh SEE ALSO
.\" List links in ascending order by section, alphabetically within a section.
.\" Please do not reference files that do not exist without filing a bug report
.Xr a 1 ,
.Xr b 1 ,
.Xr c 1 ,
.Xr a 2 ,
.Xr b 2 ,
.Xr a 3 ,
.Xr b 3
.\" .Sh BUGS \" Document known, unremedied bugs
.\" .Sh HISTORY \" Document history if command behaves in a unique manner
37 changes: 37 additions & 0 deletions GameEngine.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// GameEngine.cpp
// Advent-Err
//
// Created by Ed Shaw on 10/06/2013.
// Copyright (c) 2013 Ed Shaw. All rights reserved.
//

#include "GameEngine.h"

GameEngine::GameEngine(){
GameEngine::quitter = [](){};
}

GameEngine::GameEngine(std::function<void()> quitter){
GameEngine::quitter = quitter;
}

GameEngine::~GameEngine(){

}

std::string GameEngine::play(const std::string input){

auto output = "Error!";

if (input.compare("test") == 0){
output = "Hello World!";
} else if (input.compare("quit game") == 0){
quitter();
output = "Goodbye!";
} else {
output = "I have, like, no idea what you just said.";
}

return output;
}
27 changes: 27 additions & 0 deletions GameEngine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// GameEngine.h
// Advent-Err
//
// Created by Ed Shaw on 10/06/2013.
// Copyright (c) 2013 Ed Shaw. All rights reserved.
//

#ifndef __Advent_Err__GameEngine__
#define __Advent_Err__GameEngine__

#include <iostream>

class GameEngine{

public:
GameEngine();
GameEngine(std::function<void()> quitter);
~GameEngine();

std::string play(const std::string input);

private:
std::function<void()> quitter;
};

#endif /* defined(__Advent_Err__GameEngine__) */
23 changes: 23 additions & 0 deletions emscripten.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// emscripten.cpp
// Advent-Err
//
// Created by Ed Shaw on 11/06/2013.
// Copyright (c) 2013 Ed Shaw. All rights reserved.
//
// Defines emscripten bindings for access to GameEngine class.
// https://github.com/kripken/emscripten/wiki/embind
//

#include <emscripten/bind.h>

#include "GameEngine.h"

using namespace emscripten;

EMSCRIPTEN_BINDINGS(module){
class_<GameEngine>("GameEngine")
.constructor<>()
.function("play", &GameEngine::play)
;
}
38 changes: 38 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// main.cpp
// Advent-Err
//
// Created by Ed Shaw on 10/06/2013.
// Copyright (c) 2013 Ed Shaw. All rights reserved.
//

#include <iostream>
#include "GameEngine.h"

bool running = true;


void quit(){
running = false;
}


int main(int argc, const char * argv[])
{

// insert code here...
std::cout << "Hello, World!" << std::endl;


GameEngine game = GameEngine(std::bind(quit));

while (running){
std::string line;
std::cout << " > ";
std::getline(std::cin, line);
auto out = game.play(line);
std::cout << out << std::endl;
}

return 0;
}
Binary file added website/.DS_Store
Binary file not shown.
Loading

0 comments on commit 2d14125

Please sign in to comment.