Skip to content

Commit

Permalink
#5 block begin y index is -2
Browse files Browse the repository at this point in the history
  • Loading branch information
fpdjsns committed Aug 1, 2020
1 parent 77afb74 commit 765ebbb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Tetris/js/blockType.js
Expand Up @@ -24,7 +24,7 @@ const blockType = [
name: "I",
color: "darkred",
shape: [
[[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]],
[[0, 0, 0, 0], [0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0]],
[[0, 0, 1, 0], [0, 0, 1, 0], [0, 0, 1, 0], [0, 0, 1, 0]]
]
},
Expand Down
6 changes: 4 additions & 2 deletions Tetris/js/constants.js
Expand Up @@ -9,10 +9,12 @@ const BIG_BLOCK_SIZE = SMALL_BLOCK_SIZE * SMALL_BLOCK_NUM;

const NEXT_BLOCK_SIZE = 3;

const HIDE_SCREEN_HEIGHT_NUM = 2;

const GAME_SCREEN_WIDTH_NUM = 10;
const GAME_SCREEN_HEIGHT_NUM = 20;
const GAME_SCREEN_HEIGHT_NUM = 20 + HIDE_SCREEN_HEIGHT_NUM;
const GAME_SCREEN_WIDTH = GAME_SCREEN_WIDTH_NUM * SMALL_BLOCK_SIZE;
const GAME_SCREEN_HEIGHT = GAME_SCREEN_HEIGHT_NUM * SMALL_BLOCK_SIZE;
const GAME_SCREEN_HEIGHT = (GAME_SCREEN_HEIGHT_NUM - HIDE_SCREEN_HEIGHT_NUM) * SMALL_BLOCK_SIZE;

const GAME_SCREEN_LEFT = canvas.clientLeft;
const GAME_SCREEN_RIGHT = canvas.clientLeft + GAME_SCREEN_WIDTH;
Expand Down
4 changes: 2 additions & 2 deletions Tetris/js/gameAlgorithm.js
Expand Up @@ -127,7 +127,7 @@ var eraseRow = function(row) {
var eraseOneBlock = function(x, y) {
ctx.clearRect(
x * SMALL_BLOCK_SIZE + BLOCK_GAP,
y * SMALL_BLOCK_SIZE + BLOCK_GAP,
(y - HIDE_SCREEN_HEIGHT_NUM) * SMALL_BLOCK_SIZE + BLOCK_GAP,
SMALL_BLOCK_SIZE - BLOCK_GAP,
SMALL_BLOCK_SIZE - BLOCK_GAP
);
Expand All @@ -137,7 +137,7 @@ var drawOneBlockWithColor = function(x, y, colorName) {
ctx.fillStyle = colorName;
ctx.fillRect(
x * SMALL_BLOCK_SIZE + BLOCK_GAP,
y * SMALL_BLOCK_SIZE + BLOCK_GAP,
(y - HIDE_SCREEN_HEIGHT_NUM) * SMALL_BLOCK_SIZE + BLOCK_GAP,
SMALL_BLOCK_SIZE - BLOCK_GAP,
SMALL_BLOCK_SIZE - BLOCK_GAP
);
Expand Down

0 comments on commit 765ebbb

Please sign in to comment.