林秉軒、王勻
function int readOperation() {
var int ch;
let ch = Keyboard.readChar();
do Output.backSpace();
if ((ch = 130)) { return 0; }
if ((ch = 131)) { return 1; }
if ((ch = 132)) { return 2; }
if ((ch = 133)) { return 3; }
return -1;
}
// 130 = left
// 131 = up
// 132 = right
// 133 = down
根據盤面狀態繪圖
function void drawCell(int type, int x, int y, int size) {
var int r, w;
let r = size / 2;
let w = 2;
do Screen.setColor(false);
do Screen.drawRectangle(x, y, x + size, y + size);
if (type = PLAYER) {
do Screen.setColor(true);
do Screen.drawCircle(x + r, y + r, r);
}
if (type = POINT) {
do Screen.setColor(true);
do Screen.drawCircle(x + r, y + r, w);
}
if (type = NORMAL_BLOCK) {
do Screen.setColor(true);
do Screen.drawRectangle(x, y, x + size, y + size);
}
if (type = STABLE_BLOCK) {
do Screen.setColor(true);
do Screen.drawRectangle(x, y, x + size, y + size);
do Screen.setColor(false);
do Screen.drawRectangle(x + w, y + w, x + size - w, y + size - w);
do Screen.setColor(true);
do Screen.drawLine(x, y, x + size, y + size);
do Screen.drawLine(x + size, y, x, y + size);
}
return;
}
\(\Rightarrow\)只針對更新的區域重新渲染
\(\Rightarrow\)若造成消行則重新隨機一個位置,至多重新三次
\(\Rightarrow\)若放置的固定箱子造成遊戲結束,則改為放置一般箱子,增加玩家的操作空間