Advertisement
maddie_dlt

game.cpp

Dec 1st, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <iostream>
  2. #include "plotter.h"
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. //data abstractions
  9. Plotter screen;
  10. int currX = 10, currY = 10;
  11. char key;
  12.  
  13. screen.clear();
  14. screen.setColor(magenta);
  15. screen.plot (currX, currY, SQUARE);
  16.  
  17. //input, update, draw
  18. while ( 1 ) //1 creates an infinite loop because 1 means true
  19. {
  20. if (kbhit) //a boolean function call that determines if there
  21. //is something in the keyboard buffer
  22. {
  23. //Input
  24. key = getch();
  25.  
  26. //Update
  27. switch (key)
  28. {
  29. case 'w': currY--; break;
  30. case 'a': currX--; break;
  31. case 's': currY++; break;
  32. case 'd': currX++; break;
  33. default: break;
  34. }
  35.  
  36. //Draw
  37. screen.clear();
  38. screen.plot (currX, currY, SQUARE);
  39. }
  40. }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement