Advertisement
vikhik

gridworld gridworld.h

Jul 8th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. #ifndef GRIDWORLD_H
  2. #define GRIDWORLD_H
  3.  
  4. #include <string>
  5. #include <iostream>
  6.  
  7. namespace gridworld {
  8. class Tile {
  9.     //Knows if the player can walk here (i.e. not a wall)
  10.     //Knows if something happens on this square
  11.     //Model class
  12.  
  13. public:
  14.     //These really should be private, with getters and setters
  15.     bool wall;
  16.     bool event;
  17.     std::string eventText;
  18.  
  19.     Tile(bool w, bool e, std::string eText);
  20.  
  21.     Tile(bool w);
  22.  
  23.     Tile();
  24.  
  25. };
  26.  
  27. class Map {
  28.     //Handles map, character location, and knows what should happen at each map location
  29.     //Model class
  30.  
  31. public:
  32.     Tile map[8][8]; // [0][0] is top left, [7][0] is top right, etc.
  33.     int charX;
  34.     int charY;
  35.  
  36.     Map();
  37.  
  38.     std::string possibleExits();
  39.  
  40.     bool legalExit(int x, int y);
  41.  
  42.     bool legalExit(char dir);
  43.  
  44.     void moveChar(char dir);
  45.  
  46.     bool finish() {
  47.         return map[charX][charY].event;
  48.     }
  49.  
  50.     std::string finishEvent();
  51. };
  52.  
  53. class Display {
  54.     //currently outputs what is happening and what exits are available
  55.     //will display the current square and every adjacent square
  56.     //View class
  57. public:
  58.     Display() {
  59.     }
  60.  
  61.     void exits(Map map);
  62.  
  63.     void finish(Map map);
  64.  
  65.     void intro();
  66.  
  67.     void quit();
  68. };
  69.  
  70. class InputManager {
  71.     //handles input, asks Model what should happen and acts on it
  72.     //Control class
  73. public:
  74.     InputManager() {
  75.     }
  76.  
  77.     bool runTurn(Map map);
  78. };
  79. }
  80.  
  81. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement