ft: improved npc spawning logic

This commit is contained in:
2026-01-17 13:00:54 +01:00
parent 1a532a5afb
commit e4b3919b81
10 changed files with 75 additions and 33 deletions

View File

@@ -1,10 +1,11 @@
[gd_scene load_steps=6 format=3 uid="uid://b55w56d4twno1"]
[gd_scene load_steps=7 format=3 uid="uid://b55w56d4twno1"]
[ext_resource type="Texture2D" uid="uid://dnlrq8gxiix6" path="res://molecular/assets/bg-far-placeholder.jpg" id="1_cthuy"]
[ext_resource type="Texture2D" uid="uid://bfjf6dxvbq5cj" path="res://dirt-specs.png" id="2_a5cls"]
[ext_resource type="PackedScene" uid="uid://dxluckxdkpv4f" path="res://molecular/molecular_player.tscn" id="3_b1jr0"]
[ext_resource type="Script" uid="uid://ceut2lrvkns75" path="res://debug_label.gd" id="4_mys4o"]
[ext_resource type="Script" uid="uid://2pmjtnrg5471" path="res://molecular/preyManager.gd" id="5_ojt85"]
[ext_resource type="Script" uid="uid://umx4w11edif" path="res://molecular/prey_manager.gd" id="5_cthuy"]
[ext_resource type="PackedScene" uid="uid://c3iw2v3x6ngrb" path="res://molecular/nucleotide_prey.tscn" id="6_a5cls"]
[node name="MolecularStage" type="Node2D"]
@@ -57,5 +58,10 @@ text = "Debug: You made it into the game!
This is running from C++: "
script = ExtResource("4_mys4o")
[node name="Prey" type="Node" parent="."]
script = ExtResource("5_ojt85")
[node name="PreyManager" type="Node" parent="." node_paths=PackedStringArray("cam")]
script = ExtResource("5_cthuy")
cam = NodePath("../player/Camera2D")
scene = ExtResource("6_a5cls")
minCount = 500
maxCount = 1000
metadata/_custom_type_script = "uid://coetidfssb80w"

View File

@@ -6,7 +6,6 @@ extends AbstractPrey2D
func _ready() -> void:
$AnimatedSprite2D.animation = "Healthy"
$AnimatedSprite2D.play()
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.

View File

@@ -1,27 +0,0 @@
extends Node
var preyScene = preload("res://molecular/nucleotide_prey.tscn")
#var predatorScene = preload("res://Predator.tscn")
var score
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
for i in range(0, 100, 10):
spawn_creature(preyScene, Vector2(i, i))
spawn_random()
spawn_random()
spawn_random()
spawn_random()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func spawn_random() -> void:
spawn_creature(preyScene, Vector2(randfn(100, 100), randfn(100, 100)))
func spawn_creature(scene, position: Vector2) -> void:
var instance = scene.instantiate()
instance.position = position
add_child(instance)

View File

@@ -1 +0,0 @@
uid://2pmjtnrg5471

View File

@@ -0,0 +1,13 @@
extends SpawnManager2D
@export var cam: Camera2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
spawnRange = cam.get_viewport_rect()
_spawn_minimum()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass

View File

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