Compare commits

..

10 commits

28 changed files with 330 additions and 176 deletions

BIN
aseprite/palm-tree.aseprite Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -0,0 +1,38 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bv6xyavrko8pt"
path.s3tc="res://.godot/imported/road_clover+grass-64x64.png-3ecbc3bba0bf60c10dbe09ff1fbc26da.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={
"md5": "2a29c758d2d9723c895c01e5921737a9"
}
[deps]
source_file="res://blender/road_clover+grass-64x64.png"
dest_files=["res://.godot/imported/road_clover+grass-64x64.png-3ecbc3bba0bf60c10dbe09ff1fbc26da.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,53 +0,0 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://c84tiggbw7fby"
path="res://.godot/imported/tire.blend-257acba8f91987b9d3ccadd03f9c2628.scn"
[deps]
source_file="res://blender/tire.blend"
dest_files=["res://.godot/imported/tire.blend-257acba8f91987b9d3ccadd03f9c2628.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={}
blender/nodes/visible=0
blender/nodes/active_collection_only=false
blender/nodes/punctual_lights=true
blender/nodes/cameras=true
blender/nodes/custom_properties=true
blender/nodes/modifiers=1
blender/meshes/colors=false
blender/meshes/uvs=true
blender/meshes/normals=true
blender/meshes/export_geometry_nodes_instances=false
blender/meshes/tangents=true
blender/meshes/skins=2
blender/meshes/export_bones_deforming_mesh_only=false
blender/materials/unpack_enabled=true
blender/materials/export_materials=1
blender/animation/limit_playback=true
blender/animation/always_sample=true
blender/animation/group_tracks=true

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -0,0 +1,38 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b2auwk46k0y28"
path.s3tc="res://.godot/imported/road_clover+grass-64x64.png-d92a937111c1a927974aecf4c3161435.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={
"md5": "2a29c758d2d9723c895c01e5921737a9"
}
[deps]
source_file="res://objects/road_clover+grass-64x64.png"
dest_files=["res://.godot/imported/road_clover+grass-64x64.png-d92a937111c1a927974aecf4c3161435.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

Binary file not shown.

View file

@ -1,37 +0,0 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://ciad77soibtc6"
path="res://.godot/imported/tire.glb-8859bd6645e15498c4765ffa15527f9c.scn"
[deps]
source_file="res://objects/tire.glb"
dest_files=["res://.godot/imported/tire.glb-8859bd6645e15498c4765ffa15527f9c.scn"]
[params]
nodes/root_type="Node3D"
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1

View file

@ -1,9 +1,10 @@
[gd_scene load_steps=9 format=3 uid="uid://d4ljkc7l57udr"]
[gd_scene load_steps=10 format=3 uid="uid://d4ljkc7l57udr"]
[ext_resource type="PackedScene" uid="uid://dtncvl5af4fhr" path="res://objects/road.glb" id="1_uwrxv"]
[ext_resource type="Script" uid="uid://63j50wn1myoi" path="res://scripts/vehicle.gd" id="2_lnu2h"]
[ext_resource type="Script" uid="uid://hufd4xlq7b6k" path="res://scripts/road_manager.gd" id="1_lbhrr"]
[ext_resource type="PackedScene" uid="uid://mu3b314l3soy" path="res://scenes/road.tscn" id="1_lnu2h"]
[ext_resource type="Script" uid="uid://cs0y5pe8qnj2r" path="res://scripts/player.gd" id="2_lnu2h"]
[ext_resource type="PackedScene" uid="uid://cewenjpq8wbig" path="res://objects/testcar.glb" id="2_yqjtg"]
[ext_resource type="PackedScene" uid="uid://btpfvhpv0630f" path="res://scenes/wheel.tscn" id="4_lbhrr"]
[ext_resource type="Texture2D" uid="uid://4kfwwijnbqlw" path="res://sprites/interior_overlays/truck-interior.png" id="5_iywne"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_lnu2h"]
sky_top_color = Color(0, 0.388235, 1, 1)
@ -19,71 +20,59 @@ sky = SubResource("Sky_lbhrr")
tonemap_mode = 2
glow_enabled = true
[sub_resource type="BoxShape3D" id="BoxShape3D_lbhrr"]
size = Vector3(3.6333, 0.937874, 1.93555)
[sub_resource type="BoxShape3D" id="BoxShape3D_yqjtg"]
size = Vector3(3.60051, 2.21851, 1.87103)
[node name="Game" type="Node3D"]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
[node name="SubViewportContainer" type="SubViewportContainer" parent="."]
texture_filter = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
stretch = true
stretch_shrink = 4
[node name="SubViewport" type="SubViewport" parent="SubViewportContainer"]
handle_input_locally = false
size = Vector2i(320, 240)
render_target_update_mode = 4
[node name="WorldEnvironment" type="WorldEnvironment" parent="SubViewportContainer/SubViewport"]
environment = SubResource("Environment_iywne")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.866023, -0.433016, 0.250001, 0, 0.499998, 0.866027, -0.500003, 0.749999, -0.43301, 0, 0, 0)
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="SubViewportContainer/SubViewport"]
transform = Transform3D(-0.866024, -0.433016, 0.250001, 0, 0.499998, 0.866026, -0.500003, 0.749999, -0.43301, 0, 0, 0)
shadow_enabled = true
[node name="RoadBlocks" type="Node3D" parent="."]
[node name="Road" parent="RoadBlocks" instance=ExtResource("1_uwrxv")]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, -10.549, 9.53674e-07, 0.0019331)
[node name="Road2" parent="RoadBlocks" instance=ExtResource("1_uwrxv")]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, 9.5, 0, 0)
[node name="Road3" parent="RoadBlocks" instance=ExtResource("1_uwrxv")]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, -50.613, 9.53674e-07, 0.0019331)
[node name="Road4" parent="RoadBlocks" instance=ExtResource("1_uwrxv")]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, -30.564, 0, 0)
[node name="Road5" parent="RoadBlocks" instance=ExtResource("1_uwrxv")]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, -89.5907, 9.53674e-07, 0.0019331)
[node name="Road6" parent="RoadBlocks" instance=ExtResource("1_uwrxv")]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, -69.5417, 0, 0)
[node name="Road7" parent="RoadBlocks" instance=ExtResource("1_uwrxv")]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, -129.655, 9.53674e-07, 0.0019331)
[node name="Road8" parent="RoadBlocks" instance=ExtResource("1_uwrxv")]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, -109.606, 0, 0)
[node name="PlayerVehicle" type="VehicleBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.519431)
[node name="Player" type="CharacterBody3D" parent="SubViewportContainer/SubViewport"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, -0.510139, 0, -0.578158)
script = ExtResource("2_lnu2h")
[node name="TestCar" parent="PlayerVehicle" instance=ExtResource("2_yqjtg")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.464)
[node name="TestCar" parent="SubViewportContainer/SubViewport/Player" instance=ExtResource("2_yqjtg")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.53674e-07, -0.463639)
visible = false
[node name="RearLeftWheel" parent="PlayerVehicle" instance=ExtResource("4_lbhrr")]
transform = Transform3D(-2.62268e-08, 0, -0.6, 0, 0.6, 0, 0.6, 0, -2.62268e-08, 0.943448, 0.301217, 0.324063)
use_as_traction = true
[node name="CollisionShape3D" type="CollisionShape3D" parent="SubViewportContainer/SubViewport/Player"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.279745, 1.10964, -0.462006)
shape = SubResource("BoxShape3D_yqjtg")
[node name="FrontLeftWheel" parent="PlayerVehicle" instance=ExtResource("4_lbhrr")]
transform = Transform3D(-2.62268e-08, 0, -0.6, 0, 0.6, 0, 0.6, 0, -2.62268e-08, -1.49207, 0.301217, 0.324063)
use_as_steering = true
[node name="Head" type="Node3D" parent="SubViewportContainer/SubViewport/Player"]
transform = Transform3D(0.965536, 0.260269, 0, -0.260269, 0.965536, 0, 0, 0, 1, 0, 1.54334, -0.215674)
[node name="RearRightWheel" parent="PlayerVehicle" instance=ExtResource("4_lbhrr")]
transform = Transform3D(-2.62268e-08, 0, -0.6, 0, 0.6, 0, 0.6, 0, -2.62268e-08, 0.943448, 0.301217, -1.24299)
use_as_traction = true
[node name="Camera3D" type="Camera3D" parent="SubViewportContainer/SubViewport/Player/Head"]
transform = Transform3D(-2.19056e-08, -0.570069, 0.821597, -5.39943e-08, 0.821597, 0.570069, -1, -3.18738e-08, -4.8778e-08, -0.181639, 0.104743, 0.247312)
[node name="FrontRightWheel" parent="PlayerVehicle" instance=ExtResource("4_lbhrr")]
transform = Transform3D(-2.62268e-08, 0, -0.6, 0, 0.6, 0, 0.6, 0, -2.62268e-08, -1.49207, 0.301217, -1.24299)
use_as_steering = true
[node name="RoadManager" type="Node3D" parent="SubViewportContainer/SubViewport" node_paths=PackedStringArray("player")]
script = ExtResource("1_lbhrr")
player = NodePath("../Player")
[node name="Camera3D" type="Camera3D" parent="PlayerVehicle"]
transform = Transform3D(-3.92527e-08, -0.440002, 0.897997, -1.92331e-08, 0.897997, 0.440002, -1, 8.73235e-16, -4.37114e-08, 3.93353, 3.74796, -0.402741)
fov = 71.0
[node name="Road" parent="SubViewportContainer/SubViewport/RoadManager" instance=ExtResource("1_lnu2h")]
[node name="CollisionShape3D" type="CollisionShape3D" parent="PlayerVehicle"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.283447, 0.713863, -0.467773)
shape = SubResource("BoxShape3D_lbhrr")
[node name="CanvasLayer" type="CanvasLayer" parent="SubViewportContainer/SubViewport"]
[node name="Sprite2D" type="Sprite2D" parent="SubViewportContainer/SubViewport/CanvasLayer"]
position = Vector2(160, 120)
texture = ExtResource("5_iywne")

56
scenes/road.tscn Normal file
View file

@ -0,0 +1,56 @@
[gd_scene load_steps=3 format=3 uid="uid://mu3b314l3soy"]
[ext_resource type="PackedScene" uid="uid://dtncvl5af4fhr" path="res://objects/road.glb" id="1_mv8x7"]
[ext_resource type="Texture2D" uid="uid://d5joix6cbuik" path="res://sprites/palm-tree.png" id="2_my2y2"]
[node name="Road" type="Node3D"]
[node name="RoadObject" parent="." instance=ExtResource("1_mv8x7")]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0)
[node name="Trees" type="Node3D" parent="."]
[node name="PalmTree" type="Sprite3D" parent="Trees"]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 2.93877, 2.34261, -9.49557)
flip_h = true
billboard = 1
texture = ExtResource("2_my2y2")
[node name="PalmTree5" type="Sprite3D" parent="Trees"]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, -2.83949, 2.34261, -14.0975)
billboard = 1
texture = ExtResource("2_my2y2")
[node name="PalmTree6" type="Sprite3D" parent="Trees"]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 1.1861, 2.34261, -20.8587)
flip_h = true
billboard = 1
texture = ExtResource("2_my2y2")
[node name="PalmTree7" type="Sprite3D" parent="Trees"]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 5.2136, 2.34261, -16.6129)
billboard = 1
texture = ExtResource("2_my2y2")
[node name="PalmTree2" type="Sprite3D" parent="Trees"]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 2.34261, 9.30729)
flip_h = true
billboard = 1
texture = ExtResource("2_my2y2")
[node name="PalmTree8" type="Sprite3D" parent="Trees"]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 5.74419, 2.34261, 13.1949)
billboard = 1
texture = ExtResource("2_my2y2")
[node name="PalmTree3" type="Sprite3D" parent="Trees"]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, -3.32652, 2.34261, 13.0005)
flip_h = true
billboard = 1
texture = ExtResource("2_my2y2")
[node name="PalmTree4" type="Sprite3D" parent="Trees"]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 2.34261, 17.0532)
flip_h = true
billboard = 1
texture = ExtResource("2_my2y2")

