feat: Randomize position and spawn of pickups
This commit is contained in:
parent
4b5bd16cef
commit
66077734b7
25
level.gd
25
level.gd
|
|
@ -8,6 +8,8 @@ var dimension: int = BASE_DIMENSION
|
||||||
@export var ped_spawn_rate: int = 20
|
@export var ped_spawn_rate: int = 20
|
||||||
# Spawn Rate = rate - floor(stage_count * stage_mod)
|
# Spawn Rate = rate - floor(stage_count * stage_mod)
|
||||||
@export var ped_spawn_rate_stage_modifier: float = 0.5
|
@export var ped_spawn_rate_stage_modifier: float = 0.5
|
||||||
|
@export var speed_boost_spawn_rate = 1
|
||||||
|
@export var bonus_time_spawn_rate = 1
|
||||||
|
|
||||||
var pedestrian_scn = preload("res://pedestrian.tscn")
|
var pedestrian_scn = preload("res://pedestrian.tscn")
|
||||||
var chunk_scn = preload("res://chunk.tscn")
|
var chunk_scn = preload("res://chunk.tscn")
|
||||||
|
|
@ -51,16 +53,6 @@ func initialize_world() -> void:
|
||||||
$Player.position.x = spawn.x * Global.chunk_size
|
$Player.position.x = spawn.x * Global.chunk_size
|
||||||
$Player.position.z = spawn.y * Global.chunk_size
|
$Player.position.z = spawn.y * Global.chunk_size
|
||||||
|
|
||||||
var bt = bonus_time_scn.instantiate()
|
|
||||||
bt.position.x = spawn.x * Global.chunk_size - 10
|
|
||||||
bt.position.z = spawn.y * Global.chunk_size + 20
|
|
||||||
add_child(bt)
|
|
||||||
|
|
||||||
var sb = speed_boost_scn.instantiate()
|
|
||||||
sb.position.x = spawn.x * Global.chunk_size + 10
|
|
||||||
sb.position.z = spawn.y * Global.chunk_size + 20
|
|
||||||
add_child(sb)
|
|
||||||
|
|
||||||
# ---- Generate the paths ----
|
# ---- Generate the paths ----
|
||||||
var paths: Array = []
|
var paths: Array = []
|
||||||
for path_idx in range(path_count):
|
for path_idx in range(path_count):
|
||||||
|
|
@ -97,9 +89,22 @@ func initialize_world() -> void:
|
||||||
new_chunk = spawn_scn.instantiate()
|
new_chunk = spawn_scn.instantiate()
|
||||||
else:
|
else:
|
||||||
new_chunk = chunk_scn.instantiate()
|
new_chunk = chunk_scn.instantiate()
|
||||||
|
|
||||||
new_chunk.position = Vector3(x * Global.chunk_size+1, 0, y * Global.chunk_size+1)
|
new_chunk.position = Vector3(x * Global.chunk_size+1, 0, y * Global.chunk_size+1)
|
||||||
row.append(new_chunk)
|
row.append(new_chunk)
|
||||||
$ChunkContainer.add_child(new_chunk)
|
$ChunkContainer.add_child(new_chunk)
|
||||||
|
|
||||||
|
if randi() % bonus_time_spawn_rate == 0:
|
||||||
|
var bonus_time = bonus_time_scn.instantiate()
|
||||||
|
bonus_time.position.x = new_chunk.position.x + randf_range(-Global.chunk_size/2, Global.chunk_size/2)
|
||||||
|
bonus_time.position.z = new_chunk.position.z + randf_range(-Global.chunk_size/2, Global.chunk_size/2)
|
||||||
|
$ChunkContainer.add_child(bonus_time)
|
||||||
|
if randi() % speed_boost_spawn_rate == 0:
|
||||||
|
var speed_boost = speed_boost_scn.instantiate()
|
||||||
|
speed_boost.position.x = new_chunk.position.x + randf_range(-Global.chunk_size/2, Global.chunk_size/2)
|
||||||
|
speed_boost.position.z = new_chunk.position.z + randf_range(-Global.chunk_size/2, Global.chunk_size/2)
|
||||||
|
$ChunkContainer.add_child(speed_boost)
|
||||||
|
|
||||||
chunks.append(row)
|
chunks.append(row)
|
||||||
|
|
||||||
# ---- Set exits based on paths ----
|
# ---- Set exits based on paths ----
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ radius = 2.3896484
|
||||||
script = SubResource("GDScript_rqnpm")
|
script = SubResource("GDScript_rqnpm")
|
||||||
|
|
||||||
[node name="Cartell" type="MeshInstance3D" parent="." unique_id=1340947697]
|
[node name="Cartell" type="MeshInstance3D" parent="." unique_id=1340947697]
|
||||||
transform = Transform3D(2.0101042, 0, 0, 0, 2.0101042, 0, 0, 0, 2.0101042, 0, 0.28158534, 0)
|
transform = Transform3D(2.0101042, 0, 0, 0, 2.0101042, 0, 0, 0, 2.0101042, 0, 1, 0)
|
||||||
mesh = SubResource("PlaneMesh_b5fwd")
|
mesh = SubResource("PlaneMesh_b5fwd")
|
||||||
surface_material_override/0 = SubResource("StandardMaterial3D_cumbd")
|
surface_material_override/0 = SubResource("StandardMaterial3D_cumbd")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ radius = 2.3896484
|
||||||
script = SubResource("GDScript_rqnpm")
|
script = SubResource("GDScript_rqnpm")
|
||||||
|
|
||||||
[node name="Cartell" type="MeshInstance3D" parent="." unique_id=1340947697]
|
[node name="Cartell" type="MeshInstance3D" parent="." unique_id=1340947697]
|
||||||
transform = Transform3D(2.0101042, 0, 0, 0, 2.0101042, 0, 0, 0, 2.0101042, 0, 0.28158534, 0)
|
transform = Transform3D(2.0101042, 0, 0, 0, 2.0101042, 0, 0, 0, 2.0101042, 0, 1, 0)
|
||||||
mesh = SubResource("PlaneMesh_b5fwd")
|
mesh = SubResource("PlaneMesh_b5fwd")
|
||||||
surface_material_override/0 = SubResource("StandardMaterial3D_cumbd")
|
surface_material_override/0 = SubResource("StandardMaterial3D_cumbd")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue