Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

CSC112 Spring 2016 Examples

2370 views
1
#include <unistd.h>
2
#include "termmanip.h"
3
#include "SmileyFace.h"
4
#include "keystream.h"
5
6
using namespace std;
7
8
9
int main()
10
{
11
SmileyFace *face = new SmileyFace(42, 10); //put the smiley near the middle!
12
keycode c;
13
14
kin.rawMode();
15
16
//clear the screen and display the menu
17
cout << clearScreen << cursorOff;
18
cout << cursorPosition(1,1)
19
<< "Q - Scare C - Chill Z - Kill UP - Reset ESC - Exit";
20
cout.flush();
21
22
//draw the initial smiley
23
face->display();
24
25
do {
26
c = kin.getKey();
27
switch(c) {
28
case 'q':
29
case 'Q':
30
face->scare();
31
break;
32
33
case 'c':
34
case 'C':
35
face->chill();
36
break;
37
38
case 'z':
39
case 'Z':
40
face->kill();
41
break;
42
43
case UP:
44
face->reset();
45
break;
46
}
47
48
face->display();
49
} while(c != ESC);
50
51
return 0;
52
}
53
54