From 38ff9c03b79dab68abd5f5073694599d9fa62419 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Wed, 20 May 2020 17:16:36 +0930 Subject: [PATCH] Refactored draw code --- scripts/GameField.gd | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/GameField.gd b/scripts/GameField.gd index 8aa3683..3b6d6cc 100644 --- a/scripts/GameField.gd +++ b/scripts/GameField.gd @@ -58,38 +58,38 @@ func _draw() -> void: for col in cols: var color = COLORS[cell_colors.get_cell(row, col)] if color != null: - draw_rect(Rect2(Vector2(h0+col*h_space, v0+row*v_space), Vector2(h_space, v_space)), color, true) + draw_rect(Rect2(grid_corner(row, col), Vector2(h_space, v_space)), color, true) # Lines for row in rows: for col in cols: if corner_marks.get_flag(row, col, CornerMark.L_RIGHT): - draw_line(Vector2(h0+col*h_space, v0+row*v_space), Vector2(h0+(col+1)*h_space, v0+row*v_space), Color.blue) + draw_line(grid_corner(row, col), grid_corner(row, col+1), Color.blue) elif corner_marks.get_flag(row, col, CornerMark.X_RIGHT): - draw_line(Vector2(h0+(col+0.4)*h_space, v0+row*v_space), Vector2(h0+(col+0.6)*h_space, v0+row*v_space), Color.red) + draw_line(grid_corner(row, col+0.4), grid_corner(row, col+0.6), Color.red) else: - draw_line(Vector2(h0+col*h_space, v0+row*v_space), Vector2(h0+(col+1)*h_space, v0+row*v_space), Color.white) + draw_line(grid_corner(row, col), grid_corner(row, col+1), Color.white) if corner_marks.get_flag(row, col, CornerMark.L_DOWN): - draw_line(Vector2(h0+col*h_space, v0+row*v_space), Vector2(h0+col*h_space, v0+(row+1)*v_space), Color.blue) + draw_line(grid_corner(row, col), grid_corner(row+1, col), Color.blue) elif corner_marks.get_flag(row, col, CornerMark.X_DOWN): - draw_line(Vector2(h0+col*h_space, v0+(row+0.4)*v_space), Vector2(h0+col*h_space, v0+(row+0.6)*v_space), Color.red) + draw_line(grid_corner(row+0.4, col), grid_corner(row+0.6, col), Color.red) else: - draw_line(Vector2(h0+col*h_space, v0+row*v_space), Vector2(h0+col*h_space, v0+(row+1)*v_space), Color.white) + draw_line(grid_corner(row, col), grid_corner(row+1, col), Color.white) for col in cols: if corner_marks.get_flag(rows, col, CornerMark.L_RIGHT): - draw_line(Vector2(h0+col*h_space, v0+rows*v_space), Vector2(h0+(col+1)*h_space, v0+rows*v_space), Color.blue) + draw_line(grid_corner(rows, col), grid_corner(rows, col+1), Color.blue) elif corner_marks.get_flag(rows, col, CornerMark.X_RIGHT): - draw_line(Vector2(h0+(col+0.4)*h_space, v0+rows*v_space), Vector2(h0+(col+0.6)*h_space, v0+rows*v_space), Color.red) + draw_line(grid_corner(rows, col+0.4), grid_corner(rows, col+0.6), Color.red) else: - draw_line(Vector2(h0+col*h_space, v0+rows*v_space), Vector2(h0+(col+1)*h_space, v0+rows*v_space), Color.white) + draw_line(grid_corner(rows, col), grid_corner(rows, col+1), Color.white) for row in rows: if corner_marks.get_flag(row, cols, CornerMark.L_DOWN): - draw_line(Vector2(h0+cols*h_space, v0+row*v_space), Vector2(h0+cols*h_space, v0+(row+1)*v_space), Color.blue) + draw_line(grid_corner(row, cols), grid_corner(row+1, cols), Color.blue) elif corner_marks.get_flag(row, cols, CornerMark.X_DOWN): - draw_line(Vector2(h0+cols*h_space, v0+(row+0.4)*v_space), Vector2(h0+cols*h_space, v0+(row+0.6)*v_space), Color.red) + draw_line(grid_corner(row+0.4, cols), grid_corner(row+0.6, cols), Color.red) else: - draw_line(Vector2(h0+cols*h_space, v0+row*v_space), Vector2(h0+cols*h_space, v0+(row+1)*v_space), Color.white) + draw_line(grid_corner(row, cols), grid_corner(row+1, cols), Color.white) # Numbers for row in rows: