mirror of
https://github.com/JohnBreaux/Boat-Battle.git
synced 2025-02-04 12:28:35 +00:00
Improve menuing, and convert ships to RigidBody2D for accurate positioning.
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
extends LineEdit
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
func _on_Debug_clear_in():
|
||||
clear()
|
||||
|
||||
@@ -3,7 +3,7 @@ extends TextEdit
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
var _errno = MessageBus.connect("print_console", self, "_on_Debug_print_text")
|
||||
pass # Replace with function body.
|
||||
grab_focus()
|
||||
|
||||
|
||||
func _on_Debug_print_text(text):
|
||||
|
||||
@@ -48,7 +48,7 @@ func _input(event):
|
||||
# open debug menu
|
||||
debug_active = !debug_active;
|
||||
# Hand the keyboard focus to the next valid focus
|
||||
if (!debug_active): find_next_valid_focus().grab_focus()
|
||||
if (!debug_active) && find_next_valid_focus(): find_next_valid_focus().grab_focus()
|
||||
|
||||
func _on_LineEdit_text_entered(line):
|
||||
emit_signal("clear_in")
|
||||
|
||||
@@ -8,6 +8,7 @@ extends Control
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
grab_focus()
|
||||
pass # Replace with function body.
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
@@ -17,3 +18,4 @@ func _ready():
|
||||
|
||||
func _on_Forfeit_pressed():
|
||||
queue_free();
|
||||
MessageBus.emit_signal("change_scene", "Title")
|
||||
|
||||
@@ -25,7 +25,14 @@ func _ready():
|
||||
debug_menu = preload("res://scenes/Debug Menu.tscn")
|
||||
if debug_enabled:
|
||||
add_child(debug_menu.instance())
|
||||
_on_scene_start("Title")
|
||||
|
||||
# Ensure the scene doesn't become empty
|
||||
func _process(_delta):
|
||||
# Make sure there's something running
|
||||
# Debug counts as one child
|
||||
if get_child_count() < 1 + int(debug_enabled):
|
||||
MessageBus.emit_signal("change_scene", "Title")
|
||||
pass
|
||||
|
||||
# Creates a new instance of each menu scene
|
||||
func _on_scene_start(scene):
|
||||
|
||||
@@ -1,29 +1,30 @@
|
||||
extends Sprite
|
||||
extends RigidBody2D
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
var held = false
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
var dragging = false;
|
||||
var click_radius = 32
|
||||
var orient = 0;
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventMouseButton and event.button_index == BUTTON_LEFT:
|
||||
if(event.position - position).length() < click_radius:
|
||||
if not dragging and event.pressed:
|
||||
dragging = true;
|
||||
if (event.position - position).length() < click_radius:
|
||||
if not held and event.pressed:
|
||||
held = true;
|
||||
|
||||
if dragging and not event.pressed:
|
||||
dragging = false;
|
||||
if held and not event.pressed:
|
||||
held = false;
|
||||
position = position.snapped(Vector2(32, 32)) + Vector2(2, 2)
|
||||
|
||||
if event is InputEventMouseMotion and dragging:
|
||||
if event is InputEventMouseMotion and held:
|
||||
position = event.position;
|
||||
|
||||
if event.is_action_pressed("ui_rotate"):
|
||||
@@ -32,3 +33,15 @@ func _input(event):
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
|
||||
func pickup():
|
||||
if held:
|
||||
return
|
||||
mode = RigidBody2D.MODE_STATIC
|
||||
held = true
|
||||
|
||||
func drop(impulse=Vector2.ZERO):
|
||||
if held:
|
||||
mode = RigidBody2D.MODE_RIGID
|
||||
apply_central_impulse(impulse)
|
||||
held = false
|
||||
|
||||
@@ -1,19 +1,10 @@
|
||||
extends Control
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
find_next_valid_focus().grab_focus()
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
|
||||
func _on_Button_pressed():
|
||||
queue_free()
|
||||
MessageBus.emit_signal("change_scene", "Title")
|
||||
|
||||
@@ -6,17 +6,20 @@ extends Control
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
#$VBoxContainer/Singleplayer.grab_focus()
|
||||
pass
|
||||
$VBoxContainer/Singleplayer.grab_focus()
|
||||
|
||||
func _on_Singleplayer_pressed():
|
||||
MessageBus.emit_signal("change_scene", "Singleplayer")
|
||||
|
||||
queue_free()
|
||||
|
||||
func _on_Multiplayer_pressed():
|
||||
MessageBus.emit_signal("change_scene", "Multiplayer")
|
||||
queue_free()
|
||||
|
||||
func _on_Options_pressed():
|
||||
MessageBus.emit_signal("change_scene", "Options")
|
||||
queue_free()
|
||||
|
||||
func _on_Quit_pressed():
|
||||
MessageBus.emit_signal("quit")
|
||||
queue_free()
|
||||
|
||||
Reference in New Issue
Block a user