mirror of
https://github.com/JohnBreaux/Boat-Battle.git
synced 2024-11-15 05:25:57 +00:00
Click and drag ships, rotate ships
:)
This commit is contained in:
parent
4d1327b74f
commit
06e131834a
@ -62,6 +62,11 @@ ui_debug={
|
|||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":96,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":96,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
ui_rotate={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":2,"pressed":false,"doubleclick":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=10 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://assets/game/board_blue.png" type="Texture" id=1]
|
[ext_resource path="res://assets/game/board_blue.png" type="Texture" id=1]
|
||||||
[ext_resource path="res://script/title screen/Title-Screen-Background.png" type="Texture" id=2]
|
[ext_resource path="res://script/title screen/Title-Screen-Background.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://script/game/Gameplay.gd" type="Script" id=3]
|
[ext_resource path="res://script/game/Gameplay.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://assets/game/2longShipS.png" type="Texture" id=4]
|
||||||
|
[ext_resource path="res://assets/game/5longShipS.png" type="Texture" id=5]
|
||||||
|
[ext_resource path="res://assets/game/3longShipBS.png" type="Texture" id=6]
|
||||||
|
[ext_resource path="res://assets/game/4longShipS.png" type="Texture" id=7]
|
||||||
|
[ext_resource path="res://assets/game/3longShipAS.png" type="Texture" id=8]
|
||||||
|
[ext_resource path="res://script/game/moveShip.gd" type="Script" id=9]
|
||||||
|
|
||||||
[node name="Game" type="Control"]
|
[node name="Game" type="Control"]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 0.889
|
anchor_bottom = 0.889
|
||||||
margin_left = -0.5
|
margin_left = -0.5
|
||||||
margin_top = 1.37003
|
margin_top = 0.740086
|
||||||
margin_right = -0.5
|
margin_right = -0.5
|
||||||
margin_bottom = 41.33
|
margin_bottom = 40.7
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
@ -19,15 +25,40 @@ __meta__ = {
|
|||||||
[node name="board_blue" type="Sprite" parent="."]
|
[node name="board_blue" type="Sprite" parent="."]
|
||||||
position = Vector2( 187, 178 )
|
position = Vector2( 187, 178 )
|
||||||
texture = ExtResource( 1 )
|
texture = ExtResource( 1 )
|
||||||
__meta__ = {
|
|
||||||
"_edit_lock_": true
|
[node name="2longShipS" type="Sprite" parent="board_blue"]
|
||||||
}
|
position = Vector2( 413.784, -126.581 )
|
||||||
|
texture = ExtResource( 4 )
|
||||||
|
script = ExtResource( 9 )
|
||||||
|
|
||||||
|
[node name="3longShipAS" type="Sprite" parent="board_blue"]
|
||||||
|
position = Vector2( 412.524, 83.826 )
|
||||||
|
texture = ExtResource( 8 )
|
||||||
|
script = ExtResource( 9 )
|
||||||
|
|
||||||
|
[node name="3longShipBS" type="Sprite" parent="board_blue"]
|
||||||
|
position = Vector2( 413.784, -31.457 )
|
||||||
|
texture = ExtResource( 6 )
|
||||||
|
script = ExtResource( 9 )
|
||||||
|
|
||||||
|
[node name="4longShipS" type="Sprite" parent="board_blue"]
|
||||||
|
position = Vector2( 356.458, 75.006 )
|
||||||
|
texture = ExtResource( 7 )
|
||||||
|
script = ExtResource( 9 )
|
||||||
|
|
||||||
|
[node name="5longShipS" type="Sprite" parent="board_blue"]
|
||||||
|
position = Vector2( 354.568, -88.7834 )
|
||||||
|
texture = ExtResource( 5 )
|
||||||
|
script = ExtResource( 9 )
|
||||||
|
|
||||||
[node name="Title-Screen-Background" type="Sprite" parent="."]
|
[node name="Title-Screen-Background" type="Sprite" parent="."]
|
||||||
show_behind_parent = true
|
show_behind_parent = true
|
||||||
position = Vector2( 321.081, 179.931 )
|
position = Vector2( 321.081, 179.931 )
|
||||||
texture = ExtResource( 2 )
|
texture = ExtResource( 2 )
|
||||||
flip_h = true
|
flip_h = true
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_lock_": true
|
||||||
|
}
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||||
anchor_left = 0.912
|
anchor_left = 0.912
|
||||||
@ -47,4 +78,15 @@ margin_right = 53.0
|
|||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
text = "Forfeit"
|
text = "Forfeit"
|
||||||
|
|
||||||
|
[node name="ConfirmationDialog" type="ConfirmationDialog" parent="."]
|
||||||
|
margin_left = 199.156
|
||||||
|
margin_top = 155.6
|
||||||
|
margin_right = 458.156
|
||||||
|
margin_bottom = 225.6
|
||||||
|
window_title = "Are you sure you'd like to forfeit?"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
[connection signal="pressed" from="VBoxContainer/Forfeit" to="." method="_on_Forfeit_pressed"]
|
[connection signal="pressed" from="VBoxContainer/Forfeit" to="." method="_on_Forfeit_pressed"]
|
||||||
|
[connection signal="about_to_show" from="ConfirmationDialog" to="." method="_on_ConfirmationDialog_about_to_show"]
|
||||||
|
34
godot_ship/script/game/moveShip.gd
Normal file
34
godot_ship/script/game/moveShip.gd
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
extends Sprite
|
||||||
|
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
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 dragging and not event.pressed:
|
||||||
|
dragging = false;
|
||||||
|
|
||||||
|
if event is InputEventMouseMotion and dragging:
|
||||||
|
position = event.position;
|
||||||
|
|
||||||
|
if event.is_action_pressed("ui_rotate"):
|
||||||
|
if(event.position - position).length() < click_radius:
|
||||||
|
rotate(PI/2);
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta):
|
||||||
|
# pass
|
Loading…
Reference in New Issue
Block a user