View file

@ -1,8 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://btpfvhpv0630f"]
[ext_resource type="PackedScene" uid="uid://ciad77soibtc6" path="res://objects/tire.glb" id="1_hm1pg"]
[node name="Wheel" type="VehicleWheel3D"]
[node name="TireMesh" parent="." instance=ExtResource("1_hm1pg")]
transform = Transform3D(-7.21238e-08, 0, -1.65, 0, 1.65, 0, 1.65, 0, -7.21238e-08, 0, -0.0759154, 0)

View file

@ -1,8 +1,8 @@
extends CharacterBody3D
@export var acceleration: float = 10.0
@export var brake_intensity: float = 5.0
@export var rotation_speed: float = 1.5
@export var acceleration: float = 5.0
@export var brake_intensity: float = 3.0
@export var strafe_speed: float = 10.0 # Speed for sideways movement
@export var gravity: float = 9.8
@export var max_speed: float = 30.0
@ -15,11 +15,7 @@ func _physics_process(delta: float) -> void:
# Get input direction
var input_forward = Input.get_action_strength("move_forward") - Input.get_action_strength("move_backward")
var input_rotation = Input.get_action_strength("turn_right") - Input.get_action_strength("turn_left")
# Handle rotation
if input_rotation != 0:
rotate_y(-input_rotation * rotation_speed * delta)
var input_strafe = Input.get_action_strength("turn_left") - Input.get_action_strength("turn_right")
# Handle acceleration and braking
if input_forward > 0:
@ -32,9 +28,29 @@ func _physics_process(delta: float) -> void:
# No input, gradually slow down
current_speed = move_toward(current_speed, 0, brake_intensity * delta)
# Apply movement in the direction the vehicle is facing
var direction = -global_transform.basis.z
velocity.z = direction.x * current_speed
velocity.x = direction.z * current_speed
# Get the forward and right vectors
var forward_direction = -global_transform.basis.z
var side_direction = global_transform.basis.x
# Calculate forward movement
var forward_movement = Vector3(
forward_direction.x * current_speed,
0,
forward_direction.z * current_speed
)
# Calculate strafe movement (sideways)
var strafe_movement = Vector3(
side_direction.x * input_strafe * strafe_speed,
0,
side_direction.z * input_strafe * strafe_speed
)
# Combine movements
var total_movement = forward_movement + strafe_movement
# Apply to velocity
velocity.z = total_movement.x
velocity.x = total_movement.z
move_and_slide()

54
scripts/road_manager.gd Normal file
View file

@ -0,0 +1,54 @@
extends Node3D
@export var player: CharacterBody3D
@export var spawn_distance: float = 100.0
@export var despawn_distance: float = 200.0
var road_scene = preload("res://scenes/road.tscn")
var roads = []
var road_length: float
func _ready():
# Calculate road length from existing instance
var temp_road = road_scene.instantiate()
# Get the MeshInstance3D from the road scene structure
var mesh_instance = temp_road.get_node("RoadObject") as MeshInstance3D
if mesh_instance:
var aabb = mesh_instance.mesh.get_aabb()
road_length = aabb.size.x * mesh_instance.scale.x
else:
push_error("Could not find RoadObject MeshInstance3D in road scene")
road_length = 20.0 # Fallback value
temp_road.queue_free()
# Initialize with existing road
var initial_road = $Road
roads.append(initial_road)
func _process(delta):
if not player:
return
var player_x = player.global_position.x
# Spawn new roads ahead
var last_road = roads[-1]
var last_road_end = last_road.global_position.x + road_length
if player_x + spawn_distance > last_road_end:
spawn_road(last_road_end)
# Despawn old roads behind
for road in roads.duplicate():
var road_end = road.global_position.x + road_length
if player_x - road_end > despawn_distance:
despawn_road(road)
func spawn_road(position_x: float):
var new_road = road_scene.instantiate()
new_road.global_position = Vector3(position_x, 0, 0)
add_child(new_road)
roads.append(new_road)
func despawn_road(road: Node3D):
road.queue_free()
roads.erase(road)

View file

@ -0,0 +1 @@
uid://hufd4xlq7b6k

View file

@ -1,8 +0,0 @@
extends VehicleBody3D
@export var MAX_STEER = 0.5
@export var ENGINE_POWER = 300
func _physics_process(delta):
steering = move_toward(steering, Input.get_axis("turn_right", "turn_left") * MAX_STEER, delta * 10)
engine_force = Input.get_axis("move_backward", "move_forward") * ENGINE_POWER

View file

@ -1 +0,0 @@
uid://63j50wn1myoi

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://4kfwwijnbqlw"
path="res://.godot/imported/truck-interior.png-b04ac59f5a4db67414c278f28b096834.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/interior_overlays/truck-interior.png"
dest_files=["res://.godot/imported/truck-interior.png-b04ac59f5a4db67414c278f28b096834.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
sprites/palm-tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d5joix6cbuik"
path.s3tc="res://.godot/imported/palm-tree.png-164b1dab9fd83351c0d9e916940eff92.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://sprites/palm-tree.png"
dest_files=["res://.godot/imported/palm-tree.png-164b1dab9fd83351c0d9e916940eff92.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0