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:
parent
d833d98502
commit
8c4457a883
27
godot_ship/script/game/Gameplay/Board.gd
Normal file
27
godot_ship/script/game/Gameplay/Board.gd
Normal 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
|
25
godot_ship/script/game/Gameplay/Game.gd
Normal file
25
godot_ship/script/game/Gameplay/Game.gd
Normal 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
|
51
godot_ship/script/game/Gameplay/Player.gd
Normal file
51
godot_ship/script/game/Gameplay/Player.gd
Normal 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
|
||||
|
40
godot_ship/script/game/Gameplay/Ship.gd
Normal file
40
godot_ship/script/game/Gameplay/Ship.gd
Normal 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
|
Loading…
Reference in New Issue
Block a user