-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathsmiley.cpp
More file actions
79 lines (62 loc) · 1.53 KB
/
smiley.cpp
File metadata and controls
79 lines (62 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include<iostream>
#include<graphics.h>
#include<conio.h>
#include<time.h>
using namespace std;
int myRandomX() {
srand(time(NULL));
int randomNumber;
randomNumber = rand()%700;
return randomNumber;
}
int myRandomY() {
srand(time(NULL));
int randomNumber;
randomNumber = rand()%500;
return randomNumber;
}
void drawSmile(int x,int y) {
// Face Circle
setcolor(YELLOW);
circle(x, y, 50);
setfillstyle(SOLID_FILL, YELLOW);
floodfill(x, y, YELLOW);
// Left Eye
setcolor(BLACK);
circle(x-20, y-15, 7);
setfillstyle(SOLID_FILL,BLACK);
floodfill(x-20, y-15, BLACK);
// Right Eye
setcolor(BLACK);
circle(x+20, y-15,7);
setfillstyle(SOLID_FILL,BLACK);
floodfill(x+20, y-15, BLACK);
// Smile
setcolor(BLACK);
line(x-25,y+24,x+25,y+24);
line(x-25,y+25,x+25,y+25);
line(x-25,y+26,x+25,y+26);
}
int main() {
initwindow(800,600);
int randomNumberX;
int randomNumberY;
while(1) {
srand(time(NULL));
randomNumberX = rand()%700;
randomNumberY = rand()%500;
if (randomNumberX < 100) {
randomNumberX += 100;
}
if (randomNumberY < 100) {
randomNumberY += 100;
}
cout << "randomX" << randomNumberX;
cout << "randomY" << randomNumberY;
drawSmile(randomNumberX,randomNumberY);
delay(1000);
cleardevice();
}
getch();
closegraph();
}