Object scattering
This commit is contained in:
@ -1,26 +1,26 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://deus4t8mmx6pp"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://deus4t8mmx6pp"]
|
||||
|
||||
[ext_resource type="Script" path="res://script/world.gd" id="1_fj2dk"]
|
||||
[ext_resource type="PackedScene" uid="uid://4dsm0l7s6vki" path="res://data/character/character.tscn" id="1_gadv2"]
|
||||
[ext_resource type="Texture2D" uid="uid://vyhureoc5qlp" path="res://textures/world/biome/forest/grass.svg" id="2_xtc31"]
|
||||
[ext_resource type="PackedScene" uid="uid://ikvaekbnft70" path="res://data/objects/stone.tscn" id="3_l3ue5"]
|
||||
[ext_resource type="PackedScene" uid="uid://c7ir6imnqx4py" path="res://data/objects/tree.tscn" id="4_qpvcg"]
|
||||
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_0fcbb"]
|
||||
normal = Vector2(0, 1)
|
||||
distance = -2000.0
|
||||
distance = -3000.0
|
||||
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_cl8ds"]
|
||||
normal = Vector2(-1, 0)
|
||||
distance = -2000.0
|
||||
distance = -3000.0
|
||||
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_5jryn"]
|
||||
distance = -2000.0
|
||||
distance = -3000.0
|
||||
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_j3vu4"]
|
||||
normal = Vector2(1, 0)
|
||||
distance = -2000.0
|
||||
distance = -3000.0
|
||||
|
||||
[node name="world" type="Node2D"]
|
||||
script = ExtResource("1_fj2dk")
|
||||
|
||||
[node name="character" parent="." instance=ExtResource("1_gadv2")]
|
||||
|
||||
@ -31,16 +31,10 @@ z_index = -10
|
||||
texture_repeat = 2
|
||||
texture = ExtResource("2_xtc31")
|
||||
region_enabled = true
|
||||
region_rect = Rect2(0, 0, 4000, 4000)
|
||||
region_rect = Rect2(0, 0, 8000, 8000)
|
||||
|
||||
[node name="objects" type="Node2D" parent="."]
|
||||
|
||||
[node name="stone" parent="objects" instance=ExtResource("3_l3ue5")]
|
||||
position = Vector2(-128, -64)
|
||||
|
||||
[node name="tree" parent="objects" instance=ExtResource("4_qpvcg")]
|
||||
position = Vector2(168, -152)
|
||||
|
||||
[node name="world_boundaries" type="StaticBody2D" parent="."]
|
||||
|
||||
[node name="north" type="CollisionShape2D" parent="world_boundaries"]
|
||||
|
20
script/world.gd
Normal file
20
script/world.gd
Normal file
@ -0,0 +1,20 @@
|
||||
@tool
|
||||
extends Node2D
|
||||
|
||||
|
||||
var objects = [
|
||||
"res://data/objects/stone.tscn",
|
||||
"res://data/objects/tree.tscn"
|
||||
]
|
||||
var object_ammount = 20 #the ammount of each type of object
|
||||
var this_seed = 1234
|
||||
|
||||
|
||||
func _ready():
|
||||
seed(this_seed)
|
||||
for object in objects:
|
||||
for iter in range(object_ammount):
|
||||
var this_object = load(object).instantiate()
|
||||
this_object.position.x = randf_range(-4000, 4000)
|
||||
this_object.position.y = randf_range(-4000, 4000)
|
||||
$objects.add_child(this_object)
|
Reference in New Issue
Block a user