summaryrefslogtreecommitdiffhomepage
path: root/Racing-Game/4WheelCar
diff options
context:
space:
mode:
Diffstat (limited to 'Racing-Game/4WheelCar')
-rw-r--r--Racing-Game/4WheelCar/4WheelCar.tscn28
-rw-r--r--Racing-Game/4WheelCar/BackWheel.gd1
-rw-r--r--Racing-Game/4WheelCar/CarBody.gd2
-rw-r--r--Racing-Game/4WheelCar/Engine.gd13
-rw-r--r--Racing-Game/4WheelCar/Weight.gd26
-rw-r--r--Racing-Game/4WheelCar/Weight.tscn23
-rw-r--r--Racing-Game/4WheelCar/WeightCreation.gd23
-rw-r--r--Racing-Game/4WheelCar/Wheel.gd2
-rw-r--r--Racing-Game/4WheelCar/WheelCreation.gd5
9 files changed, 80 insertions, 43 deletions
diff --git a/Racing-Game/4WheelCar/4WheelCar.tscn b/Racing-Game/4WheelCar/4WheelCar.tscn
index de13e82..ff5d89f 100644
--- a/Racing-Game/4WheelCar/4WheelCar.tscn
+++ b/Racing-Game/4WheelCar/4WheelCar.tscn
@@ -1,16 +1,14 @@
-[gd_scene load_steps=8 format=2]
+[gd_scene load_steps=7 format=2]
[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://Art(non-orig)/crosshair(isorig).png" type="Texture" id=3]
+[ext_resource path="res://4WheelCar/WeightCreation.gd" type="Script" id=4]
[ext_resource path="res://4WheelCar/CarProperties.gd" type="Script" id=6]
[ext_resource path="res://4WheelCar/WheelCreation.gd" type="Script" id=9]
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 35.7301, 58.1399 )
-[sub_resource type="RectangleShape2D" id=1]
-
[node name="4WheelCar" type="Node"]
script = ExtResource( 6 )
@@ -28,26 +26,8 @@ visible = false
modulate = Color( 0, 0, 0, 1 )
shape = SubResource( 2 )
-[node name="Engine" type="RigidBody2D" parent="CarBody"]
-position = Vector2( 0, 26 )
-z_index = 2
-mass = 10.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/Engine"]
-texture = ExtResource( 3 )
-
[node name="Wheels" type="Node" parent="CarBody"]
script = ExtResource( 9 )
-[node name="PinjointEngine" type="PinJoint2D" parent="CarBody"]
-position = Vector2( 0, 26 )
-node_a = NodePath("../Engine")
-node_b = NodePath("..")
+[node name="Weight" type="Node" parent="CarBody"]
+script = ExtResource( 4 )
diff --git a/Racing-Game/4WheelCar/BackWheel.gd b/Racing-Game/4WheelCar/BackWheel.gd
index e4a95d7..1d6ee18 100644
--- a/Racing-Game/4WheelCar/BackWheel.gd
+++ b/Racing-Game/4WheelCar/BackWheel.gd
@@ -33,7 +33,6 @@ func _process(delta):
if Input.is_action_pressed("forward"):
if !Input.is_action_pressed("brake"):
- print("GO")
apply_central_impulse(Vector2(0,-gear(velocity, hp, acceleration)).rotated(carAngle)*delta*5000)
else:
pass
diff --git a/Racing-Game/4WheelCar/CarBody.gd b/Racing-Game/4WheelCar/CarBody.gd
index 7a77fd4..266fa13 100644
--- a/Racing-Game/4WheelCar/CarBody.gd
+++ b/Racing-Game/4WheelCar/CarBody.gd
@@ -9,6 +9,8 @@ var directionUnitVector
func _ready():
angular_damp = 5
+
+
pass
func _process(_delta):
diff --git a/Racing-Game/4WheelCar/Engine.gd b/Racing-Game/4WheelCar/Engine.gd
deleted file mode 100644
index 46c8298..0000000
--- a/Racing-Game/4WheelCar/Engine.gd
+++ /dev/null
@@ -1,13 +0,0 @@
-extends RigidBody2D
-
-# 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):
- set_rotation(get_node("../../CarBody").get_rotation())
diff --git a/Racing-Game/4WheelCar/Weight.gd b/Racing-Game/4WheelCar/Weight.gd
new file mode 100644
index 0000000..ea9e615
--- /dev/null
+++ b/Racing-Game/4WheelCar/Weight.gd
@@ -0,0 +1,26 @@
+extends RigidBody2D
+
+
+# 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):
+# pass
+
+func initVars(dataArray):
+# #---Creating and attaching pinjoint to wheel
+ mass = dataArray[2]
+ var tempA = PinJoint2D.new()
+ tempA.set_position(Vector2(dataArray[0],dataArray[1]))
+ print(get_parent().get_parent().get_path())
+ tempA.set_node_a(get_path())
+ tempA.set_node_b(get_parent().get_parent().get_path())
+ tempA.softness = 0
+ tempA.bias = 0
+ tempA.disable_collision = true
+ get_parent().add_child(tempA)
+# #---
+ pass
diff --git a/Racing-Game/4WheelCar/Weight.tscn b/Racing-Game/4WheelCar/Weight.tscn
new file mode 100644
index 0000000..4735229
--- /dev/null
+++ b/Racing-Game/4WheelCar/Weight.tscn
@@ -0,0 +1,23 @@
+[gd_scene load_steps=4 format=2]
+
+[ext_resource path="res://Art(non-orig)/crosshair(isorig).png" type="Texture" id=1]
+[ext_resource path="res://4WheelCar/Weight.gd" type="Script" id=2]
+
+[sub_resource type="RectangleShape2D" id=1]
+
+[node name="Weight" type="RigidBody2D"]
+position = Vector2( -0.446396, 25.4176 )
+z_index = 2
+mass = 10.0
+script = ExtResource( 2 )
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
+z_index = 2
+shape = SubResource( 1 )
+disabled = true
+__meta__ = {
+"_edit_group_": true
+}
+
+[node name="Sprite" type="Sprite" parent="."]
+texture = ExtResource( 1 )
diff --git a/Racing-Game/4WheelCar/WeightCreation.gd b/Racing-Game/4WheelCar/WeightCreation.gd
new file mode 100644
index 0000000..6d6f607
--- /dev/null
+++ b/Racing-Game/4WheelCar/WeightCreation.gd
@@ -0,0 +1,23 @@
+extends Node
+
+
+# This script creates and attaches all "masses". This makes it possible
+# to simulate unbalanced weight distribution in a vehicle
+
+
+# Called when the node enters the scene tree for the first time.
+func _ready():
+ createWeight([0,30,30])
+ pass # Replace with function body.
+
+
+# Called every frame. 'delta' is the elapsed time since the previous frame.
+#func _process(delta):
+# pass
+
+func createWeight(dataArray):
+ var weighttemp_resource = load("res://4WheelCar/Weight.tscn")
+ var weighttemp = weighttemp_resource.instance()
+ weighttemp.set_position(Vector2(dataArray[0],dataArray[1]))
+ add_child(weighttemp)
+ weighttemp.initVars(dataArray)
diff --git a/Racing-Game/4WheelCar/Wheel.gd b/Racing-Game/4WheelCar/Wheel.gd
index 88ab9b1..49024fb 100644
--- a/Racing-Game/4WheelCar/Wheel.gd
+++ b/Racing-Game/4WheelCar/Wheel.gd
@@ -28,8 +28,6 @@ func initVars(dataArray):
# #---Creating and attaching pinjoint to wheel
var tempA = PinJoint2D.new()
tempA.set_position(Vector2(dataArray[0],dataArray[1]))
-# var tempB = Sprite.new()
- print(get_parent().get_parent().get_path())
tempA.set_node_a(get_path())
tempA.set_node_b(get_parent().get_parent().get_path())
tempA.softness = 0
diff --git a/Racing-Game/4WheelCar/WheelCreation.gd b/Racing-Game/4WheelCar/WheelCreation.gd
index 7c6b192..6be1a26 100644
--- a/Racing-Game/4WheelCar/WheelCreation.gd
+++ b/Racing-Game/4WheelCar/WheelCreation.gd
@@ -1,9 +1,8 @@
extends Node
-# Declare member variables here. Examples:
-# var a = 2
-# var b = "text"
+# This script creates and attaches all the wheels. Depending on the variables
+# given to this script, it can generate different type of vehicles
# Called when the node enters the scene tree for the first time.