1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2024-11-15 05:25:57 +00:00

Rotation fix for ships being rotated after already being placed on board

If rotating the ship hangs the piece off the board, it will move the piece back on the board accordingly
This commit is contained in:
tommy-l-ngo 2021-11-01 15:10:12 -05:00
parent bc319fa464
commit 254a9d86d4

View File

@ -110,58 +110,70 @@ func _input(event):
# 2-Ship # 2-Ship
if (get_parent().get_node("2Ship").rotation_degrees == 0): if (get_parent().get_node("2Ship").rotation_degrees == 0):
if (get_parent().get_node("2Ship").position.y > 308): if (get_parent().get_node("2Ship").position.y > 308):
position.y -= 32 get_parent().get_node("2Ship").position.y -= 32
if (get_parent().get_node("2Ship").rotation_degrees == -90): if (get_parent().get_node("2Ship").rotation_degrees == -90):
if (get_parent().get_node("2Ship").position.x > 308): if (get_parent().get_node("2Ship").position.x > 308):
position.x -= 32 get_parent().get_node("2Ship").position.x -= 32
# 3-Ship A # 3-Ship A
if (get_parent().get_node("3ShipA").rotation_degrees == 0): if (get_parent().get_node("3ShipA").rotation_degrees == 0):
if (get_parent().get_node("3ShipA").position.y > 308): if (get_parent().get_node("3ShipA").position.y > 308):
position.y -= 32 get_parent().get_node("3ShipA").position.y -= 32
if (get_parent().get_node("3ShipA").position.y < 52): if (get_parent().get_node("3ShipA").position.y < 52):
position.y += 32 get_parent().get_node("3ShipA").position.y += 32
if (get_parent().get_node("3ShipA").rotation_degrees == -90): if (get_parent().get_node("3ShipA").rotation_degrees == -90):
if (get_parent().get_node("3ShipA").position.x > 308): if (get_parent().get_node("3ShipA").position.x > 308):
position.x -= 32 get_parent().get_node("3ShipA").position.x -= 32
if (get_parent().get_node("3ShipA").position.x < 52): if (get_parent().get_node("3ShipA").position.x < 52):
position.x += 32 get_parent().get_node("3ShipA").position.x += 32
# 3-Ship B # 3-Ship B
if (get_parent().get_node("3ShipB").rotation_degrees == 0): if (get_parent().get_node("3ShipB").rotation_degrees == 0):
if (get_parent().get_node("3ShipB").position.y > 308): if (get_parent().get_node("3ShipB").position.y > 308):
position.y -= 32 get_parent().get_node("3ShipB").position.y -= 32
if (get_parent().get_node("3ShipB").position.y < 52): if (get_parent().get_node("3ShipB").position.y < 52):
position.y += 32 get_parent().get_node("3ShipB").position.y += 32
if (get_parent().get_node("3ShipB").rotation_degrees == -90): if (get_parent().get_node("3ShipB").rotation_degrees == -90):
if (get_parent().get_node("3ShipB").position.x > 308): if (get_parent().get_node("3ShipB").position.x > 308):
position.x -= 32 get_parent().get_node("3ShipB").position.x -= 32
if (get_parent().get_node("3ShipB").position.x < 52): if (get_parent().get_node("3ShipB").position.x < 52):
position.x += 32 get_parent().get_node("3ShipB").position.x += 32
# 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 > 276.8):
position.y -= 64 get_parent().get_node("4Ship").position.y -= 32
if (get_parent().get_node("4Ship").position.y > 308.8):
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):
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 > 276.8):
position.x -= 64 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):
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 > 276.8):
position.y -= 64 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 < 84.8): if (get_parent().get_node("5Ship").position.y < 84.8):
position.y += 64 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 > 276.8):
position.x -= 64 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 < 84.8): if (get_parent().get_node("5Ship").position.x < 84.8):
position.x += 64 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):