#include <curses.h>
#include <cstdlib>
#include <ctime>
#define bRead(value, bit) (((value) >> (bit)) & 0x01)
#define bWrite(value, bit, bitvalue) (bitvalue ? (value) |= (1UL << (bit)) : (value) &= ~(1UL << (bit)))
#define AUTO_PLAY false
#define cactus '|'
#define player '@'
void sleep(float);
void init();
int main() {
init();
int map = 0, plry = 10, score = 0;
double asd = 1.00;
while (true) {
if (!bRead(map, 1) && !bRead(map, 2) && !bRead(map, 3) && !bRead(map, 4) && !bRead(map, 5)) bWrite(map, 0, rand() % 2);
if (plry < 10) {
if (asd) asd -= 0.50;
else {
asd = 1.00;
mvwaddch(stdscr, plry, 14, ' ');
++plry;
}
}
#if AUTO_PLAY <= 0
if (getch() == KEY_UP && plry >= 9) {
mvwaddch(stdscr, plry, 14, ' ');
--plry;
}
if (plry == 10 && bRead(map, 28)) break;
#elif AUTO_PLAY > 0
if (plry == 10 && bRead(map, 27)) {
mvwaddch(stdscr, plry, 14, ' ');
--plry;
}
#endif
if (bRead(map, 27)) ++score;
move(10, 11);
for (int j = 31; j >= 0; --j) {
waddch(stdscr, (bRead(map, j) ? cactus | COLOR_PAIR(1) : ' '));
}
mvwaddch(stdscr, plry, 14, player);
mvwaddch(stdscr, 5, 42, cactus | COLOR_PAIR(1));
wprintw(stdscr, " - %d", score);
map <<= 1;
refresh();
sleep(0.15);
}
sleep(3.00);
endwin();
return 0;
}
void sleep(float seconds) {
clock_t startClock = clock();
while(clock() < startClock + (seconds * CLOCKS_PER_SEC));
}
void init() {
srand(time(NULL));
initscr();
start_color();
init_pair(1, COLOR_GREEN, 0);
curs_set(false);
keypad(stdscr, true);
nodelay(stdscr, true);
noecho();
}
WARNING:aiogram:Goodbye!
Traceback (most recent call last):
File "/home/Silin11/.local/lib/python3.8/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa
File "/usr/lib/python3.8/asyncio/base_events.py", line 1017, in create_connection
raise exceptions[0]
File "/usr/lib/python3.8/asyncio/base_events.py", line 1002, in create_connection
sock = await self._connect_sock(
File "/usr/lib/python3.8/asyncio/base_events.py", line 916, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/lib/python3.8/asyncio/selector_events.py", line 485, in sock_connect
return await fut
File "/usr/lib/python3.8/asyncio/selector_events.py", line 490, in _sock_connect
sock.connect(address)
OSError: [Errno 101] Network is unreachable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/Silin11/.local/lib/python3.8/site-packages/aiogram/bot/api.py", line 139, in make_request
async with session.post(url, data=req, **kwargs) as response:
File "/home/Silin11/.local/lib/python3.8/site-packages/aiohttp/client.py", line 1117, in __aenter__
self._resp = await self._coro
File "/home/Silin11/.local/lib/python3.8/site-packages/aiohttp/client.py", line 520, in _request
conn = await self._connector.connect(
File "/home/Silin11/.local/lib/python3.8/site-packages/aiohttp/connector.py", line 535, in connect
proto = await self._create_connection(req, traces, timeout)
File "/home/Silin11/.local/lib/python3.8/site-packages/aiohttp/connector.py", line 892, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/home/Silin11/.local/lib/python3.8/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection
raise last_exc
File "/home/Silin11/.local/lib/python3.8/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/home/Silin11/.local/lib/python3.8/site-packages/aiohttp/connector.py", line 975, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.telegram.org:443 ssl:default [Network is unreachable]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "bot.py", line 59, in <module>
executor.start_polling(dp, skip_updates=True)
File "/home/Silin11/.local/lib/python3.8/site-packages/aiogram/utils/executor.py", line 41, in start_polling
executor.start_polling(reset_webhook=reset_webhook, timeout=timeout, relax=relax, fast=fast)
File "/home/Silin11/.local/lib/python3.8/site-packages/aiogram/utils/executor.py", line 309, in start_polling
loop.run_until_complete(self._startup_polling())
File "/usr/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete
return future.result()
File "/home/Silin11/.local/lib/python3.8/site-packages/aiogram/utils/executor.py", line 360, in _startup_polling
await self._welcome()
File "/home/Silin11/.local/lib/python3.8/site-packages/aiogram/utils/executor.py", line 350, in _welcome
user = await self.dispatcher.bot.me
File "/home/Silin11/.local/lib/python3.8/site-packages/aiogram/bot/bot.py", line 29, in me
setattr(self, '_me', await self.get_me())
File "/home/Silin11/.local/lib/python3.8/site-packages/aiogram/bot/bot.py", line 217, in get_me
result = await self.request(api.Methods.GET_ME, payload)
File "/home/Silin11/.local/lib/python3.8/site-packages/aiogram/bot/base.py", line 208, in request
return await api.make_request(self.session, self.server, self.__token, method, data, files,
File "/home/Silin11/.local/lib/python3.8/site-packages/aiogram/bot/api.py", line 142, in make_request
raise exceptions.NetworkError(f"aiohttp client throws an error: {e.__class__.__name__}: {e}")
aiogram.utils.exceptions.NetworkError: Aiohttp client throws an error: ClientConnectorError: Cannot connect to host api.telegram.org:443 ssl:default [Network is unre
achable]