1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2024-11-14 21:15:58 +00:00

Create game classes

This commit is contained in:
John 2021-11-08 07:40:11 -06:00
parent d833d98502
commit 8c4457a883
4 changed files with 143 additions and 0 deletions

View File

@ -0,0 +1,27 @@
extends Node
var bottomBoard # Player board
var topBoard # Opponent board
var ships # list of Ships
var shipCount # number of 'active' (un-sunk) ships
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func getState():
pass
func placeShip():
pass
func getBottomBoard():
pass
func getShipCount():
pass

View File

@ -0,0 +1,25 @@
extends Node
var players # = player1, player2, ...
var turnCount = 0
var wasHit = false
var isMultiplayer = false
# Called when the node enters the scene tree for the first time.
func _ready():
gameStart()
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func gameStart():
pass
func victoryScreen():
pass
func displayTurn():
pass

View File

@ -0,0 +1,51 @@
extends Node
var pid
var board
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
# hit: Called when opponent fires on us.
# Update internal state, and return bool hit/miss
func hit():
pass
# placeShip: called when ships are placed.
# forwards Ship locations to the Board, so that it may construct a ship
# ship: a list of ship properties {possition, orientation, size}
func placeShips(_ship):
pass
# setUp: set up the board given the placed ship locations
# translates the ship positions in the Setup UI to board-space, then places each ship
# ships: a list of lists of ship properties {{position, orientation, size}, ...}
func setUp(_ships):
pass
# turnStart: start player's turn
# Initiates the player's turn, and blocks until the player selects a location to fire upon
# returns: fire {player, coordinates}
func turnStart():
pass
# getBoard: returns the player's board
# returns: board
func getBoard():
return board
# forfeit: ends game for player
# Sinks all ships
func forfeit():
pass
# getShipCount: get the number of ships the player has left alive
func getShipCount():
pass

View File

@ -0,0 +1,40 @@
extends Node
# This is the rendered element of a "ship", auto-generated when
var size = 0 # Size of ship in units
var position # Coordinates of ship's center. Ship extends [-(size-1 >> 1), (size/2 >> 1)]
var sunk = false
var orientation = false
# index into ship sprite table
var texture = 0
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func getSize():
return size
func getPosition():
return position
func getOrientation():
return orientation
func getSunk():
return sunk
func setSunk():
sunk = true
func makeShip(in_position, in_size, in_orientation):
position = in_position
size = in_size
orientation = in_orientation