WIP: merge recipies
This commit is contained in:
+12
-3
@@ -3,6 +3,7 @@ extends Node3D
|
||||
const PLAYER_SCENE := preload("res://scenes/Player.tscn")
|
||||
const ENEMY_SCENE := preload("res://scenes/Enemy.tscn")
|
||||
const ROCK_SCENE := preload("res://scenes/Rock.tscn")
|
||||
const STICK_SCENE := preload("res://scenes/Stick.tscn")
|
||||
const LEVEL_SCENE := preload("res://scenes/Level.tscn")
|
||||
|
||||
const CAM_DIST := 8.0
|
||||
@@ -43,6 +44,7 @@ func _ready() -> void:
|
||||
_create_ui()
|
||||
_spawn_player()
|
||||
_spawn_rocks()
|
||||
_spawn_sticks()
|
||||
_start_game()
|
||||
add_to_group("main")
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
@@ -104,14 +106,20 @@ func _spawn_rocks() -> void:
|
||||
for i in range(limit):
|
||||
_spawn_single_rock()
|
||||
|
||||
func _spawn_sticks() -> void:
|
||||
for i in range(2):
|
||||
var stick := STICK_SCENE.instantiate()
|
||||
stick.position = _safe_item_position()
|
||||
add_child(stick)
|
||||
|
||||
func _spawn_single_rock() -> void:
|
||||
var rock := ROCK_SCENE.instantiate()
|
||||
rock.position = _safe_rock_position()
|
||||
rock.position = _safe_item_position()
|
||||
add_child(rock)
|
||||
rock.connect("destroyed", _on_rock_destroyed)
|
||||
rocks_on_field += 1
|
||||
|
||||
func _safe_rock_position() -> Vector3:
|
||||
func _safe_item_position() -> Vector3:
|
||||
var player_pos := player.global_position if is_instance_valid(player) else Vector3.ZERO
|
||||
for _attempt in range(30):
|
||||
var angle := randf() * TAU
|
||||
@@ -120,7 +128,7 @@ func _safe_rock_position() -> Vector3:
|
||||
if player_pos.distance_to(pos) < 4.5:
|
||||
continue
|
||||
var clear := true
|
||||
for r in get_tree().get_nodes_in_group("rocks"):
|
||||
for r in get_tree().get_nodes_in_group("kickable"):
|
||||
if (r as Node3D).global_position.distance_to(pos) < 1.5:
|
||||
clear = false
|
||||
break
|
||||
@@ -162,6 +170,7 @@ func _start_game() -> void:
|
||||
score = 0
|
||||
kills = 0
|
||||
kills_for_next = 10
|
||||
Enemy.first_leather_spawned = false
|
||||
_update_labels()
|
||||
spawn_timer.wait_time = 1.4
|
||||
spawn_timer.connect("timeout", _on_spawn_timer)
|
||||
|
||||
Reference in New Issue
Block a user