Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Cameras/example1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
wa 1
i Hello!
wa 3
i Welcome to the example!
wa 5
i I just waited until the 5 second mark! This should have looked like two seconds to you.
wr 4
i I just waited 4 seconds.
wa 10
i This should pop up at the 10 second mark
wa 12
i Let's change cameras
wa 15
camera example2
35 changes: 35 additions & 0 deletions Cameras/example2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
wa 1
oa 20 this camera has been waiting for you for a while. 15 seconds, give or take.
i Waiting for camera to change
wa 5
i Still waiting
wa 10
i STIIIIIILLLL waiting
wa 15
i Hello! This is a different camera!
wa 17
i I can also pause your game. Behold!
p
i Welcome back! Sorry for pausing you so abruptly
wa 20
i I can also pause your game without it telling you that it's paused, like so (press enter to continue):
ps
i Isn't that cool!?
wa 22
i And unnecessary!?
wa 23
i ...
wa 24
i ...
wa 25
i yes, it probably is
wa 27
i ...
wa 29
i ...
wa 31
i Oh well, all's well that ends well.
wa 33
i Such as this game
wa 34
q
6 changes: 6 additions & 0 deletions Cameras/start.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
i Hello!
wa 4
i You are now 5 seconds into the game.
wa 5
i 1 second has passed since the previous message
q
30 changes: 30 additions & 0 deletions Cameras/test1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
i test1 seconds: 0
oa 10 test1 seconds: 0
wa 1
i test1 seconds: 1
oa 10 test1 seconds: 1
wa 2
i test1 seconds: 2
oa 10 test1 seconds: 2
wa 3
i test1 seconds: 3
oa 10 test1 seconds: 3
wa 4
i test1 seconds: 4
oa 10 test1 seconds: 4
wa 5
i test1 seconds: 5
oa 10 test1 seconds: 5
wa 6
i test1 seconds: 6
oa 10 test1 seconds: 6
wa 7
i test1 seconds: 7
oa 10 test1 seconds: 7
wa 8
i test1 seconds: 8
oa 10 test1 seconds: 8
wa 9
i test1 seconds: 9
oa 10 test1 seconds: 9
q
30 changes: 30 additions & 0 deletions Cameras/test2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
i test2 seconds: 0
oa 10 test2 seconds: 0
wa 1
i test2 seconds: 1
oa 10 test2 seconds: 1
wa 2
i test2 seconds: 2
oa 10 test2 seconds: 2
wa 3
i test2 seconds: 3
oa 10 test2 seconds: 3
wa 4
i test2 seconds: 4
oa 10 test2 seconds: 4
wa 5
i test2 seconds: 5
oa 10 test2 seconds: 5
wa 6
i test2 seconds: 6
oa 10 test2 seconds: 6
wa 7
i test2 seconds: 7
oa 10 test2 seconds: 7
wa 8
i test2 seconds: 8
oa 10 test2 seconds: 8
wa 9
i test2 seconds: 9
oa 10 test2 seconds: 9
q
59 changes: 59 additions & 0 deletions Instructions.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include "Instructions.h"
#include <string.h>
#include <stdio.h>

/* Here's a dictionary mapping the types of instruction with the strings that call them */
/* to differentiate between instructions, it's best to put a space after instructions with arguments and '\n' after instructions without any */
const InstructionMap instructionCalls[] = {
{INSTANT_EVENT, "i "},
{INSTANT_EVENT, "instant "},
{ONGOING_EVENT_ABSOLUTE, "oa "},
{ONGOING_EVENT_ABSOLUTE, "ongoing_till "},
{ONGOING_EVENT_RELATIVE, "or "},
{ONGOING_EVENT_RELATIVE, "ongoing_for "},
{WAIT_ABSOLUTE, "wa "},
{WAIT_ABSOLUTE, "wait_till "},
{WAIT_RELATIVE, "wr "},
{WAIT_RELATIVE, "wait_for "},
{COMMENT, "//"},
{EXIT, "q\n"},
{EXIT, "quit\n"},
{EXIT, "exit\n"},
{EXIT, "end\n"},
{CHANGE_CAMERA, "c "},
{CHANGE_CAMERA, "camera "},
{LIST_CAMERAS, "cameras\n"},
{PAUSE, "p\n"},
{PAUSE, "pause\n"},
{PAUSE, "\n"},
{PAUSE_SILENT, "ps\n"},
{PAUSE_SILENT, "pause_silent\n"},
{HELP, "help\n"},
{HELP, "h\n"},
{HELP, "?\n"}
};

/* binds the commands that the player can input to their help text */
const InstructionMap playerInstructionHelp[] = {
{CHANGE_CAMERA, "To change the camera, type \"camera <cameraName>\""},
{LIST_CAMERAS, "To get a list of cameras, type \"cameras\""},
{EXIT, "To quit, type \"quit\""},
{PAUSE, "To pause, press enter"}
};

