Commits

Allan Davis committed bde05ff

Started basic game loop

  • Participants
  • Parent commits 4852a74

Comments (0)

Files changed (3)

code/HuntTheWumpus/HuntTheWumpus/main.m

 //
 
 #import <Foundation/Foundation.h>
+#import "Game.h"
 
 int main(int argc, const char * argv[])
 {
     @autoreleasepool {
         
         // insert code here...
-        NSLog(@"Hello, World!");
+        //NSLog(@"Hello, World!");
+        [Game startLoop];
         
     }
     return 0;

code/HuntTheWumpus/HuntTheWumpus/models/Game.m

 
 @implementation Game
 
+
+
 + (void) startLoop{
-    static Game * game = [[Game alloc]init];
+    Game * game = [[Game alloc]init];
+    game.gameRunning = YES;
     while (game.gameRunning) {
-        [game clearTheScreen];
-        [game updateTheData];
+        printf("Press x to quit. \n");
+        char input;
+        scanf("%c", &input);
+        if (input == 'x') {
+            game.gameRunning = NO;
+        }
+        
     }
 }
 

source/objective_c.rst

+Objective C
+=============
+
+Overview
+---------
+
+
+
+Hunt the Wumpus
+----------------
+
+
+Game Loop
+^^^^^^^^^^^
+
+.. code-block:: objc
+  :linenos:
+  
+  + (void) startLoop{
+      Game * game = [[Game alloc]init];
+      game.gameRunning = YES;
+      while (game.gameRunning) {
+          printf("Press x to quit. \n");
+          char input;
+          scanf("%c", &input);
+          if (input == 'x') {
+              game.gameRunning = NO;
+          }
+      }
+  }
+