-
Couldn't load subscription status.
- Fork 22
Add files via upload #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jy330545
wants to merge
6
commits into
CPRO-Session1:master
Choose a base branch
from
jy330545:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,28 @@ | ||
| This is a game about you being trapped in a dungeon and you have to make decisions in order to escape. | ||
| You may type in the number that represents your decision. | ||
| The game will proceed towards different endings based on your input. | ||
| You will be given the choice of either restart the game or terminate the game whenever you reach the end of that round, so you may make a second attempt if you would like to. | ||
| If you input a variable other than the options provided, you will be immediately notified that it was not a valid move. | ||
| Simply reenter ./a.out to manually restart the game. | ||
| Instruction is also stated at the beginning of the game in case if you forget. | ||
|
|
||
| I did make a change that do not follow my original proposal, which is how structures are used in my code. | ||
| I think the reason behind that is: I feel that I was rushing through the project because I was running out of time. | ||
|
|
||
| This is what I have accomplished: | ||
| Instructions will be given out through printf and player's input can be recognized by scanf. | ||
| Player has the ability to decide when to end the game due to a do-while loop I Implemented. | ||
|
|
||
| Structures will not be used to store data and progress, but instead give out an evaluation I wrote based on player's performance. | ||
|
|
||
| Strings will be printed whenever they are set to. | ||
|
|
||
| Only one function is necessary throughout my code and it is void main(). | ||
| Variables are used everywhere across the code. | ||
|
|
||
| Here is what you have to actually input in order to beat the game: | ||
| 1 | ||
| 2 | ||
| 1 | ||
| 3 | ||
| either 1 or 2 or 3 (1 and 3 leads to bad end while 2 leads to good end) |
Binary file not shown.
This file contains hidden or 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,186 @@ | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
|
|
||
| void main() { | ||
|
|
||
| printf("\n"); | ||
| printf("\n"); | ||
|
|
||
| printf("Hello User. You don't know me, but I know you.\n"); | ||
| printf("I want to play a game.\n"); | ||
| printf("You are trapped in a dugeon, and you have to escape by making decisions.\n"); | ||
| printf("Every move you make is crucial to your life.\n"); | ||
| printf("Know that I'm not lying. Better hurry up.\n"); | ||
| printf("Live or die, make your choice.\n"); | ||
| printf("\n"); | ||
| printf("Enter 1 whenever you think choice 1 is the one you want to go with and do the same for other choices\n"); | ||
|
|
||
| //introduction of the game// | ||
|
|
||
| struct user { | ||
|
|
||
| char user [20]; | ||
| char grade [3]; | ||
| } user_failed, user_succeed; | ||
| //a structure that will be used later on to give players their grade// | ||
|
|
||
| char goodEnd[] = "Safe and Sound"; | ||
| char badEnd[] = "Endless Nightmare"; | ||
| char gameOver[] = "GAME OVER"; | ||
| char invalidMove[] = "That's not a valid move"; | ||
| //a few characters that serve different purposes// | ||
|
|
||
| int choice1; | ||
| int choice2; | ||
| int choice3; | ||
| int choice4; | ||
| int choice5; | ||
| int again; | ||
| int i; | ||
| //a few variables that will be used to receive player's choice// | ||
|
|
||
| do { //a do while loop that will terminate the game when requested// | ||
|
|
||
| printf("\n"); | ||
| printf("\n"); | ||
|
|
||
| printf("You woke up in a small room with the wall painted red. the door is not locked. It seems like you are experiencing a memory loss. You can't recall anything asaide from a voice you heard from a doll with a creepy mask. You are not sure if you cam trust it. What should you do?\n"); | ||
| printf("1. exit the room.\n"); | ||
| printf("2. stay in the room.\n"); | ||
| scanf("%d", &choice1); | ||
|
|
||
| //a user will read the text and be given two options where he or she has to enter an integer. The integer will be scanned through scanf and output a following text based on the input integer// | ||
|
|
||
| if(choice1 == 1) { | ||
| printf("You left the room and found yourself ended up in a hallway. You have to decide which direction you want to explore. What will your choice be?\n"); | ||
| printf("1. left\n"); | ||
| printf("2. right\n"); | ||
| scanf("%d", &choice2); | ||
|
|
||
| if(choice2 == 1) { | ||
| printf("You walked towards the left side of the hallway. Unfortunately, you ran into a creature ten times your size. It seems like he doesn't appreciate outsiders like you.\n"); | ||
| printf("%s\n", gameOver); | ||
| } | ||
|
|
||
| else if(choice2 == 2) { | ||
| printf("You ended up in front of the stairs, you can choose to either go up or down. Also, on your way to the stairs, you found a key. So, would you like to go up or down?\n"); | ||
| printf("1. up\n"); | ||
| printf("2. down\n"); | ||
| scanf("%d", &choice3); | ||
|
|
||
| if(choice3 == 1) { | ||
| printf("You walked up the stairs and took a quick glance at the floor you just arrived. You noticed that there are three doors all shut on this floor. The one on the left has a painting of devil on it, while the one on the right has a painting of angel, and the middle one, a painting of a monkey. So, what will your choice be? The angel? The devil? Or... The monkey?\n"); | ||
| printf("1. angel\n"); | ||
| printf("2. devil\n"); | ||
| printf("3. monkey\n"); | ||
| scanf("%d", &choice4); | ||
|
|
||
| if(choice4 == 1) { | ||
| printf("God: Where did your humanity go...\n"); | ||
| printf("%s\n", gameOver); | ||
| } | ||
|
|
||
| else if(choice4 == 2) { | ||
| printf("Satan: You belong with me!\n"); | ||
| printf("%s\n", gameOver); | ||
| } | ||
|
|
||
| else if(choice4 == 3) { | ||
| printf("Thank to Darwin, you made it to the ground! You are now right in front of the gate that separates you from the outside world. Suddenly, you heard the creepy voice again:\n"); | ||
| printf("Congragulations, User. I'm really glad that you made it this far. Now, all you have to do is answer one simple question and then I will set you free.\n"); | ||
| printf("Do you hate me?\n"); | ||
| printf("1. Yes\n"); | ||
| printf("2. No\n"); | ||
| printf("3. Obviously\n"); | ||
| scanf("%d", &choice5); | ||
|
|
||
| if(choice5 == 1 | choice5 == 3) { | ||
| printf("Sure\n"); | ||
| printf("The gate slowly opened and you finally made it out of the dungeon. In front of you, stood a giant maze and you heard a mechanic sound: \n"); | ||
| printf("Welcome to stage 2\n"); | ||
| printf("BAD END: %s\n", badEnd); //char badEnd is used here// | ||
| } | ||
|
|
||
| else if(choice5 == 2) { | ||
| printf("Awwwwwwwwwwwwwwwwwww\n"); | ||
| printf("The gate slowly opened and you finally made it out of the dungeon. In front of you, is the park that you walk around every afternoon. Right after you step on to the ground, the entrance closed and disappeared as if it never existed. You are safe now.\n"); | ||
| printf("GOOD END: %s\n", goodEnd); //char goodEnd is used here// | ||
| struct user user_succeed; //struct user is applied here to print out the username and grade// | ||
| strcpy(user_succeed. user, "User"); | ||
| strcpy(user_succeed. grade, "A+"); | ||
| printf("name: %s\n", user_succeed. user ); | ||
| printf("grade: %s\n", user_succeed. grade ); | ||
| } | ||
|
|
||
| else { | ||
| printf("%s\n", invalidMove); //else is used to ensure if the player input a variable other than 1 and 2, it will notify them that the input is invalid along with char invalidMove// | ||
| } | ||
|
|
||
| } | ||
|
|
||
| else { | ||
| printf("%s\n", invalidMove); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| else if(choice3 == 2) { | ||
| printf("You decided to go further down and that's definitely not a wise choice you made. No one has seen you ever since...\n"); | ||
| printf("%s\n", gameOver); //char gameOver will be the output of a false move that leads to the end of game// | ||
| } | ||
|
|
||
| else { | ||
| printf("%s\n", invalidMove); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| else { | ||
| printf("%s\n", invalidMove); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| else if(choice1 == 2) { | ||
| printf("After a while, the light suddenly went out. You are terrified. You heard the sound of something moving towards you, faster and faster. And...\n"); | ||
| printf("%s\n", gameOver); | ||
| } | ||
|
|
||
| else { | ||
| printf("%s\n", invalidMove); | ||
| } | ||
|
|
||
| if(choice5 != 2) { //struct is implemented here again along with a condition that choice5 != 5, when choice5 == 5, another struct: struct user user_succeed will be the output rather than this one// | ||
| struct user user_failed; | ||
| strcpy(user_failed. user, "User"); | ||
| strcpy(user_failed. grade, "F"); | ||
| printf( "user: %s\n", user_failed. user ); | ||
| printf( "grade: %s\n", user_failed. grade ); | ||
| } | ||
|
|
||
| printf("\n"); | ||
| printf("Do you wish to try again?\n"); | ||
| printf("1. Yea\n"); | ||
| printf("2. Nope\n"); | ||
| scanf("%d", &again); | ||
| while(again == 2) { | ||
| printf("\n"); | ||
| for(i = 0; i < 10; i++) { | ||
| printf("Promise me you will come back later qwq!!!\n"); | ||
| printf("Have a nice day qwq!!!\n"); } | ||
| break; | ||
| } | ||
|
|
||
| while(again != 1 && again != 2) { | ||
| printf("%s\n", invalidMove); | ||
| printf("Enter ./final to restart the game qwq!!!\n"); | ||
| break; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| while(again == 1); //gives the option of cotinue/terminate the game// | ||
|
|
||
| return; | ||
|
|
||
| } |
This file contains hidden or 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,8 @@ | ||
| Justin Yu | ||
| my idea is to design a text adventure game that simulates an event with the ending totally depending to user's decisions. This will be done using mostly printf and scanf command, although other concepts are also being applied. | ||
| The game will give out instructions using printf and the code will recognize player's decision through scanf. | ||
| The game will use loop to determine when to exit and end the game. | ||
| The game will use structrues to store data and progress a player has made while array will be more specificly storing the terms used. | ||
| My reason for picking this game is that I personally am a big fan of text based games and I think it will be cool if I can design one myself. Also, it enables me to apply everything I have learned about C which really makes this idea even better. | ||
| I don't think my game will be using any external library. | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Keep in mind that your text adventure should be of sufficient length to indicate a week's worth of work.
Please update with a specific example or instance of how you would use a custom function or functions in your project.