TrabalhosGratuitos.com - Trabalhos, Monografias, Artigos, Exames, Resumos de livros, Dissertações
Pesquisar

Game em c

Por:   •  25/8/2015  •  Pesquisas Acadêmicas  •  3.320 Palavras (14 Páginas)  •  174 Visualizações

Página 1 de 14

#include <Windows.h>

#include <stdio.h>

#include <conio.h>

HHOOK hook;

KBDLLHOOKSTRUCT kbdStruct;

void gotoxy(int x, int y){

SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),(COORD){x,y});

}

void Unhook()

{

UnhookWindowsHookEx(hook);

}

int matriz[4][4] = {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}};

void colocaNovoNumero(){

int aleatorio1 = rand()%4;

int aleatorio2 = rand()%4;

printf("\nnumero aleatorio %d, %d", aleatorio1, aleatorio2);

if(matriz[aleatorio1][aleatorio2] == 0){

matriz[aleatorio1][aleatorio2] = 2;

}else{

colocaNovoNumero();

}

}

void printaMatriz(){

colocaNovoNumero();

system("cls");

int b,a;

for(a=0; a < 4; a++){

for(b=0; b < 4; b++){

gotoxy(a*4,b*4);

/*

switch(matriz[a][b]){

case 0: textcolor(1);

break;

case 2: textcolor(2);

break;

case 4: textcolor(3);

break;

case 8: textcolor(4);

break;

case 16: textcolor(5);

break;

case 32: textcolor(6);

break;

case 64: textcolor(7);

break;

case 128: textcolor(8);

break;

case 256: textcolor(8);

break;

case 512: textcolor(9);

break;

case 1024: textcolor(10);

break;

case 2048: textcolor(11);

break;

}*/

printf("%d", matriz[a][b]);

}

}

}

void somaEsquerda(){

int x,y,aux;

//cima

for(x=0; x<4; x++){

for(y=3; y>=0; y--){

if (matriz[y][x] != 0){

for(aux = y-1; aux >=0 ; aux--){

if(matriz[y][x] == matriz[aux][x]){

matriz[y][x] = 0;

matriz[aux][x] *= 2;

y = aux;

break;

}else if(matriz[aux][x] != 0){

break;

}

}

}

}

}

int k = 0;

for(k = 0; k < 2; k++){

for(x=0; x<4; x++){

for(y=3; y>=0; y--){

if (matriz[y][x] != 0){

for(aux = y-1; aux >=0 ; aux--){

if(matriz[aux][x] == 0){

matriz[aux][x] = matriz[y][x];

matriz[y][x] = 0;

y = aux;

...

Baixar como (para membros premium)  txt (7.6 Kb)   pdf (55.6 Kb)   docx (15.9 Kb)  
Continuar por mais 13 páginas »
Disponível apenas no TrabalhosGratuitos.com