Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "plotter.h"
- using namespace std;
- int main()
- {
- //data abstractions
- Plotter screen;
- int currX = 10, currY = 10;
- char key;
- screen.clear();
- screen.setColor(magenta);
- screen.plot (currX, currY, SQUARE);
- //input, update, draw
- while ( 1 ) //1 creates an infinite loop because 1 means true
- {
- if (kbhit) //a boolean function call that determines if there
- //is something in the keyboard buffer
- {
- //Input
- key = getch();
- //Update
- switch (key)
- {
- case 'w': currY--; break;
- case 'a': currX--; break;
- case 's': currY++; break;
- case 'd': currX++; break;
- default: break;
- }
- //Draw
- screen.clear();
- screen.plot (currX, currY, SQUARE);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement