1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2024-11-15 05:25:57 +00:00

Fix up some stuff

This commit is contained in:
John 2021-11-11 20:45:38 -06:00
parent a8f96eed9d
commit fae2631637
2 changed files with 17 additions and 9 deletions

View File

@ -8,10 +8,13 @@ var top_board # Opponent board
var ships # list of Ships var ships # list of Ships
var ship_count # number of 'active' (un-sunk) ships var ship_count # number of 'active' (un-sunk) ships
# a board is square. This is its side lengths
var board_len = 10
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
ships = [] ships = []
shipCount = 0 ship_count = 0
# TODO: What state? # TODO: What state?
func getState(): func getState():
@ -26,21 +29,26 @@ func getBottomBoard():
pass pass
func getShipCount(): func getShipCount():
pass return ship_count
func _init(): func _init():
# Initialize the bottom_board to a 10x10 array # Initialize the bottom_board to a 10x10 array
for i in range(10): for _row in range(board_len):
bottom_board.append([]) bottom_board.append([])
for _i in range(0, 10): for column in bottom_board:
bottom_board[i].resize(10) column.resize(10)
# Initialize the top_board to a 10x10 array # Initialize the top_board to a 10x10 array
for i in range(10): for _row in range(board_len):
top_board.append([]) top_board.append([])
for _i in range(0, 10): for column in top_board:
top_board[i].resize(10) column.resize(board_len)
# worldspace_to_boardspace: convert a Vector2 in world-space to board-space # worldspace_to_boardspace: convert a Vector2 in world-space to board-space
func worldspace_to_boardspace(coordinate:Vector2): func worldspace_to_boardspace(coordinate:Vector2):
# subtract 36 to get the position relative to (0,0) on the board, and integer divide by 32 # subtract 36 to get the position relative to (0,0) on the board, and integer divide by 32
return Vector2(int(coordinate.x - 36) >> 5, int(coordinate.y-36) >> 5) return Vector2(int(coordinate.x - 36) >> 5, int(coordinate.y-36) >> 5)
# Coordinates of ship's center. Ship extends [-(size-1 >> 1), (size/2 >> 1)]
func shiptoboard(ship:Ship):
for i in range (ship.)
pass

View File

@ -6,7 +6,7 @@ var Board = "res://script/game/Gameplay/Board.gd"
# Player ID of this player # Player ID of this player
var pid var pid
# board (an instance of the Board class) # board (an instance of the Board class)
var board onready var board = Board.new()
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():