mirror of
https://github.com/JohnBreaux/Boat-Battle.git
synced 2024-11-15 05:25:57 +00:00
Rotation only works on board now
letting the ships be able to be rotated while not on the board caused a few bugs, so I just made it so that you can't rotate the pieces unless it's on board
This commit is contained in:
parent
223944523d
commit
221608a1e3
@ -7,9 +7,11 @@ var held = false
|
|||||||
var originalPos
|
var originalPos
|
||||||
var snapOriginalPos = false
|
var snapOriginalPos = false
|
||||||
var vertical = true
|
var vertical = true
|
||||||
|
var startingPos
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
|
startingPos = position
|
||||||
pass
|
pass
|
||||||
|
|
||||||
var click_radius = 16
|
var click_radius = 16
|
||||||
@ -99,13 +101,19 @@ func _input(event):
|
|||||||
position = event.position;
|
position = event.position;
|
||||||
|
|
||||||
if event.is_action_pressed("ui_rotate"):
|
if event.is_action_pressed("ui_rotate"):
|
||||||
if(event.position - position).length() < click_radius:
|
if checkOriginalPos():
|
||||||
if vertical == true:
|
return
|
||||||
rotate(-PI/2)
|
else:
|
||||||
vertical = false
|
if originalPos == null:
|
||||||
else:
|
if position == originalPos:
|
||||||
rotate(PI/2)
|
return
|
||||||
vertical = true
|
elif(event.position - position).length() < click_radius:
|
||||||
|
if vertical == true:
|
||||||
|
rotate(-PI/2)
|
||||||
|
vertical = false
|
||||||
|
else:
|
||||||
|
rotate(PI/2)
|
||||||
|
vertical = true
|
||||||
|
|
||||||
if(position.x > 17.4 and position.x < 337.5) and (position.y > 20.2 and position.y < 335.5):
|
if(position.x > 17.4 and position.x < 337.5) and (position.y > 20.2 and position.y < 335.5):
|
||||||
# 2-Ship
|
# 2-Ship
|
||||||
@ -142,39 +150,42 @@ func _input(event):
|
|||||||
|
|
||||||
# 4-Ship
|
# 4-Ship
|
||||||
if (get_parent().get_node("4Ship").rotation_degrees == 0):
|
if (get_parent().get_node("4Ship").rotation_degrees == 0):
|
||||||
if (get_parent().get_node("4Ship").position.y > 276.8):
|
if (get_parent().get_node("4Ship").position.y > 308.8):
|
||||||
get_parent().get_node("4Ship").position.y -= 32
|
get_parent().get_node("4Ship").position.y -= 64;
|
||||||
if (get_parent().get_node("4Ship").position.y > 308.8):
|
elif (get_parent().get_node("4Ship").position.y > 276.8):
|
||||||
get_parent().get_node("4Ship").position.y -= 32
|
get_parent().get_node("4Ship").position.y -= 32;
|
||||||
if (get_parent().get_node("4Ship").position.y < 52):
|
if (get_parent().get_node("4Ship").position.y < 52):
|
||||||
get_parent().get_node("4Ship").position.y += 32
|
get_parent().get_node("4Ship").position.y += 32
|
||||||
if (get_parent().get_node("4Ship").rotation_degrees == -90):
|
if (get_parent().get_node("4Ship").rotation_degrees == -90):
|
||||||
if (get_parent().get_node("4Ship").position.x > 276.8):
|
if (get_parent().get_node("4Ship").position.x > 308.8):
|
||||||
|
get_parent().get_node("4Ship").position.x -= 64
|
||||||
|
elif (get_parent().get_node("4Ship").position.x > 276.8):
|
||||||
get_parent().get_node("4Ship").position.x -= 32
|
get_parent().get_node("4Ship").position.x -= 32
|
||||||
if (get_parent().get_node("4Ship").position.y > 308.8):
|
|
||||||
get_parent().get_node("4Ship").position.x -= 32
|
|
||||||
if (get_parent().get_node("4Ship").position.x < 52):
|
if (get_parent().get_node("4Ship").position.x < 52):
|
||||||
get_parent().get_node("4Ship").position.x += 32
|
get_parent().get_node("4Ship").position.x += 32
|
||||||
|
|
||||||
# 5-Ship
|
# 5-Ship
|
||||||
if (get_parent().get_node("5Ship").rotation_degrees == 0):
|
if (get_parent().get_node("5Ship").rotation_degrees == 0):
|
||||||
if (get_parent().get_node("5Ship").position.y > 276.8):
|
if (get_parent().get_node("5Ship").position.y > 308.8):
|
||||||
|
get_parent().get_node("5Ship").position.y -= 64
|
||||||
|
elif (get_parent().get_node("5Ship").position.y > 276.8):
|
||||||
get_parent().get_node("5Ship").position.y -= 32
|
get_parent().get_node("5Ship").position.y -= 32
|
||||||
if (get_parent().get_node("5Ship").position.y > 308.8):
|
|
||||||
get_parent().get_node("5Ship").position.y -= 32
|
if (get_parent().get_node("5Ship").position.y < 52):
|
||||||
if (get_parent().get_node("5Ship").position.y < 84.8):
|
get_parent().get_node("5Ship").position.y += 64
|
||||||
|
elif (get_parent().get_node("5Ship").position.y < 84.8):
|
||||||
get_parent().get_node("5Ship").position.y += 32
|
get_parent().get_node("5Ship").position.y += 32
|
||||||
if (get_parent().get_node("5Ship").position.y < 52):
|
|
||||||
get_parent().get_node("5Ship").position.y += 32
|
|
||||||
if (get_parent().get_node("5Ship").rotation_degrees == -90):
|
if (get_parent().get_node("5Ship").rotation_degrees == -90):
|
||||||
if (get_parent().get_node("5Ship").position.x > 276.8):
|
if (get_parent().get_node("5Ship").position.x > 308.8):
|
||||||
|
get_parent().get_node("5Ship").position.x -= 64
|
||||||
|
elif (get_parent().get_node("5Ship").position.x > 276.8):
|
||||||
get_parent().get_node("5Ship").position.x -= 32
|
get_parent().get_node("5Ship").position.x -= 32
|
||||||
if (get_parent().get_node("5Ship").position.x > 308.8):
|
|
||||||
get_parent().get_node("5Ship").position.x -= 32
|
if (get_parent().get_node("5Ship").position.x < 52):
|
||||||
if (get_parent().get_node("5Ship").position.x < 84.8):
|
get_parent().get_node("5Ship").position.x += 64
|
||||||
|
elif (get_parent().get_node("5Ship").position.x < 84.8):
|
||||||
get_parent().get_node("5Ship").position.x += 32
|
get_parent().get_node("5Ship").position.x += 32
|
||||||
if (get_parent().get_node("5Ship").position.x < 52):
|
|
||||||
get_parent().get_node("5Ship").position.x += 32
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
#func _process(delta):
|
#func _process(delta):
|
||||||
@ -192,3 +203,9 @@ func drop(impulse=Vector2.ZERO):
|
|||||||
apply_central_impulse(impulse)
|
apply_central_impulse(impulse)
|
||||||
held = false
|
held = false
|
||||||
snapOriginalPos = false
|
snapOriginalPos = false
|
||||||
|
|
||||||
|
func checkOriginalPos():
|
||||||
|
if position == startingPos:
|
||||||
|
return true
|
||||||
|
else:
|
||||||
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user