origin stuff I was late committing
This commit is contained in:
186
PlayerScript.gd
186
PlayerScript.gd
@@ -86,15 +86,16 @@ var Keys = []
|
|||||||
var RouteCounter = 0
|
var RouteCounter = 0
|
||||||
var SendToRobo = []
|
var SendToRobo = []
|
||||||
var RetraveledArray = []
|
var RetraveledArray = []
|
||||||
|
var Ori = 0
|
||||||
|
var amnt = 0
|
||||||
func _input(event):
|
func _input(event):
|
||||||
#if Current_Position != TargetCord:
|
#if Current_Position != TargetCord:
|
||||||
if event.is_action_pressed("ui_left"):
|
if event.is_action_pressed("ui_left"):
|
||||||
goLeft()
|
LeftTurn()
|
||||||
Been_There()
|
Been_There()
|
||||||
AutoBacktrack = false
|
AutoBacktrack = false
|
||||||
elif event.is_action_pressed("ui_right"):
|
elif event.is_action_pressed("ui_right"):
|
||||||
goRight()
|
RightTurn()
|
||||||
Been_There()
|
Been_There()
|
||||||
AutoBacktrack = false
|
AutoBacktrack = false
|
||||||
elif event.is_action_pressed("ui_up"):
|
elif event.is_action_pressed("ui_up"):
|
||||||
@@ -106,7 +107,14 @@ func _input(event):
|
|||||||
Been_There()
|
Been_There()
|
||||||
AutoBacktrack = false
|
AutoBacktrack = false
|
||||||
elif event.is_action_pressed("ui_accept"):
|
elif event.is_action_pressed("ui_accept"):
|
||||||
AutoSolve()
|
#AutoSolve()
|
||||||
|
$Sprite2D.rotation_degrees += 180
|
||||||
|
$Backv.rotation_degrees += 180
|
||||||
|
$Forwardv.rotation_degrees += 180
|
||||||
|
$Leftv.rotation_degrees += 180
|
||||||
|
$Rightv.rotation_degrees += 180
|
||||||
|
Ori += 180
|
||||||
|
|
||||||
elif event.is_action_pressed("ui_text_backspace"):
|
elif event.is_action_pressed("ui_text_backspace"):
|
||||||
print(SendToRobo)
|
print(SendToRobo)
|
||||||
print(Current_Position)
|
print(Current_Position)
|
||||||
@@ -115,8 +123,8 @@ func _input(event):
|
|||||||
CommonsSort(arr1)
|
CommonsSort(arr1)
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
FoundGoal()
|
#FoundGoal()
|
||||||
AllObjectsFound()
|
#AllObjectsFound()
|
||||||
CallableRaycastData()
|
CallableRaycastData()
|
||||||
Mark(Prev_dir)
|
Mark(Prev_dir)
|
||||||
WhatMove()
|
WhatMove()
|
||||||
@@ -134,7 +142,10 @@ func _process(delta):
|
|||||||
IntersectionDumping()
|
IntersectionDumping()
|
||||||
CordsDumping()
|
CordsDumping()
|
||||||
FinishCircling()
|
FinishCircling()
|
||||||
|
#Orienting()
|
||||||
|
#print(Current_Position)
|
||||||
|
#print(Ordered_Commands_Backward)
|
||||||
|
#print(Individual_Steps)
|
||||||
func FoundGoal():
|
func FoundGoal():
|
||||||
if TargetCord.find(Cords[-1]) != -1 and TargetsArray.find(Cords[-1]) == -1:
|
if TargetCord.find(Cords[-1]) != -1 and TargetsArray.find(Cords[-1]) == -1:
|
||||||
Goal = true
|
Goal = true
|
||||||
@@ -410,8 +421,13 @@ func BackTracking():
|
|||||||
print("The distance from the last intersection is : ", Distance_From_Intersection)
|
print("The distance from the last intersection is : ", Distance_From_Intersection)
|
||||||
print("To get to the last intersection follow these steps : ", TrackBack)
|
print("To get to the last intersection follow these steps : ", TrackBack)
|
||||||
if Detail_Dict.Type == "Dead End" and Current_Position != [0,0]:
|
if Detail_Dict.Type == "Dead End" and Current_Position != [0,0]:
|
||||||
|
print("Moving")
|
||||||
|
FullReverseTurn()
|
||||||
|
print("Done reverse")
|
||||||
|
GoBack(TrackBack)
|
||||||
GoBack(TrackBack)
|
GoBack(TrackBack)
|
||||||
print(TrackBack)
|
print(TrackBack)
|
||||||
|
print("Done")
|
||||||
|
|
||||||
func Circling():
|
func Circling():
|
||||||
if Been_There_Array.size() > 3:
|
if Been_There_Array.size() > 3:
|
||||||
@@ -664,7 +680,15 @@ func MoveAfterIntersection():
|
|||||||
else:
|
else:
|
||||||
Invert = false
|
Invert = false
|
||||||
|
|
||||||
if Invert == true:
|
if Invert == true:#print(Direction.find(Dir))
|
||||||
|
# if Ori == 0 or Ori == 180:
|
||||||
|
# print("YYYYYYY")
|
||||||
|
# if Ori == 0:
|
||||||
|
# print("Same/Normal Orientation")
|
||||||
|
# print(Dir)
|
||||||
|
# if Ori == 180:
|
||||||
|
# print("Flipped")
|
||||||
|
# print(Direction[Direction.find(Dir)])
|
||||||
#print(Prev_dir_Opp)
|
#print(Prev_dir_Opp)
|
||||||
IntOptions[-1].erase(Prev_dir_Opp)
|
IntOptions[-1].erase(Prev_dir_Opp)
|
||||||
#print(IntOptions)
|
#print(IntOptions)
|
||||||
@@ -717,7 +741,7 @@ func IntersectionWaysAvailable():
|
|||||||
|
|
||||||
func Been_There():
|
func Been_There():
|
||||||
if Been_There_Overide == false:
|
if Been_There_Overide == false:
|
||||||
if Cords.find(Current_Position) == -1:
|
if Cords.find(Current_Position) == -1 or Prev_dir == "R" or Prev_dir == "L":
|
||||||
Cords.push_back(Current_Position)
|
Cords.push_back(Current_Position)
|
||||||
Cords_Copy = Cords.duplicate(true)
|
Cords_Copy = Cords.duplicate(true)
|
||||||
Cords = Cords_Copy
|
Cords = Cords_Copy
|
||||||
@@ -869,12 +893,14 @@ func goDown():
|
|||||||
dir = Vector2.DOWN
|
dir = Vector2.DOWN
|
||||||
FullCount += 1
|
FullCount += 1
|
||||||
if not D.is_colliding():
|
if not D.is_colliding():
|
||||||
self.global_position.y += 24
|
#self.global_position.y += 24
|
||||||
Current_Position[1] -=1
|
#Current_Position[1] -=1
|
||||||
Prev_dir = "D"
|
Prev_dir = "F"
|
||||||
Prev_dir_Opp = "U"
|
Prev_dir_Opp = "F"
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
Been_There_Overide = false
|
Been_There_Overide = false
|
||||||
|
#Ori = 0
|
||||||
|
Orienting("D")
|
||||||
else:
|
else:
|
||||||
Been_There_Overide = true
|
Been_There_Overide = true
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
@@ -884,12 +910,14 @@ func goUp():
|
|||||||
var U = $Backv
|
var U = $Backv
|
||||||
dir = Vector2.UP
|
dir = Vector2.UP
|
||||||
if not U.is_colliding():
|
if not U.is_colliding():
|
||||||
self.global_position.y -= 24
|
#self.global_position.y -= 24
|
||||||
Current_Position[1] +=1
|
#Current_Position[1] +=1
|
||||||
Prev_dir = "U"
|
Prev_dir = "F"
|
||||||
Prev_dir_Opp = "D"
|
Prev_dir_Opp = "F"
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
Been_There_Overide = false
|
Been_There_Overide = false
|
||||||
|
#Ori = 180
|
||||||
|
Orienting("U")
|
||||||
else:
|
else:
|
||||||
Been_There_Overide = true
|
Been_There_Overide = true
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
@@ -897,44 +925,124 @@ func goUp():
|
|||||||
#BeenTheirFromPrevCord()
|
#BeenTheirFromPrevCord()
|
||||||
FullCount += 1
|
FullCount += 1
|
||||||
|
|
||||||
func goRight():
|
func RightTurn():
|
||||||
var R = $Rightv
|
var R = $Rightv
|
||||||
dir = Vector2.RIGHT
|
dir = Vector2.RIGHT
|
||||||
if not R.is_colliding():
|
if not R.is_colliding():
|
||||||
self.global_position.x += 24.4
|
#self.global_position.x += 24.4
|
||||||
Current_Position[0] +=1
|
#Current_Position[0] +=1
|
||||||
|
$Sprite2D.rotation_degrees -= 90
|
||||||
|
$Backv.rotation_degrees -= 90
|
||||||
|
$Forwardv.rotation_degrees -= 90
|
||||||
|
$Leftv.rotation_degrees -= 90
|
||||||
|
$Rightv.rotation_degrees -=90
|
||||||
Prev_dir = "R"
|
Prev_dir = "R"
|
||||||
Prev_dir_Opp = "L"
|
Prev_dir_Opp = "L"
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
Been_There_Overide = false
|
Been_There_Overide = false
|
||||||
|
Ori -= 90
|
||||||
|
print(Ori)
|
||||||
|
Orienting("R")
|
||||||
else:
|
else:
|
||||||
Been_There_Overide = true
|
Been_There_Overide = true
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
print("There is something to your right")
|
print("There is something to your right")
|
||||||
FullCount += 1
|
FullCount += 1
|
||||||
|
|
||||||
func goLeft():
|
func LeftTurn():
|
||||||
var L = $Leftv
|
var L = $Leftv
|
||||||
dir = Vector2.LEFT
|
dir = Vector2.LEFT
|
||||||
if not L.is_colliding():
|
if not L.is_colliding():
|
||||||
self.global_position.x -= 24.4
|
#self.global_position.x -= 24.4
|
||||||
Current_Position[0] -=1
|
#Current_Position[0] -=1
|
||||||
|
$Sprite2D.rotation_degrees += 90
|
||||||
|
$Backv.rotation_degrees += 90
|
||||||
|
$Forwardv.rotation_degrees += 90
|
||||||
|
$Leftv.rotation_degrees += 90
|
||||||
|
$Rightv.rotation_degrees +=90
|
||||||
Prev_dir = "L"
|
Prev_dir = "L"
|
||||||
Prev_dir_Opp = "R"
|
Prev_dir_Opp = "R"
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
Been_There_Overide = false
|
Been_There_Overide = false
|
||||||
|
Ori += 90
|
||||||
|
Orienting("L")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
Been_There_Overide = true
|
Been_There_Overide = true
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
print("There is something to your left")
|
print("There is something to your left")
|
||||||
FullCount += 1
|
FullCount += 1
|
||||||
|
|
||||||
|
|
||||||
|
func Orienting(Dir):
|
||||||
|
var Base = [0,90,180,270]
|
||||||
|
var Way = ""
|
||||||
|
var Default = ["U","D","L","R"]
|
||||||
|
var LOrientation = ["R","L","D","U"]
|
||||||
|
var ROrientation = ["L","R", "U","D"]
|
||||||
|
var BOrientation = ["D","U","R","L"]
|
||||||
|
if Ori < 0:
|
||||||
|
Ori = 360 + Ori
|
||||||
|
if Ori >= 360:
|
||||||
|
Ori = Ori - 360
|
||||||
|
|
||||||
|
#print(Dir)
|
||||||
|
#print(Ori)
|
||||||
|
if Ori == 270:
|
||||||
|
if Dir == "U":
|
||||||
|
self.global_position.x -= 24.4
|
||||||
|
Current_Position[0] -=1
|
||||||
|
if Dir == "D":
|
||||||
|
self.global_position.x += 24.4
|
||||||
|
Current_Position[0] +=1
|
||||||
|
if Dir == "F":
|
||||||
|
self.global_position.x += 24.4
|
||||||
|
Current_Position[0] +=1
|
||||||
|
|
||||||
|
if Ori == 180:
|
||||||
|
if Dir == "U":
|
||||||
|
self.global_position.y += 24
|
||||||
|
Current_Position[1] -=1
|
||||||
|
if Dir == "D":
|
||||||
|
self.global_position.y -= 24
|
||||||
|
Current_Position[1] +=1
|
||||||
|
if Dir == "F":
|
||||||
|
self.global_position.y -= 24
|
||||||
|
Current_Position[1] +=1
|
||||||
|
|
||||||
|
if Ori == 90:
|
||||||
|
if Dir == "U":
|
||||||
|
self.global_position.x += 24.4
|
||||||
|
Current_Position[0] +=1
|
||||||
|
if Dir == "D":
|
||||||
|
self.global_position.x -= 24.4
|
||||||
|
Current_Position[0] -=1
|
||||||
|
if Dir == "F":
|
||||||
|
self.global_position.x -= 24.4
|
||||||
|
Current_Position[0] -=1
|
||||||
|
|
||||||
|
if Ori == 0:
|
||||||
|
if Dir == "U":
|
||||||
|
self.global_position.y -= 24
|
||||||
|
Current_Position[1] +=1
|
||||||
|
if Dir == "D":
|
||||||
|
self.global_position.y += 24
|
||||||
|
Current_Position[1] -=1
|
||||||
|
if Dir == "F":
|
||||||
|
self.global_position.y += 24
|
||||||
|
Current_Position[1] -=1
|
||||||
|
|
||||||
|
|
||||||
#***** Auto Movement *****
|
#***** Auto Movement *****
|
||||||
func Move(SetDirection):
|
func Move(SetDirection):
|
||||||
|
|
||||||
if SetDirection == "R":
|
if SetDirection == "R":
|
||||||
self.global_position.x += 24.4
|
$Sprite2D.rotation_degrees -= 90
|
||||||
Current_Position[0] +=1
|
$Backv.rotation_degrees -= 90
|
||||||
|
$Forwardv.rotation_degrees -= 90
|
||||||
|
$Leftv.rotation_degrees -= 90
|
||||||
|
$Rightv.rotation_degrees -=90
|
||||||
|
Ori -= 90
|
||||||
Prev_dir = "R"
|
Prev_dir = "R"
|
||||||
Prev_dir_Opp = "L"
|
Prev_dir_Opp = "L"
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
@@ -942,28 +1050,32 @@ func Move(SetDirection):
|
|||||||
FullCount += 1
|
FullCount += 1
|
||||||
|
|
||||||
if SetDirection == "L":
|
if SetDirection == "L":
|
||||||
self.global_position.x -= 24.4
|
$Sprite2D.rotation_degrees += 90
|
||||||
Current_Position[0] -=1
|
$Backv.rotation_degrees += 90
|
||||||
|
$Forwardv.rotation_degrees += 90
|
||||||
|
$Leftv.rotation_degrees += 90
|
||||||
|
$Rightv.rotation_degrees +=90
|
||||||
|
Ori += 90
|
||||||
Prev_dir = "L"
|
Prev_dir = "L"
|
||||||
Prev_dir_Opp = "R"
|
Prev_dir_Opp = "R"
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
Been_There()
|
Been_There()
|
||||||
FullCount += 1
|
FullCount += 1
|
||||||
|
|
||||||
if SetDirection == "D":
|
if SetDirection == "F":
|
||||||
self.global_position.y += 24
|
self.global_position.y += 24
|
||||||
Current_Position[1] -=1
|
Current_Position[1] -=1
|
||||||
Prev_dir = "D"
|
Prev_dir = "F"
|
||||||
Prev_dir_Opp = "U"
|
Prev_dir_Opp = "F"
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
Been_There()
|
Been_There()
|
||||||
FullCount += 1
|
FullCount += 1
|
||||||
|
|
||||||
if SetDirection == "U":
|
if SetDirection == "F":
|
||||||
self.global_position.y -= 24
|
self.global_position.y -= 24
|
||||||
Current_Position[1] +=1
|
Current_Position[1] +=1
|
||||||
Prev_dir = "U"
|
Prev_dir = "F"
|
||||||
Prev_dir_Opp = "D"
|
Prev_dir_Opp = "F"
|
||||||
move += Move_Strength
|
move += Move_Strength
|
||||||
Been_There()
|
Been_There()
|
||||||
FullCount += 1
|
FullCount += 1
|
||||||
@@ -1006,6 +1118,14 @@ func RMove(SetDirection):
|
|||||||
Been_There()
|
Been_There()
|
||||||
FullCount += 1
|
FullCount += 1
|
||||||
|
|
||||||
|
func FullReverseTurn():
|
||||||
|
$Sprite2D.rotation_degrees += 180
|
||||||
|
$Backv.rotation_degrees += 180
|
||||||
|
$Forwardv.rotation_degrees += 180
|
||||||
|
$Leftv.rotation_degrees += 180
|
||||||
|
$Rightv.rotation_degrees += 180
|
||||||
|
Ori += 180
|
||||||
|
|
||||||
func AutoSolve():
|
func AutoSolve():
|
||||||
var DirectionStrengths = [6,6,5,6]
|
var DirectionStrengths = [6,6,5,6]
|
||||||
var Colliders = RaycastHelper()
|
var Colliders = RaycastHelper()
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ position = Vector2(26.6667, 26.6667)
|
|||||||
scale = Vector2(0.9, 0.9)
|
scale = Vector2(0.9, 0.9)
|
||||||
|
|
||||||
[node name="Rightv" type="RayCast2D" parent="TextureRect/Player"]
|
[node name="Rightv" type="RayCast2D" parent="TextureRect/Player"]
|
||||||
|
visible = false
|
||||||
scale = Vector2(1, 0.950617)
|
scale = Vector2(1, 0.950617)
|
||||||
exclude_parent = false
|
exclude_parent = false
|
||||||
target_position = Vector2(32.8, 0)
|
target_position = Vector2(32.8, 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user