summaryrefslogtreecommitdiffhomepage
path: root/Racing-Game/4WheelCar
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2020-03-14 15:12:51 -0400
committerrealtradam <[email protected]>2020-03-14 15:12:51 -0400
commitf435ce10e93d7798ad4fe43be33cd01a4edd3dfb (patch)
treef77f4c781c1ebdea88cc89b4132c33c310acb69d /Racing-Game/4WheelCar
parentb536ec904471c8995c1910477ca1c829c2e31af5 (diff)
downloadoptimal-direction-f435ce10e93d7798ad4fe43be33cd01a4edd3dfb.tar.gz
optimal-direction-f435ce10e93d7798ad4fe43be33cd01a4edd3dfb.zip
Initial adding of files
Diffstat (limited to 'Racing-Game/4WheelCar')
-rw-r--r--Racing-Game/4WheelCar/4WheelCar.tscn142
-rw-r--r--Racing-Game/4WheelCar/RemoteTransform2D.gd16
-rw-r--r--Racing-Game/4WheelCar/SkidController.gd38
-rw-r--r--Racing-Game/4WheelCar/Skidmarks.gd21
4 files changed, 217 insertions, 0 deletions
diff --git a/Racing-Game/4WheelCar/4WheelCar.tscn b/Racing-Game/4WheelCar/4WheelCar.tscn
new file mode 100644
index 0000000..242e6d5
--- /dev/null
+++ b/Racing-Game/4WheelCar/4WheelCar.tscn
@@ -0,0 +1,142 @@
+[gd_scene load_steps=10 format=2]
+
+[ext_resource path="res://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://FrontWheel.gd" type="Script" id=3]
+[ext_resource path="res://4WheelCar/SkidController.gd" type="Script" id=4]
+[ext_resource path="res://BackWheel.gd" type="Script" id=5]
+
+[sub_resource type="RectangleShape2D" id=1]
+
+[sub_resource type="RectangleShape2D" id=2]
+extents = Vector2( 35.7301, 58.1399 )
+
+[sub_resource type="RectangleShape2D" id=3]
+extents = Vector2( 6.93714, 14.1584 )
+
+[sub_resource type="RectangleShape2D" id=4]
+extents = Vector2( 7.07375, 14.3787 )
+
+[node name="4WheelCar" type="Node"]
+
+[node name="CarBody" type="RigidBody2D" parent="."]
+position = Vector2( -0.446396, -0.582428 )
+z_index = 1
+mass = 20.0
+script = ExtResource( 1 )
+
+[node name="Engine" type="RigidBody2D" parent="CarBody"]
+position = Vector2( 0, 26 )
+z_index = 2
+mass = 30.0
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="CarBody/Engine"]
+z_index = 2
+shape = SubResource( 1 )
+disabled = true
+__meta__ = {
+"_edit_group_": true
+}
+
+[node name="Sprite" type="Sprite" parent="CarBody"]
+texture = ExtResource( 2 )
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="CarBody"]
+visible = false
+modulate = Color( 0, 0, 0, 1 )
+shape = SubResource( 2 )
+
+[node name="Wheels" type="Node" parent="CarBody"]
+
+[node name="FRWheel" type="RigidBody2D" parent="CarBody/Wheels"]
+position = Vector2( 24.7786, -36.8564 )
+mass = 15.0
+linear_damp = 0.4
+angular_damp = 7.04
+script = ExtResource( 3 )
+__meta__ = {
+"_edit_group_": true
+}
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="CarBody/Wheels/FRWheel"]
+shape = SubResource( 3 )
+disabled = true
+
+[node name="SkidController4" type="Node" parent="CarBody/Wheels/FRWheel"]
+script = ExtResource( 4 )
+
+[node name="FLWheel" type="RigidBody2D" parent="CarBody/Wheels"]
+position = Vector2( -25.6184, -36.8564 )
+mass = 15.0
+linear_damp = 0.4
+angular_damp = 7.04
+script = ExtResource( 3 )
+__meta__ = {
+"_edit_group_": true
+}
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="CarBody/Wheels/FLWheel"]
+shape = SubResource( 4 )
+disabled = true
+
+[node name="SkidController3" type="Node" parent="CarBody/Wheels/FLWheel"]
+script = ExtResource( 4 )
+
+[node name="BLWheel" type="RigidBody2D" parent="CarBody/Wheels"]
+position = Vector2( -22.4074, 38.5726 )
+mass = 15.0
+linear_damp = 0.4
+angular_damp = 7.04
+script = ExtResource( 5 )
+__meta__ = {
+"_edit_group_": true
+}
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="CarBody/Wheels/BLWheel"]
+shape = SubResource( 4 )
+disabled = true
+
+[node name="SkidController2" type="Node" parent="CarBody/Wheels/BLWheel"]
+script = ExtResource( 4 )
+
+[node name="BRWheel" type="RigidBody2D" parent="CarBody/Wheels"]
+position = Vector2( 21.2326, 38.4176 )
+mass = 15.0
+linear_damp = 0.4
+angular_damp = 7.04
+script = ExtResource( 5 )
+__meta__ = {
+"_edit_group_": true
+}
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="CarBody/Wheels/BRWheel"]
+shape = SubResource( 4 )
+disabled = true
+
+[node name="SkidController" type="Node" parent="CarBody/Wheels/BRWheel"]
+script = ExtResource( 4 )
+
+[node name="PinJointFR" type="PinJoint2D" parent="CarBody"]
+position = Vector2( 25.2246, -36.274 )
+node_a = NodePath("../Wheels/FRWheel")
+node_b = NodePath("..")
+
+[node name="PinJointBR" type="PinJoint2D" parent="CarBody"]
+position = Vector2( 21.6786, 39.155 )
+node_a = NodePath("../Wheels/BRWheel")
+node_b = NodePath("..")
+
+[node name="PinJointBL" type="PinJoint2D" parent="CarBody"]
+position = Vector2( -21.961, 39.155 )
+node_a = NodePath("../Wheels/BLWheel")
+node_b = NodePath("..")
+
+[node name="PinJointFL" type="PinJoint2D" parent="CarBody"]
+position = Vector2( -25.1724, -36.274 )
+node_a = NodePath("../Wheels/FLWheel")
+node_b = NodePath("..")
+
+[node name="PinjointEngine" type="PinJoint2D" parent="CarBody"]
+position = Vector2( 0, 26 )
+node_a = NodePath("../..")
+node_b = NodePath("..")
diff --git a/Racing-Game/4WheelCar/RemoteTransform2D.gd b/Racing-Game/4WheelCar/RemoteTransform2D.gd
new file mode 100644
index 0000000..b18f706
--- /dev/null
+++ b/Racing-Game/4WheelCar/RemoteTransform2D.gd
@@ -0,0 +1,16 @@
+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/SkidController.gd b/Racing-Game/4WheelCar/SkidController.gd
new file mode 100644
index 0000000..e7dad54
--- /dev/null
+++ b/Racing-Game/4WheelCar/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://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://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
+ \ No newline at end of file
diff --git a/Racing-Game/4WheelCar/Skidmarks.gd b/Racing-Game/4WheelCar/Skidmarks.gd
new file mode 100644
index 0000000..4c662b4
--- /dev/null
+++ b/Racing-Game/4WheelCar/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())