diff options
Diffstat (limited to 'Main.gd')
-rw-r--r-- | Main.gd | 34 |
1 files changed, 11 insertions, 23 deletions
@@ -3,7 +3,7 @@ extends Node export (PackedScene) var piece_scene export (PackedScene) var movetile_scene -var board = new_board2() +var board = new_board() var board_cell = 128 const BOARD_WIDTH = 7 # starting at 0..7 const BOARD_HEIGHT = 7 @@ -36,7 +36,7 @@ func _ready(): OS.set_window_always_on_top(true) # horrifying discovery: this occurs after the signal capturing functions -func _process(delta): +func _process(_delta): safely_handle_movement = false func remove_movement_layer(): @@ -53,7 +53,7 @@ func piece_clicked(piece): remove_movement_layer() else: if ! safely_handle_movement: - var piece_name = piece.get_piece() + #var piece_name = piece.get_piece() #rint("You clicked on a %s, team %s" % [piece_name, piece.get_team()]) var location = click_spot() #rint("Spot: %s " % location) @@ -120,28 +120,18 @@ func in_square(vect2): #rint(vect2) return vect2 -func new_board2(): +func new_board(): # x → # y # ↓ # [0][0] = top left, [0][7] = bottom left, [7][0] = top right, [7][7] = bottom right - var board = [] + var new_board = [] for i in BOARD_HEIGHT + 1: - board.append([]) - board[i].resize(BOARD_WIDTH + 1) + new_board.append([]) + new_board[i].resize(BOARD_WIDTH + 1) for j in BOARD_WIDTH + 1: - board[i][j] = 0 - return board - -func new_board(): - return [[0,0,0,0,0,0,0,0], - [0,0,0,0,0,0,0,0], - [0,0,0,0,0,0,0,0], - [0,0,0,0,0,0,0,0], - [0,0,0,0,0,0,0,0], - [0,0,0,0,0,0,0,0], - [0,0,0,0,0,0,0,0], - [0,0,0,0,0,0,0,0]] + new_board[i][j] = 0 + return new_board func board_add_piece(piece, x, y): board[x][y] = piece @@ -418,16 +408,14 @@ func make_tiles(coords, pattern, go_range, cant_attack, curr_team, var pattern1 = pattern[1] var a = 0 var b = 0 - var board_size_x = 7 # starting at 0 - var board_size_y = 7 var made_tile = false - for i in range(1,go_range+1): + for _i in range(1,go_range+1): a += pattern0 b += pattern1 # dont go out of bounds: not bigger than board size but not smaller than 0 - if (x + a) <= board_size_x and (y + b) <= board_size_y and (x + a) >= 0 and (y + b) >= 0 : + if (x + a) <= BOARD_WIDTH and (y + b) <= BOARD_HEIGHT and (x + a) >= 0 and (y + b) >= 0 : var check = board[x + a][y + b] if ! check and ! dict.get("must_attack"): spawn_move_tile([x + a, y + b], dict.get("tile_is_en_passant"), dict.get("en_passant_pawn"), dict.get("castling_rook")) |