Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- //
- //
- int main(void) {
- char characterSpace[80];
- char character = '@';
- char line = '_';
- char encouragement = 1;
- int counter;
- int externCounter = 0;
- int quit;
- int quittersFlag = 0;
- //introduction
- printf("This is your character ->@\nSay hello!\n");
- printf("...\n\n");
- printf("You character needs some word food to complete his journey.\n");
- printf("Any character on your keyboard will do, except numbers.\n");
- printf("@ hates numbers. If you feed him some...r\nhe might just run back to the start.\n\nOr worse... he may get lost.\n\n");
- printf("Give some motivation to your character:\n");
- while (quit != EOF) {
- for (counter = 0; counter <80; counter++) {
- characterSpace[counter]=line;
- }
- characterSpace[counter]='\0';
- scanf("%c", &encouragement);
- if (externCounter <= -10) {
- quittersFlag = 2;
- quit = EOF;
- }
- if (encouragement >= 65) { // if a letter
- externCounter+=4;
- }
- if (encouragement <= 57 && encouragement >= 48) { // if a number
- if (externCounter <=5) {
- externCounter--;
- } else {
- externCounter -=5;
- }
- }
- if (encouragement == '\n') {
- printf("\n");
- printf("Sending motivation to @. He feels like going to position %d...\n", externCounter);
- characterSpace[externCounter]=character;
- if ( externCounter >=80 ) {
- characterSpace[79]='@';
- printf("%s\n", characterSpace);
- printf("yay! your character made it safely to the end. you win!\n");
- quit = EOF;
- } else {
- printf("%s\n\n", characterSpace); // draws the characters world
- printf("care to tell him more words of wisdom?\n");
- }
- }
- if (encouragement >= 128 || encouragement <= 7) { //if not a good character
- quittersFlag = 1;
- quit = EOF;
- }
- encouragement = 0; //makes things happy so when I EOF or ^D in middle I don't loop forever.
- }
- if (quittersFlag == 1) {
- printf("\n\nQUITTER!\nYOU FAILED MISERABLY!\n\n...\n\n...\n\n");
- printf("But please play again. @ misses you.\n");
- }
- if (quittersFlag == 2) {
- printf("\n\nYou lost @!\n\n...\n\n...\n\n");
- printf("But please play again. I'm sure he'll find his way back by the time you try again.\n");
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement