mirror of
https://github.com/JohnBreaux/Boat-Battle.git
synced 2025-02-04 12:28:35 +00:00
Partial fire functionality added.
Currently hides all ship placement UI and makes visible all fire functionality. The crosshair currently does not snap to a grid. The ships are saved in an area of location objects holding the length, orientation, and coordinates of the ship.
This commit is contained in:
29
godot_ship/script/game/Gameplay/Crosshair.gd
Normal file
29
godot_ship/script/game/Gameplay/Crosshair.gd
Normal file
@@ -0,0 +1,29 @@
|
||||
extends Sprite
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
var snapped = false #when snapped if true crosshair stops following mouse
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
func _physics_process(delta):
|
||||
if snapped == false:
|
||||
position += (get_global_mouse_position() - position)/10
|
||||
|
||||
func _input(event):
|
||||
#Check if left click is being clicked and the sprite is visible (i.e only checks for inputs after ship positions are confirmed)
|
||||
if event is InputEventMouseButton and event.button_index == BUTTON_LEFT and visible == true:
|
||||
#Locks the position of the crosshair with left click
|
||||
snapped = true
|
||||
if event is InputEventMouseButton and event.button_index == BUTTON_RIGHT and visible == true:
|
||||
#Unlocks the position of the crosshair with right click
|
||||
snapped = false
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
Reference in New Issue
Block a user