-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinitBoard.c
More file actions
20 lines (19 loc) · 1.01 KB
/
initBoard.c
File metadata and controls
20 lines (19 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*-----------------------------------------------------------------머릿주석-----------------------------------------------------------------*/
/*2048게임을 처음 시작할 때 사용한다. 보드판 생성을 위해 사용한다.*/
/*2048게임을 reset할 때 사용한다.*/
/*initBoard 함수 사용.*/
/*----------------------------------------------------------------------------------------------------------------------------------*/
#include"initBoard.h"
/* 게임판을 초기화 시켜주는 함수*/
void initBoard(uint8_t board[SIZE][SIZE]) {
uint8_t x, y;
for (x = 0; x < SIZE; x++) {
for (y = 0; y < SIZE; y++) {
board[x][y] = 0; // 0을 대입한다는건 빈칸이라는 뜻이다.
}
}
addRandom(board); // 1(2진수), 2(2진수) 값중 하나를 board에서의 랜덤 위치에 저장
addRandom(board);
drawBoard(board); // 게임판을 명령프롬프트 창에 출력
score = 0; // 점수는 초기에 0점부터 시작하므로 0으로 초기화
}