/* Finds the instruction that a string calls */
/* str: the string that calls an instruction */
/* Returns: instructionType and the instruction's arguments. If the string doesn't match any instruction, returns UNDEFINED and NULL */
InstructionMap getInstruction(char* str){
for(int i = 0; i < sizeof(instructionCalls) / sizeof(InstructionMap); i++){
if(strncmp(instructionCalls[i].args, str, strlen(instructionCalls[i].args)) == 0){
return (InstructionMap){instructionCalls[i].type, str + strlen(instructionCalls[i].args)};
}
}
return (InstructionMap){UNDEFINED, NULL};
}

void printHelpText(){
for(int i = 0; i < sizeof(playerInstructionHelp) / sizeof(InstructionMap); i++)
printf("%s\n", playerInstructionHelp[i].args);
}
23 changes: 23 additions & 0 deletions Instructions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
typedef enum InstructionType{
UNDEFINED,
INSTANT_EVENT,
ONGOING_EVENT_ABSOLUTE,
ONGOING_EVENT_RELATIVE,
WAIT_ABSOLUTE,
WAIT_RELATIVE,
COMMENT,
EXIT,
CHANGE_CAMERA,
LIST_CAMERAS,
PAUSE,
PAUSE_SILENT,
HELP
}InstructionType;

typedef struct InstructionMap { /* used to map an instruction to a string */
InstructionType type;
char* args;
}InstructionMap;

InstructionMap getInstruction(char* str);
void printHelpText();
4 changes: 4 additions & 0 deletions OldVersion/Cameras/delayTest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
d1] 1 second delay
d10] 10 second delay
d5] Will exit in 5 seconds
_end
17 changes: 17 additions & 0 deletions OldVersion/Cameras/otherCamera.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
s27] There is a tired looking man at his desk
d5] There is a man sleeping at his desk
d3] He wakes up
d3] He looks around
d5] He shrugs and twiddles his thumbs
d3] He scratches his head
d3] He closes his eyes
d5] He starts to fall asleep again
d1] He wakes up with a start
d3] Man: Oh! Hello! Welcome to the other camera!
d1] Man: Erm, that's...
d1] Man: Uh...
d3] Man: My teleprompter doesn't say anything else
d3] The man looks somewhere out of the camera's field of view
d3] The man appears to be mouthing words at someone
d3] Man: Erm... TECHNICAL DIFFICULTIES
_end
17 changes: 17 additions & 0 deletions OldVersion/Cameras/start.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
d3] A man walks into view. He is wearing a suit, although it looks a bit too small.
s3] There is a man wearing a suit that's a bit too small for him.
d3] He clears his throat.
d3] He tightens his tie.
d2] He clears his throat again.
d3] Man: Welcome to the text adventure!
d5] Man: To pause the game, press enter. Try it!
d3] Man: This game is all about cameras.
d5] Man: To change cameras, pause the game and type "camera otherCamera"
d4] Man: Go ahead, I'll wait
d4] Oh, Hell. The teleprompter's broken
d3] The man runs to the edge of the camera's view
d2] The man waves, trying to get someone's attention
d3] The man makes difficult-to-interpret hand gestures at the person
d3] The man glares
d3] The man stage whispers: You're fired
_end
11 changes: 11 additions & 0 deletions OldVersion/Cameras/syntax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#Camera Syntax
##Events
###Watching Events
To write a normal event, the syntax is "d<n>] <s>"
Where <s> is the string to print and <n> is the delay between that event and the next one
###Switching Events
Switching events are only sent if the player switches to the camera that calls them between the time it is called and the time it is called + the duration it specifies
The syntax is: "s<n>] <s>"
Where <s> is the string to print and <n> is the duration
##Exiting
To automatically exit the game, write "_exit" or "_end" at the end of the files
21 changes: 21 additions & 0 deletions OldVersion/Cameras/test1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
s10] 1s 0 seconds
d1] 1d 0 seconds
s10] 1s 1 seconds
d1] 1d 1 seconds
s10] 1s 2 seconds
d1] 1d 2 seconds
s10] 1s 3 seconds
d1] 1d 3 seconds
s10] 1s 4 seconds
d1] 1d 4 seconds
s10] 1s 5 seconds
d1] 1d 5 seconds
s10] 1s 6 seconds
d1] 1d 6 seconds
s10] 1s 7 seconds
d1] 1d 7 seconds
s10] 1s 8 seconds
d1] 1d 8 seconds
s10] 1s 9 seconds
d1] 1d 9 seconds
_end
21 changes: 21 additions & 0 deletions OldVersion/Cameras/test2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
s10] 2s 0 seconds
d1] 2d 0 seconds
s10] 2s 1 seconds
d1] 2d 1 seconds
s10] 2s 2 seconds
d1] 2d 2 seconds
s10] 2s 3 seconds
d1] 2d 3 seconds
s10] 2s 4 seconds
d1] 2d 4 seconds
s10] 2s 5 seconds
d1] 2d 5 seconds
s10] 2s 6 seconds
d1] 2d 6 seconds
s10] 2s 7 seconds
d1] 2d 7 seconds
s10] 2s 8 seconds
d1] 2d 8 seconds
s10] 2s 9 seconds
d1] 2d 9 seconds
_end
21 changes: 21 additions & 0 deletions OldVersion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#How to play the game
The game consists of a series of messages that print out at specific times. The player interacts with the game using commands. Although not required, before writing a command, press enter to pause the messages, then write the command, then press enter again to unpause them. The commands are as follows.
### Pausing the game
To pause the game, press enter
### Changing the camera
To change the camera, type "camera <name>"
To get a list of available cameras, type "camera"
### Listing the commands
To get a list of commands, type "help"
### Quitting
To quit, type "quit"
#How to make a game
The game runs using .txt files (which I call cameras, in this context) in the Cameras directory. When it launches, its camera will be start.txt, so that should be written first. There are 3 possible commands for a camera, which are the following.
### Witnessed Events
Witnessed events are events that only print if the player is watching the camera that the event is on when it occurs. The syntax for a witnessed event is `"d<n>] <s>"` where `<n>` is the delay, in seconds, between the event in question and the event following it, and `<s>` is the message to be sent.
### Ongoing Events
Ongoing events are events that only print if the player switches to the camera that the event is on after the event starts and before it stops. The syntax for an ongoing event is `"s<n>] <s>"` where `<n>` is the time, in seconds, between the event starting and the event ending, and `<s>` is the message to be sent
### Automatic exit
To automatically quit the program, put "_end" or "_exit" at the end of the file.
# How to compile it
to compile it, use `gcc textAdventure.c -o textAdventure -lpthread`
46 changes: 46 additions & 0 deletions OldVersion/README_OLD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Final Project

