Advertisement
Conner_36

sillyGame

Jun 29th, 2011
3,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
LLVM 2.29 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. //
  4. //
  5. int main(void) {
  6.    
  7.     char characterSpace[80];
  8.     char character = '@';
  9.     char line = '_';
  10.    
  11.     char encouragement = 1;
  12.    
  13.     int counter;
  14.     int externCounter = 0;
  15.    
  16.     int quit;
  17.     int quittersFlag = 0;
  18.    
  19.     //introduction
  20.     printf("This is your character ->@\nSay hello!\n");
  21.     printf("...\n\n");
  22.     printf("You character needs some word food to complete his journey.\n");
  23.     printf("Any character on your keyboard will do, except numbers.\n");
  24.     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");
  25.     printf("Give some motivation to your character:\n");
  26.    
  27.     while (quit != EOF) {
  28.         for (counter =  0; counter <80; counter++) {
  29.             characterSpace[counter]=line;
  30.         }
  31.         characterSpace[counter]='\0';
  32.        
  33.         scanf("%c", &encouragement);
  34.        
  35.         if (externCounter <= -10) {
  36.             quittersFlag = 2;
  37.             quit = EOF;
  38.         }
  39.        
  40.         if (encouragement >= 65) { // if a letter
  41.             externCounter+=4;
  42.         }
  43.        
  44.         if (encouragement <= 57 && encouragement >= 48) { // if a number
  45.             if (externCounter <=5) {
  46.                 externCounter--;
  47.             } else {
  48.                 externCounter -=5;
  49.             }
  50.         }
  51.        
  52.         if (encouragement == '\n') {
  53.             printf("\n");
  54.             printf("Sending motivation to @. He feels like going to position %d...\n", externCounter);
  55.            
  56.             characterSpace[externCounter]=character;
  57.                        
  58.             if ( externCounter >=80 ) {
  59.                 characterSpace[79]='@';
  60.                 printf("%s\n", characterSpace);
  61.                 printf("yay! your character made it safely to the end. you win!\n");
  62.                
  63.                 quit = EOF;
  64.             } else {
  65.                
  66.             printf("%s\n\n", characterSpace); // draws the characters world
  67.             printf("care to tell him more words of wisdom?\n");
  68.                
  69.             }
  70.         }
  71.        
  72.         if (encouragement >= 128 || encouragement <= 7) { //if not a good character
  73.             quittersFlag = 1;
  74.             quit = EOF;
  75.         }
  76.        
  77.        
  78.        
  79.         encouragement = 0; //makes things happy so when I EOF or ^D in middle I don't loop forever.
  80.     }
  81.    
  82.     if (quittersFlag == 1) {
  83.         printf("\n\nQUITTER!\nYOU FAILED MISERABLY!\n\n...\n\n...\n\n");
  84.         printf("But please play again. @ misses you.\n");
  85.     }  
  86.    
  87.     if (quittersFlag == 2) {
  88.         printf("\n\nYou lost @!\n\n...\n\n...\n\n");
  89.         printf("But please play again. I'm sure he'll find his way back by the time you try again.\n");
  90.     }
  91.    
  92.     return EXIT_SUCCESS;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement