summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Racing-Game/4WheelCar/4WheelCar.tscn1
-rw-r--r--Racing-Game/4WheelCar/CarBody.gd4
-rw-r--r--Racing-Game/4WheelCar/CarProperties.gd3
-rw-r--r--Racing-Game/4WheelCar/Weight/Weight.tscn1
-rw-r--r--Racing-Game/4WheelCar/Wheels/BackWheel.gd11
-rw-r--r--Racing-Game/4WheelCar/Wheels/FrontWheel.gd28
-rw-r--r--Racing-Game/4WheelCar/Wheels/Skid/SkidController.gd2
-rw-r--r--Racing-Game/4WheelCar/Wheels/Wheel.gd5
-rw-r--r--Racing-Game/4WheelCar/Wheels/WheelCreation.gd2
9 files changed, 30 insertions, 27 deletions
diff --git a/Racing-Game/4WheelCar/4WheelCar.tscn b/Racing-Game/4WheelCar/4WheelCar.tscn
index a6e289a..fd8844f 100644
--- a/Racing-Game/4WheelCar/4WheelCar.tscn
+++ b/Racing-Game/4WheelCar/4WheelCar.tscn
@@ -6,7 +6,6 @@
[ext_resource path="res://4WheelCar/CarProperties.gd" type="Script" id=6]
[ext_resource path="res://4WheelCar/Wheels/WheelCreation.gd" type="Script" id=9]
-
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 35.7301, 58.1399 )
diff --git a/Racing-Game/4WheelCar/CarBody.gd b/Racing-Game/4WheelCar/CarBody.gd
index 266fa13..53b73d2 100644
--- a/Racing-Game/4WheelCar/CarBody.gd
+++ b/Racing-Game/4WheelCar/CarBody.gd
@@ -9,8 +9,8 @@ var directionUnitVector
func _ready():
angular_damp = 5
-
-
+
+
pass
func _process(_delta):
diff --git a/Racing-Game/4WheelCar/CarProperties.gd b/Racing-Game/4WheelCar/CarProperties.gd
index c4a5ad5..4374de5 100644
--- a/Racing-Game/4WheelCar/CarProperties.gd
+++ b/Racing-Game/4WheelCar/CarProperties.gd
@@ -8,9 +8,6 @@ var steerMinimum = 1
var hp = 4.0
var acceleration = 5
-# Declare member variables here. Examples:
-# var a = 2
-# var b = "text"
# Called when the node enters the scene tree for the first time.
diff --git a/Racing-Game/4WheelCar/Weight/Weight.tscn b/Racing-Game/4WheelCar/Weight/Weight.tscn
index 094f257..b3d89ff 100644
--- a/Racing-Game/4WheelCar/Weight/Weight.tscn
+++ b/Racing-Game/4WheelCar/Weight/Weight.tscn
@@ -3,7 +3,6 @@
[ext_resource path="res://4WheelCar/Weight/Weight.gd" type="Script" id=1]
[ext_resource path="res://Art(non-orig)/crosshair(isorig).png" type="Texture" id=2]
-
[sub_resource type="RectangleShape2D" id=1]
[node name="Weight" type="RigidBody2D"]
diff --git a/Racing-Game/4WheelCar/Wheels/BackWheel.gd b/Racing-Game/4WheelCar/Wheels/BackWheel.gd
index 88df113..f9b67aa 100644
--- a/Racing-Game/4WheelCar/Wheels/BackWheel.gd
+++ b/Racing-Game/4WheelCar/Wheels/BackWheel.gd
@@ -18,19 +18,20 @@ func _process(delta):
velocity = measure_velocity()
#---
set_rotation(carAngle)
+ wheelAngle = get_transform().get_rotation()
isSkid = Input.is_action_pressed("grip")
-
+
if Input.is_action_pressed("grip") || Input.is_action_pressed("brake"):
nullStrength += max(5,velocity/7)
else:
- nullStrength += 1
-
+ nullStrength += 5
+
#Braking
setBrake(0)
null_slide(nullStrength, delta)
-
-
+
+
if Input.is_action_pressed("forward"):
if !Input.is_action_pressed("brake"):
apply_central_impulse(Vector2(0,-gear(velocity, hp, acceleration)).rotated(carAngle)*delta*5000)
diff --git a/Racing-Game/4WheelCar/Wheels/FrontWheel.gd b/Racing-Game/4WheelCar/Wheels/FrontWheel.gd
index 7a05522..cbffbcc 100644
--- a/Racing-Game/4WheelCar/Wheels/FrontWheel.gd
+++ b/Racing-Game/4WheelCar/Wheels/FrontWheel.gd
@@ -26,25 +26,31 @@ func _process(delta):
velAngle = atan2(velVector.y,velVector.x)
isForward = is_forward()
#---
- set_rotation(carAngle)
-
+
isSkid = Input.is_action_pressed("grip")
-
+
#Determines if drifting
if Input.is_action_pressed("grip") || Input.is_action_pressed("brake"):
nullStrength += max(5,velocity/7)
else:
- nullStrength += 1
-
+ nullStrength += 4
+
#Braking
setBrake(0)
- null_slide(nullStrength,delta)
-
+
#Steering
- if Input.is_action_pressed("steer_left"):
- apply_central_impulse(steerDamp*Vector2(0,steer_curve(steerSplitA, steerSplitB, steerHeight, steerLimit,steerMinimum)).rotated(steer_angle())*delta*5000)
- if Input.is_action_pressed("steer_right"):
- apply_central_impulse(steerDamp*Vector2(0,-steer_curve(steerSplitA, steerSplitB, steerHeight, steerLimit,steerMinimum)).rotated(steer_angle())*delta*5000)
+ #if pressing one button, or the other, but not both(xor)
+ if !(Input.is_action_pressed("steer_left") && Input.is_action_pressed("steer_right")) and (Input.is_action_pressed("steer_left") || Input.is_action_pressed("steer_right")):
+ if Input.is_action_pressed("steer_left"):
+ set_rotation(carAngle-deg2rad(45))
+ nullStrength += 0
+ if Input.is_action_pressed("steer_right"):
+ set_rotation(carAngle+deg2rad(45))
+ nullStrength += 0
+ else:
+ set_rotation(carAngle)
+ wheelAngle = get_transform().get_rotation()
+ null_slide(nullStrength,delta)
#returns the angle the car is facing, relative to the direction it is moving
func steer_angle():
diff --git a/Racing-Game/4WheelCar/Wheels/Skid/SkidController.gd b/Racing-Game/4WheelCar/Wheels/Skid/SkidController.gd
index df1e054..48249a4 100644
--- a/Racing-Game/4WheelCar/Wheels/Skid/SkidController.gd
+++ b/Racing-Game/4WheelCar/Wheels/Skid/SkidController.gd
@@ -33,4 +33,4 @@ func _process(_delta):
skidRecent.skidDraw = false
skidSwitch = false
pass
-
+
diff --git a/Racing-Game/4WheelCar/Wheels/Wheel.gd b/Racing-Game/4WheelCar/Wheels/Wheel.gd
index d25cec5..ab00de6 100644
--- a/Racing-Game/4WheelCar/Wheels/Wheel.gd
+++ b/Racing-Game/4WheelCar/Wheels/Wheel.gd
@@ -4,7 +4,8 @@ var velocity #How fast car is moving
var velVector #What direction the car is moving
var velUnitVector #Direction vector, but in a single unit(no magnitude)
var velAngle #The angle of the velocity(relative to world)
-var carAngle #The angle to car is facing(relative to world)
+var carAngle #The angle the car is facing(relative to world)
+var wheelAngle #the angle the wheel is facing(relative to world)
var nullStrength #sums up all sources of null to here
var isSkid = false #this one is used when user presses shift. Initially called in this function
@@ -41,7 +42,7 @@ func null_slide(var strength, var delta):
#strength is how strong you would like the nullify to be
#higher is less sliding/drifting
var movementUnitVector = get_linear_velocity().normalized()#the direction of the velocity
- var directionAngle = carAngle + (PI/2.0)#the angle the car is facing(relative to the world)
+ var directionAngle = wheelAngle + (PI/2.0)#the angle the car is facing(relative to the world)
var directionUnitVector = Vector2(cos(directionAngle),sin(directionAngle)).normalized()#the direction the car is facing
var nullify = directionUnitVector * movementUnitVector.dot(directionUnitVector)
wheelSlip = (-(movementUnitVector - nullify))*strength
diff --git a/Racing-Game/4WheelCar/Wheels/WheelCreation.gd b/Racing-Game/4WheelCar/Wheels/WheelCreation.gd
index 06f354e..c656b7c 100644
--- a/Racing-Game/4WheelCar/Wheels/WheelCreation.gd
+++ b/Racing-Game/4WheelCar/Wheels/WheelCreation.gd
@@ -25,7 +25,7 @@ func createWheel(locX, locY, type):
wheeltemp.set_position(Vector2(locX,locY))
add_child(wheeltemp)
wheeltemp.initVars(locX,locY)
-
+
# add_child(tempA)
elif(type == "back"):
var wheeltemp_resource = load("res://4WheelCar/Wheels/BackWheel.tscn")