Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

During a focused session in Geometry Dash, I stopped reacting and started anticipating. The run felt controlled from start to finish.

84 views
ubuntu2204
1
#include <iostream>
2
#include <conio.h>
3
#include <windows.h>
4
using namespace std;
5
6
int main() {
7
int x = 5, y = 10;
8
int obstacle = 40;
9
bool jump = false;
10
11
while (true) {
12
system("cls");
13
14
// draw player
15
for (int i = 0; i < y; i++) cout << endl;
16
for (int i = 0; i < x; i++) cout << " ";
17
cout << "O";
18
19
// draw obstacle
20
cout << "\n";
21
for (int i = 0; i < obstacle; i++) cout << " ";
22
cout << "#";
23
24
// input
25
if (_kbhit() && _getch() == ' ') jump = true;
26
27
// jump logic
28
if (jump) {
29
y -= 2;
30
if (y <= 5) jump = false;
31
} else if (y < 10) {
32
y += 1;
33
}
34
35
// move obstacle
36
obstacle--;
37
if (obstacle < 0) obstacle = 40;
38
39
// collision
40
if (obstacle == x && y >= 9) {
41
cout << "\nGame Over!";
42
break;
43
}
44
45
Sleep(50);
46
}
47
}
48