mirror of
https://github.com/JohnBreaux/Boat-Battle.git
synced 2024-11-15 05:25:57 +00:00
Pushing what I've done of the game logic.
This commit is contained in:
parent
8c4457a883
commit
eaa1617b9a
@ -1,5 +1,8 @@
|
||||
extends Node
|
||||
|
||||
# Path to Ship class, for instantiating new Ships in code
|
||||
onready var Ship = load("res://script/game/Gameplay/Ship.gd")
|
||||
|
||||
var bottomBoard # Player board
|
||||
var topBoard # Opponent board
|
||||
var ships # list of Ships
|
||||
@ -7,17 +10,16 @@ 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
|
||||
ships = []
|
||||
shipCount = 0
|
||||
|
||||
# TODO: What state?
|
||||
func getState():
|
||||
pass
|
||||
|
||||
func placeShip():
|
||||
# Place a ship on the board at board-space coordinates
|
||||
func placeShip(in_position, in_size, in_orientation):
|
||||
ships.append(Ship.new(in_position, in_size, in_orientation))
|
||||
pass
|
||||
|
||||
func getBottomBoard():
|
||||
@ -25,3 +27,18 @@ func getBottomBoard():
|
||||
|
||||
func getShipCount():
|
||||
pass
|
||||
|
||||
func _init():
|
||||
for i in range(10):
|
||||
bottomBoard.append([])
|
||||
for _i in range(0, 10):
|
||||
bottomBoard[i].resize(10)
|
||||
for i in range(10):
|
||||
topBoard.append([])
|
||||
for _i in range(0, 10):
|
||||
bottomBoard[i].resize(10)
|
||||
|
||||
func worldspace_to_boardspace(coordinate:Vector2):
|
||||
coordinate -= Vector2(36, 36)
|
||||
coordinate /= Vector2(32,32)
|
||||
return coordinate
|
||||
|
@ -1,5 +1,8 @@
|
||||
extends Node
|
||||
|
||||
# Path to Player class, for instantiating new Players in code
|
||||
var Player = "res://script/game/Gameplay/Player.gd"
|
||||
|
||||
var players # = player1, player2, ...
|
||||
var turnCount = 0
|
||||
var wasHit = false
|
||||
@ -8,7 +11,6 @@ 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.
|
||||
|
@ -1,5 +1,8 @@
|
||||
extends Node
|
||||
|
||||
# Path to Board class, for instantiating new Boards in code
|
||||
var Board = "res://script/game/Gameplay/Board.gd"
|
||||
|
||||
var pid
|
||||
var board
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
extends Node
|
||||
|
||||
# This is the rendered element of a "ship", auto-generated when
|
||||
# This is the rendered element of a "ship", generated when the game transitions from the placing state to the gameplay state
|
||||
|
||||
#
|
||||
enum Orientation {X = 1, Y = 0}
|
||||
|
||||
var size = 0 # Size of ship in units
|
||||
var position # Coordinates of ship's center. Ship extends [-(size-1 >> 1), (size/2 >> 1)]
|
||||
@ -34,7 +37,7 @@ func getSunk():
|
||||
func setSunk():
|
||||
sunk = true
|
||||
|
||||
func makeShip(in_position, in_size, in_orientation):
|
||||
func _init(in_position = Vector2(0,0), in_size = 2, in_orientation = Orientation.X):
|
||||
position = in_position
|
||||
size = in_size
|
||||
orientation = in_orientation
|
||||
|
Loading…
Reference in New Issue
Block a user