## Objectives
To review and implement concepts learned from class in a self-designed program.

### Description
You will design, propose, and implement a project of your own choosing. Your project must implement or include each of the following concepts:
- Variables/data types
- Input/output
- Conditional statements
- Loops
- Functions
- Arrays/strings (either directly or as a pointer)
- Advanced data types (structures and enumerated lists) <br>

If it is appropriate to use a header file and/or an external .c file containing utility functions, you should do so. If you have more than a few functions in your program, this applies to you.

Your program must be well-commented and provide the user with information on how to use your program. Interaction with the program should be specified within the program as well as within a readme.txt document. Rules for games should also be included in the readme.txt document.
Additionally, your code must be written efficiently and handle invalid user input appropriately. This means that if you have the user enter a number, and the user enters a string or a character, your program should not crash, go into an infinite loop, or produce anything outside of the expected functionality.

Examples of projects include (but are not limited to): game simulators (board games, battle arena, other games), text adventure games, artificial intelligence applications, etc.

Note: There may be functionality you wish to include in your project that we have not gone over yet in class. You can check with your instructor (me) or your TA (Lesley) to see if we intend to go over it or if it is possible. You may wish to temporarily hardcode data, functionality, etc. until we go over it. Your final code for those sections should not be hardcoded.

### Part 1: Proposal
You must submit a proposal that details the following:
- Descriptive overview of project (what it does, what game it implements/simulates, etc). This should be long enough to explain what your program is and what it does/does not do.
- Detailed examples of concept implementation (an example each of how you will use functions, loops, etc.). You do not need to explain how you will use variables or input/output unless it is not inherently obvious.
- Your reasons for picking this project (you are interested in game design and wanted to create a game, you think the application is interesting and why, etc.).
- Any external libraries you are considering using and what you will use them for. Keep in mind that most of your code should be your own, and we cannot provide any help for external libraries. This includes graphics libraries. You are responsible for learning and figuring them out on your own. Also detail any code you will use that is not yours.

### Part 2: Project Implementation
You must implement the project as described in your proposal and conforming to the expectations in the Description section.

Functions and large code blocks should be documented (have comments briefly explaining their purpose, as well as any parameters or return values, if applicable).

You must include a readme.txt detailing how to run your project, a brief overview of what it does, and a brief explanation of interaction with the program (e.g. “You may enter commands at the >> prompt. For help/suggestions of commands to enter at any time, type ‘help’.” for a text adventure game). If your project is a game or game simulator, you should also include any rules as applicable (e.g. “Go Fish is a game of matching cards. If you suggest a card your opponent has, he/she must give you that card. Likewise, if the opponent asks for a card you have, you must give him/her that card. If no card matches, player draws from the pile. Otherwise, players continue asking for cards until they ask for a card no one has.”).

Your readme.txt should also detail any changes made that do not follow your original proposal and explain why they differ.


### Deliverables
Your proposal should be submitted by 10am on Monday, July 11, 2016. It will either be approved or modification requested by Monday night. Note that if you submit your proposal early, it will likely be evaluated early, and you will be able to begin work on your project as soon as it is approved. Your proposal should be in a .doc, .pdf, or .txt document.

Your project is due Friday, July 15, 2016 at 4pm. Please submit ALL files (source code, external libraries, data files, and executable).

Binary file added OldVersion/textAdventure
Binary file not shown.
Loading