appese debugger warnings and remove/change unneeded/unused code

This commit is contained in:
jake 2023-02-18 17:23:22 -05:00
parent dc24d163a2
commit 74580ebfa9
3 changed files with 16 additions and 32 deletions

34
Main.gd
View file

@ -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"))

View file

@ -9,7 +9,7 @@ export var en_passant_tile = false
export var en_passant_kill_tile = false
export var castling_rook = ""
func _on_Area2D_input_event(viewport, event, shape_idx):
func _on_Area2D_input_event(_viewport, event, _shape_idx):
if event.is_action_pressed("mouse1"):
emit_signal("move_clicked")

View file

@ -11,10 +11,6 @@ export var team = 0
export var has_moved = false
export var in_check = false
const move_patterns = {
pawn = [[0,0,0],[2,0,0],[0,0,0]]
}
func get_move_pattern():
return self.move_patterns.get(piece)
@ -52,12 +48,12 @@ func _ready():
#position = Vector2(500,500)
pass
func init(piece, color, team = 0):
get_texture().set_region(Rect2(piece, color, CELL_W, CELL_H))
func init(new_piece, color, new_team = 0):
get_texture().set_region(Rect2(new_piece, color, CELL_W, CELL_H))
self.set_piece(self.get_piece_name_by_region())
self.set_team(team)
self.set_team(new_team)
func _on_Area2D_input_event(viewport, event, shape_idx):
func _on_Area2D_input_event(_viewport, event, _shape_idx):
if event.is_action_pressed("mouse1"):
emit_signal("clicked")