D1249360 費柏叡

1. 開場畫面 按下enter開始遊戲

DEMO

无标题视频——使用Clipchamp制作 (8).mp4

2.計算最高分數與現在分數

現在分數,最高分數

typedef struct
{
    int x;
    int y;
    int score;
    int bestScore;//new
    int rotate;
    int fallTime;
    ShapeId queue[4];
} State;
void logic(Block canvas[CANVAS_HEIGHT][CANVAS_WIDTH], State* state)
{
...
// 紀錄分數
state->score += clearLine(canvas);
// 紀錄最高分
if (state->score > state->bestScore) {
state->bestScore = state->score;
}
}

螢幕擷取畫面 2024-06-06 000223.png

3.新增暫停鍵

//printCanvas
if (state->isPause) {
    printf("\\033[%d;%dH\\x1b[41m PAUSEING\\x1b[0m\\033[%d;%dH", CANVAS_HEIGHT - 8, CANVAS_WIDTH * 2 - 12 , CANVAS_HEIGHT + 5, 0);
}

//logic
if (GetAsyncKeyState(PAUSE_KEY) & 0x8000) {
    state->isPause = !state->isPause;
}

if (!state->isPause){
...
}
else if (state->isPause) {
    printCanvas(canvas, state);
}