-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanOnMars.c
More file actions
83 lines (65 loc) · 1.77 KB
/
manOnMars.c
File metadata and controls
83 lines (65 loc) · 1.77 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
80
81
82
83
#include <stdlib.h>
#include <graphics.h>
#include <conio.h>
#include <dos.h>
int dw, dh, platformSize;
void initG () {
int GDriver = DETECT, GMode;
initgraph(&GDriver, &GMode, "C:\\TURBOC3\\BGI");
cleardevice();
dw = getmaxx(); dh = getmaxy(); platformSize = dh / 4;
}
void drawPlatform () {
int y;
setcolor(BROWN);
for (y = (dh - platformSize); y < dh; y++) {
line(0, y, dw, y);
}
}
void drawStars () {
int x, y, rx, ry;
setcolor(CYAN);
for (x = 0; x < 50; x++) {
rx = random(dw); ry = random((dh - platformSize));
line(rx, ry, rx, ry + 2);
}
}
void drawRocket (int x, int y, int w, int h) {
setcolor(LIGHTBLUE);
line(x, y + (h / 2), x + (w / 2), y);
line(x + (w / 2), y, x + w, y + (h / 2));
line(x, y + (h / 2), x + w, y + (h / 2));
line(x + (w / 2), y + (h / 2), x + (w / 2), y + h);
line(x, y + h, x + (w / 2), y + (h / 2));
line(x + (w / 2), y + (h / 2), x + w, y + h);
}
void drawMan (int x, int y, int w, int h) {
setcolor(WHITE);
circle(x + (w / 2), y + (w / 4), w / 4);
line(x, y + (h / 2), x + (w / 2), y + (h / 4));
line(x + (w / 2), y + (h / 4), x + w, y + (h / 2));
line(x + (w / 2), y + (h / 4), x + (w / 2), y + (h / 2));
line(x, y + h, x + (w / 2), y + (h / 2));
line(x + (w / 2), y + (h / 2), x + w, y + h);
}
void drawTitle () {
moveto(dw / 2, dh / 4);
setcolor(LIGHTRED);
outtext("Mars hai shayad lol");
}
void main () {
int bx = 0, step_size = 10;
initG();
setbkcolor(BLUE);
while (!kbhit()) {
drawTitle();
drawPlatform();
drawStars();
drawRocket(dw / 4, (dh - platformSize) - 50, 50, 50);
drawMan(bx, (dh - platformSize) - 120, 60, 120);
if (bx > dw) { bx = 0; } else { bx += step_size; }
delay(200);
cleardevice();
}
getch();
}