Jogo da cobrinha (Snake II) refeito em C e C++
Publicado por retro (última atualização em 29/07/2020)
[ Hits: 10.979 ]
Homepage: nenhum kk
Vocês aí com certeza já jogaram o famoso Snake II (vulgo Jogo da Cobrinha), em seus antigos nokias dos anos 2000. Mas vocês já pensaram em um remake para Windows (no momento estou tendo que usar esse janelas aí para fazer uns negócios, depois eu faço a adaptação para Linux); escrito em C++ e C?
Então você veio no lugar certo, eu tenho o GitHub, onde você poderá criar sua própria versão do jogo, e aqui, onde você poderá jogar (usando o wine) ou criar sua própria versão.
Link do repositório: https://github.com/RetroGamerCX/snake-ii-remake
E então o script (sim, são 830 linhas de esforço para um simples remake de um jogo):
#pragma warning (disable : 4996)
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#include <stdio.h>
#include <conio.h>
#include <ctime>
#include <iostream>
#include <locale.h>
#include <cstdlib>
#include <string>
using namespace std;
void mgotoxy(int x, int y) {
COORD p = { x, y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), p);
}
int main() {
system("mode 27,20");
system("title Snake");
system("color 20");
setlocale(LC_ALL, "Portuguese");
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# <<<----|-|---->>> #" << endl;
cout << "# <<<---|-|--->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "###########################" << endl;
Sleep(500);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# <<<----|-|---->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "###########################" << endl;
Sleep(500);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "###########################" << endl;
Sleep(600);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# # #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# ## #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# ### #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #### #" << endl;
cout << "# # #" << endl;
cout << "# # #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #### #" << endl;
cout << "# # #" << endl;
cout << "# ## #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #### #" << endl;
cout << "# # #" << endl;
cout << "# ### #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #### #" << endl;
cout << "# # #" << endl;
cout << "# #### #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #### #" << endl;
cout << "# # #" << endl;
cout << "# ##### #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #### #" << endl;
cout << "# # #" << endl;
cout << "# ###### #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #### #" << endl;
cout << "# # #" << endl;
cout << "# ####### #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #### #" << endl;
cout << "# # #" << endl;
cout << "# ######## #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #### #" << endl;
cout << "# # #" << endl;
cout << "# ######### #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #### #" << endl;
cout << "# # #" << endl;
cout << "# ########## #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #### #" << endl;
cout << "# # #" << endl;
cout << "# ########### #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #### #" << endl;
cout << "# # #" << endl;
cout << "# ############ #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<-----|-|----->>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# <<<<<<<[INFINITY]>>>>>> #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# apresenta: #" << endl;
cout << "# um jogo clássico, que #" << endl;
cout << "# agora possui um REMAKE! #" << endl;
cout << "# É ELE: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #### #" << endl;
cout << "# # #" << endl;
cout << "# ############ #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
Sleep(300);
goto title;
title:
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# #" << endl;
cout << "# +------------+ #" << endl;
cout << "# | SNAKE II: | #" << endl;
cout << "# | THE REMAKE | #" << endl;
cout << "# +------------+ #" << endl;
cout << "# #" << endl;
cout << "# A.K.A: Jogo da Cobrinha #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# ####<-snake #" << endl;
cout << "# # #" << endl;
cout << "# ############ #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# --> Pressione Enter <-- #" << endl;
cout << "# Versão: 1.1 #" << endl;
cout << "###########################" << endl;
getch();
goto option;
option:
int op;
int password = 1;
int speed = 200;
int c = 0;
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# o p t i o n s #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# Escolha uma opção: #" << endl;
cout << "# 0: Sair #" << endl;
cout << "# 1: Continuar #" << endl;
cout << "# 2: Novo Jogo #" << endl;
cout << "# 3: Ajuda #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# ------- options: ------ #" << endl;
cout << "# _0_ _1_ _2_ _3_ #" << endl;
cout << "# |___| |___| |___| |___| #" << endl;
cout << "# # #" << endl;
cout << "# # #" << endl;
cout << "# # #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
cin >> op;
if (op == 0) {
return 0;
}
if (op == 1) {
c = 1;
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# p a s s w o r d #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# Digite a sua senha #" << endl;
cout << "# abaixo: #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #### #" << endl;
cout << "# # #" << endl;
cout << "# ############ #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
cin >> password;
cin >> speed;
goto size;
}
if (op == 2) {
set:
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# s p e e d #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# Digite a velocidade de #" << endl;
cout << "# seu personagem, que é #" << endl;
cout << "# medida por milissegun- #" << endl;
cout << "# dos. #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# ------#### #" << endl;
cout << "# ------# #" << endl;
cout << "# ------############ #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
cin >> speed;
goto size;
}
if (op == 3) {
help:
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# p a g e 1 #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# Primeiro, você precisa #" << endl;
cout << "# ajustar a sua velocida- #" << endl;
cout << "# de. É usado um sistema #" << endl;
cout << "# de milisegundos para #" << endl;
cout << "# isso. Ao colocar certa #" << endl;
cout << "# quantidade de milisse- #" << endl;
cout << "# gundos, a cobra se move #" << endl;
cout << "# um quadrado a cada mi- #" << endl;
cout << "# lisegundo que foi ajus- #" << endl;
cout << "# tado pelo jogador. #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# próxima página: enter > #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
getch();
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
int o = 0;
cout << "000_______________________ " << endl;
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# p a g e 2 #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# Os controles são os di- #" << endl;
cout << "# recionais de seu tecla- #" << endl;
cout << "# do. Para colher uma ma- #" << endl;
cout << "# çã, faça a cobra se en- #" << endl;
cout << "# contrar com ela, assim, #" << endl;
cout << "# cada maçã irá aumentar #" << endl;
cout << "# uma unidade de seu ta- #" << endl;
cout << "# manho. #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# Opções: #" << endl;
cout << "# 0: Sair #" << endl;
cout << "# 1: Jogar #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
cin >> o;
if (o == 0) {
return 0;
}
if (o == 1) {
goto set;
}
else {
cout << "Comando inválido" << endl;
getch();
goto help;
}
}
else {
cout << "Comando inválido" << endl;
getch();
goto option;
}
size:
int size[2] = { 1,password };
goto game;
game:
int x, d = 2, cx[300] = { 12,1 }, cy[300] = { 9,7 }, mx, my;
char tecla = 'a';
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "0" << size[c] << "_______________________" << endl;
cout << "###########################" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "###########################" << endl;
srand(time(0));
mx = rand() % 1 + 25 - 1;
my = rand() % 16 + 2;
while (tecla != 's')
{
while (tecla != 's' && !(tecla = kbhit()))
{
for (x = size[c]; x > 0; x--)
{
cx[x] = cx[x - 1];
cy[x] = cy[x - 1];
}
if (d == 0)cx[0]--;
if (d == 1)cy[0]--;
if (d == 2)cx[0]++;
if (d == 3)cy[0]++;
mgotoxy(cx[size[c]], cy[size[c]]);
printf(" ");
if (mx == cx[0] && my == cy[0]){
size[c]++;
mx = rand() % 3 + 3;
my = rand() % 15 + 3;
}
mgotoxy(cx[0], cy[0]);
printf("#");
mgotoxy(mx, my);
printf("%c", 499);
Sleep(speed);
for (x = 1; x < size[c]; x++)
{
if (cx[0] == cx[x] && cy[0] == cy[x]) tecla = 's';
}
if (cy[0] == 0 || cy[0] == 18 || cx[0] == 0 || cx[0] == 26) tecla= 's';
}
if (tecla != 's') tecla = getch();
if (tecla == 'K') d = 0;
if (tecla == 'H') d = 1;
if (tecla == 'M') d = 2;
if (tecla == 'P') d = 3;
if (tecla == 'p') {
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# p a u s e #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# ______ #" << endl;
cout << "# Senha: |" << size[c] << " | #" << endl;
cout << "# |" << speed << " | #" << endl;
cout << "# -------- #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# z #" << endl;
cout << "# z #" << endl;
cout << "# z #" << endl;
cout << "# ################# #" << endl;
cout << "# ----------------------- #" << endl;
cout << "###########################" << endl;
getch();
goto game;
}
if (cy[0] == 0 || cy[0] == 18 || cx[0] == 0 || cx[0] == 26) tecla = 's';
}
gameover:
int option;
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
cout << "###########################" << endl;
cout << "# ----------------------- #" << endl;
cout << "# g a m e o v e r #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# __________ #" << endl;
cout << "# Senha: |" << size[c] << " | #" << endl;
cout << "# |" << speed << " | #" << endl;
cout << "# ------------ #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# Escolha uma opção: #" << endl;
cout << "# 0: Sair #" << endl;
cout << "# 1: Continuar #" << endl;
cout << "# 2: Novo Jogo #" << endl;
cout << "# ----------------------- #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# #" << endl;
cout << "# ##############X#X #" << endl;
cout << "###########################" << endl;
cin >> option;
if (option == 0) {
return 0;
}
if (option == 1) {
goto game;
}
if (option == 2) {
password = 1;
goto set;
}
else {
cout << "Comando inválido" << endl;
getch();
goto gameover;
}
}
Calculadora elementar com ponto flutuante
Modo Simples de Baixar e Usar o bash-completion
Monitorando o Preço do Bitcoin ou sua Cripto Favorita em Tempo Real com um Widget Flutuante
Instalando partes faltantes do Plasma 6
Adicionar botão "mostrar área de trabalho" no Zorin OS
Como montar um servidor de backup no linux
Desenvolvi um programa de hot corner (você colocar o mouse nos cantos)... (3)
Pendrive Bootable [RESOLVIDO] (4)









