From feb18d37762eb8f4414625175576f8fe9debd992 Mon Sep 17 00:00:00 2001 From: realtradam Date: Sun, 15 Mar 2020 15:16:39 -0400 Subject: refactoring complete close #4 --- Racing-Game/4WheelCar/4WheelCar.tscn | 3 ++- Racing-Game/4WheelCar/BLLine.gd | 25 ------------------ Racing-Game/4WheelCar/BRLine.gd | 30 ---------------------- Racing-Game/4WheelCar/FLLine.gd | 25 ------------------ Racing-Game/4WheelCar/FRLine.gd | 25 ------------------ Racing-Game/4WheelCar/FrontWheel.gd | 2 +- Racing-Game/4WheelCar/FrontWheelSprite.gd | 17 ------------- Racing-Game/4WheelCar/RemoteTransform2D.gd | 16 ------------ Racing-Game/4WheelCar/Skid/BLLine.gd | 25 ++++++++++++++++++ Racing-Game/4WheelCar/Skid/BRLine.gd | 30 ++++++++++++++++++++++ Racing-Game/4WheelCar/Skid/FLLine.gd | 25 ++++++++++++++++++ Racing-Game/4WheelCar/Skid/FRLine.gd | 25 ++++++++++++++++++ Racing-Game/4WheelCar/Skid/SkidController.gd | 38 ++++++++++++++++++++++++++++ Racing-Game/4WheelCar/Skid/Skidmark.tscn | 11 ++++++++ Racing-Game/4WheelCar/Skid/Skidmarks.gd | 21 +++++++++++++++ Racing-Game/4WheelCar/SkidController.gd | 38 ---------------------------- Racing-Game/4WheelCar/Skidmark.tscn | 11 -------- Racing-Game/4WheelCar/Skidmarks.gd | 21 --------------- 18 files changed, 178 insertions(+), 210 deletions(-) delete mode 100644 Racing-Game/4WheelCar/BLLine.gd delete mode 100644 Racing-Game/4WheelCar/BRLine.gd delete mode 100644 Racing-Game/4WheelCar/FLLine.gd delete mode 100644 Racing-Game/4WheelCar/FRLine.gd delete mode 100644 Racing-Game/4WheelCar/FrontWheelSprite.gd delete mode 100644 Racing-Game/4WheelCar/RemoteTransform2D.gd create mode 100644 Racing-Game/4WheelCar/Skid/BLLine.gd create mode 100644 Racing-Game/4WheelCar/Skid/BRLine.gd create mode 100644 Racing-Game/4WheelCar/Skid/FLLine.gd create mode 100644 Racing-Game/4WheelCar/Skid/FRLine.gd create mode 100644 Racing-Game/4WheelCar/Skid/SkidController.gd create mode 100644 Racing-Game/4WheelCar/Skid/Skidmark.tscn create mode 100644 Racing-Game/4WheelCar/Skid/Skidmarks.gd delete mode 100644 Racing-Game/4WheelCar/SkidController.gd delete mode 100644 Racing-Game/4WheelCar/Skidmark.tscn delete mode 100644 Racing-Game/4WheelCar/Skidmarks.gd (limited to 'Racing-Game/4WheelCar') diff --git a/Racing-Game/4WheelCar/4WheelCar.tscn b/Racing-Game/4WheelCar/4WheelCar.tscn index 84b4549..958cc39 100644 --- a/Racing-Game/4WheelCar/4WheelCar.tscn +++ b/Racing-Game/4WheelCar/4WheelCar.tscn @@ -3,9 +3,10 @@ [ext_resource path="res://4WheelCar/CarBody.gd" type="Script" id=1] [ext_resource path="res://Art(non-orig)/PNG/Cars/big/blue/car_blue_2.png" type="Texture" id=2] [ext_resource path="res://4WheelCar/FrontWheel.gd" type="Script" id=3] -[ext_resource path="res://4WheelCar/SkidController.gd" type="Script" id=4] +[ext_resource path="res://4WheelCar/Skid/SkidController.gd" type="Script" id=4] [ext_resource path="res://4WheelCar/BackWheel.gd" type="Script" id=5] + [sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=2] diff --git a/Racing-Game/4WheelCar/BLLine.gd b/Racing-Game/4WheelCar/BLLine.gd deleted file mode 100644 index 042b034..0000000 --- a/Racing-Game/4WheelCar/BLLine.gd +++ /dev/null @@ -1,25 +0,0 @@ -extends Line2D - -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" -var tempnode = 0 -var on = true - -# Called when the node enters the scene tree for the first time. -func _ready(): - tempnode = get_node("../Cars/4WheelCar/CarBody/Wheels/BLWheel") - pass # Replace with function body. - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass - -func _on_BLWheel_slip(): - if(on): - add_point(tempnode.get_global_position()) - - -func _on_BLWheel_end(): - duplicate(1) - on = false diff --git a/Racing-Game/4WheelCar/BRLine.gd b/Racing-Game/4WheelCar/BRLine.gd deleted file mode 100644 index 16578e3..0000000 --- a/Racing-Game/4WheelCar/BRLine.gd +++ /dev/null @@ -1,30 +0,0 @@ -extends Line2D - -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" -var tempnode = 0 -var on = true - -# Called when the node enters the scene tree for the first time. -func _ready(): - print("ready") - tempnode = get_node("../Cars/4WheelCar/CarBody/Wheels/BRWheel") - clear_points() - pass # Replace with function body. - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass - -func _on_BRWheel_slip(): - while on: - print("slip2") - add_point(tempnode.get_global_position()) - - -func _on_BRWheel_end(): - on = false - print("duplicated") - var duplication = duplicate(13) - duplication.request_ready() diff --git a/Racing-Game/4WheelCar/FLLine.gd b/Racing-Game/4WheelCar/FLLine.gd deleted file mode 100644 index fffcf04..0000000 --- a/Racing-Game/4WheelCar/FLLine.gd +++ /dev/null @@ -1,25 +0,0 @@ -extends Line2D - -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" -var tempnode = 0 -var on = true - -# Called when the node enters the scene tree for the first time. -func _ready(): - tempnode = get_node("../Cars/4WheelCar/CarBody/Wheels/FLWheel") - pass # Replace with function body. - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass - -func _on_FLWheel_slip(): - if(on): - add_point(tempnode.get_global_position()) - - -func _on_FLWheel_end(): - duplicate(1) - on = false diff --git a/Racing-Game/4WheelCar/FRLine.gd b/Racing-Game/4WheelCar/FRLine.gd deleted file mode 100644 index e1fbc0f..0000000 --- a/Racing-Game/4WheelCar/FRLine.gd +++ /dev/null @@ -1,25 +0,0 @@ -extends Line2D - -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" -var tempnode = 0 -var on = true - -# Called when the node enters the scene tree for the first time. -func _ready(): - tempnode = get_node("../Cars/4WheelCar/CarBody/Wheels/FRWheel") - pass # Replace with function body. - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass - -func _on_FRWheel_slip(): - if(on): - add_point(tempnode.get_global_position()) - - -func _on_FRWheel_end(): - duplicate(1) - on = false diff --git a/Racing-Game/4WheelCar/FrontWheel.gd b/Racing-Game/4WheelCar/FrontWheel.gd index 280a8a3..d4e5af4 100644 --- a/Racing-Game/4WheelCar/FrontWheel.gd +++ b/Racing-Game/4WheelCar/FrontWheel.gd @@ -10,7 +10,7 @@ var velAngle var carAngle var delay = 0 -onready var skidObj = preload("res://4WheelCar/Skidmark.tscn") +onready var skidObj = preload("res://4WheelCar/Skid/Skidmark.tscn") var steerDamp = 1 diff --git a/Racing-Game/4WheelCar/FrontWheelSprite.gd b/Racing-Game/4WheelCar/FrontWheelSprite.gd deleted file mode 100644 index e0426d4..0000000 --- a/Racing-Game/4WheelCar/FrontWheelSprite.gd +++ /dev/null @@ -1,17 +0,0 @@ -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. - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): -# if Input.is_key_pressed(KEY_A): -# set_rotation(get_node("../../../../CarBody").get_rotation()-PI/4) -# if Input.is_key_pressed(KEY_D): -# set_rotation(get_node("../../../../CarBody").get_rotation()+PI/4) - pass diff --git a/Racing-Game/4WheelCar/RemoteTransform2D.gd b/Racing-Game/4WheelCar/RemoteTransform2D.gd deleted file mode 100644 index b18f706..0000000 --- a/Racing-Game/4WheelCar/RemoteTransform2D.gd +++ /dev/null @@ -1,16 +0,0 @@ -extends RemoteTransform2D - -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" -var camera - -# Called when the node enters the scene tree for the first time. -func _ready(): - var camera = get_node("/root/World/Camera2D") - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - #camera.global_position = global_position - #camera.global_rotation = global_rotation; - pass diff --git a/Racing-Game/4WheelCar/Skid/BLLine.gd b/Racing-Game/4WheelCar/Skid/BLLine.gd new file mode 100644 index 0000000..042b034 --- /dev/null +++ b/Racing-Game/4WheelCar/Skid/BLLine.gd @@ -0,0 +1,25 @@ +extends Line2D + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" +var tempnode = 0 +var on = true + +# Called when the node enters the scene tree for the first time. +func _ready(): + tempnode = get_node("../Cars/4WheelCar/CarBody/Wheels/BLWheel") + pass # Replace with function body. + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func _on_BLWheel_slip(): + if(on): + add_point(tempnode.get_global_position()) + + +func _on_BLWheel_end(): + duplicate(1) + on = false diff --git a/Racing-Game/4WheelCar/Skid/BRLine.gd b/Racing-Game/4WheelCar/Skid/BRLine.gd new file mode 100644 index 0000000..16578e3 --- /dev/null +++ b/Racing-Game/4WheelCar/Skid/BRLine.gd @@ -0,0 +1,30 @@ +extends Line2D + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" +var tempnode = 0 +var on = true + +# Called when the node enters the scene tree for the first time. +func _ready(): + print("ready") + tempnode = get_node("../Cars/4WheelCar/CarBody/Wheels/BRWheel") + clear_points() + pass # Replace with function body. + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func _on_BRWheel_slip(): + while on: + print("slip2") + add_point(tempnode.get_global_position()) + + +func _on_BRWheel_end(): + on = false + print("duplicated") + var duplication = duplicate(13) + duplication.request_ready() diff --git a/Racing-Game/4WheelCar/Skid/FLLine.gd b/Racing-Game/4WheelCar/Skid/FLLine.gd new file mode 100644 index 0000000..fffcf04 --- /dev/null +++ b/Racing-Game/4WheelCar/Skid/FLLine.gd @@ -0,0 +1,25 @@ +extends Line2D + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" +var tempnode = 0 +var on = true + +# Called when the node enters the scene tree for the first time. +func _ready(): + tempnode = get_node("../Cars/4WheelCar/CarBody/Wheels/FLWheel") + pass # Replace with function body. + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func _on_FLWheel_slip(): + if(on): + add_point(tempnode.get_global_position()) + + +func _on_FLWheel_end(): + duplicate(1) + on = false diff --git a/Racing-Game/4WheelCar/Skid/FRLine.gd b/Racing-Game/4WheelCar/Skid/FRLine.gd new file mode 100644 index 0000000..e1fbc0f --- /dev/null +++ b/Racing-Game/4WheelCar/Skid/FRLine.gd @@ -0,0 +1,25 @@ +extends Line2D + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" +var tempnode = 0 +var on = true + +# Called when the node enters the scene tree for the first time. +func _ready(): + tempnode = get_node("../Cars/4WheelCar/CarBody/Wheels/FRWheel") + pass # Replace with function body. + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func _on_FRWheel_slip(): + if(on): + add_point(tempnode.get_global_position()) + + +func _on_FRWheel_end(): + duplicate(1) + on = false diff --git a/Racing-Game/4WheelCar/Skid/SkidController.gd b/Racing-Game/4WheelCar/Skid/SkidController.gd new file mode 100644 index 0000000..b1d8233 --- /dev/null +++ b/Racing-Game/4WheelCar/Skid/SkidController.gd @@ -0,0 +1,38 @@ +extends Node + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" +var skidSwitch = false # Is the wheel currantly skidding? +var skidFile # Stores the skid file +var skidRecent # Holds the most recent skidmark + +var deleteme = 0; + +# Called when the node enters the scene tree for the first time. +func _ready(): + skidFile = load("res://4WheelCar/Skid/Skidmark.tscn") + skidRecent = skidFile.instance() + add_child(skidRecent) + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + + if(skidSwitch && get_parent().isSkid):#if controller believes car is skidding and the wheel is skidding + #ignore the status and let the skid keep drawing + pass + elif(!skidSwitch && get_parent().isSkid):#controller doesnt skid, but wheel is supposed to be skidding + # create new skidding child, and set skid to true + + skidSwitch = true + skidFile = load("res://4WheelCar/Skid/Skidmark.tscn") + skidRecent = skidFile.instance() + add_child(skidRecent) + #set to run + pass + elif(!get_parent().isSkid): + #stop child from skidding and store + skidRecent.skidDraw = false + skidSwitch = false + pass + diff --git a/Racing-Game/4WheelCar/Skid/Skidmark.tscn b/Racing-Game/4WheelCar/Skid/Skidmark.tscn new file mode 100644 index 0000000..17ecee0 --- /dev/null +++ b/Racing-Game/4WheelCar/Skid/Skidmark.tscn @@ -0,0 +1,11 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://4WheelCar/Skid/Skidmarks.gd" type="Script" id=1] +[ext_resource path="res://Art(non-orig)/PNG/Objects/skidmark_short_1.png" type="Texture" id=2] + +[node name="Skidmark" type="Line2D"] +position = Vector2( -21.2326, -38.4176 ) +default_color = Color( 0.4, 0.501961, 1, 1 ) +texture = ExtResource( 2 ) +texture_mode = 192263440 +script = ExtResource( 1 ) diff --git a/Racing-Game/4WheelCar/Skid/Skidmarks.gd b/Racing-Game/4WheelCar/Skid/Skidmarks.gd new file mode 100644 index 0000000..4c662b4 --- /dev/null +++ b/Racing-Game/4WheelCar/Skid/Skidmarks.gd @@ -0,0 +1,21 @@ +extends Line2D + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" +var skidDraw = true +var wheel +var carBody + +# Called when the node enters the scene tree for the first time. +func _ready(): + wheel = get_parent().get_parent() + carBody = get_parent().get_parent().get_parent().get_parent() + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + global_position = Vector2(0,0) + global_rotation = 0 + if(skidDraw): + add_point(wheel.get_global_position()) diff --git a/Racing-Game/4WheelCar/SkidController.gd b/Racing-Game/4WheelCar/SkidController.gd deleted file mode 100644 index 745b195..0000000 --- a/Racing-Game/4WheelCar/SkidController.gd +++ /dev/null @@ -1,38 +0,0 @@ -extends Node - -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" -var skidSwitch = false # Is the wheel currantly skidding? -var skidFile # Stores the skid file -var skidRecent # Holds the most recent skidmark - -var deleteme = 0; - -# Called when the node enters the scene tree for the first time. -func _ready(): - skidFile = load("res://4WheelCar/Skidmark.tscn") - skidRecent = skidFile.instance() - add_child(skidRecent) - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - - if(skidSwitch && get_parent().isSkid):#if controller believes car is skidding and the wheel is skidding - #ignore the status and let the skid keep drawing - pass - elif(!skidSwitch && get_parent().isSkid):#controller doesnt skid, but wheel is supposed to be skidding - # create new skidding child, and set skid to true - - skidSwitch = true - skidFile = load("res://4WheelCar/Skidmark.tscn") - skidRecent = skidFile.instance() - add_child(skidRecent) - #set to run - pass - elif(!get_parent().isSkid): - #stop child from skidding and store - skidRecent.skidDraw = false - skidSwitch = false - pass - diff --git a/Racing-Game/4WheelCar/Skidmark.tscn b/Racing-Game/4WheelCar/Skidmark.tscn deleted file mode 100644 index 46c5d40..0000000 --- a/Racing-Game/4WheelCar/Skidmark.tscn +++ /dev/null @@ -1,11 +0,0 @@ -[gd_scene load_steps=3 format=2] - -[ext_resource path="res://Art(non-orig)/PNG/Objects/skidmark_short_1.png" type="Texture" id=1] -[ext_resource path="res://4WheelCar/Skidmarks.gd" type="Script" id=2] - -[node name="Skidmark" type="Line2D"] -position = Vector2( -21.2326, -38.4176 ) -default_color = Color( 0.4, 0.501961, 1, 1 ) -texture = ExtResource( 1 ) -texture_mode = 192263440 -script = ExtResource( 2 ) diff --git a/Racing-Game/4WheelCar/Skidmarks.gd b/Racing-Game/4WheelCar/Skidmarks.gd deleted file mode 100644 index 4c662b4..0000000 --- a/Racing-Game/4WheelCar/Skidmarks.gd +++ /dev/null @@ -1,21 +0,0 @@ -extends Line2D - -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" -var skidDraw = true -var wheel -var carBody - -# Called when the node enters the scene tree for the first time. -func _ready(): - wheel = get_parent().get_parent() - carBody = get_parent().get_parent().get_parent().get_parent() - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - global_position = Vector2(0,0) - global_rotation = 0 - if(skidDraw): - add_point(wheel.get_global_position()) -- cgit v1.2.3