Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio2.h>
- #define TAMX 8
- #define TAMY 25
- int brandom (void) {
- int r;
- r = rand () % 2;
- if (r == 1) return 0;
- else return 1;
- }
- int main() {
- int board[TAMX][TAMY], i, j, num;
- for (i=0; i<TAMX; i++) {
- for (j=0; j<TAMY; j++)
- if (i==0 && j ==0) board[0][0]=0;
- else board[i][j]=brandom();
- }
- system("cls");
- int c, x=0, y=0;
- do {
- system("cls");
- if (c=='LEFT_KEY') { x--; }
- if (c=='RIGHT_KEY') { x++; }
- if (c=='UP_KEY') { y--; }
- if (c=='DOWN_KEY') { y++; }
- gotoxy(x,y);
- for (i=0;i<TAMX;i++) {
- for (j=0;j<TAMY;j++) {
- if (board[i][j]==0) { printf("%c", 35); }
- else { printf("|"); }
- }
- printf(" \n");
- }
- gotoxy(0,0);
- c = getch();
- }
- while(c!='ESC');
- printf("\n");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement