From 8a575b79e9cce675a8872876a4f08e4a1f7ee91b Mon Sep 17 00:00:00 2001 From: Zakarya Date: Sat, 4 Nov 2023 19:21:49 -0700 Subject: [PATCH] Add the desert biome --- scenes/world.tscn | 14 ++++++++++---- scripts/world.gd | 30 ++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/scenes/world.tscn b/scenes/world.tscn index 40a7033..60e87cd 100644 --- a/scenes/world.tscn +++ b/scenes/world.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=8 format=3 uid="uid://deus4t8mmx6pp"] +[gd_scene load_steps=9 format=3 uid="uid://deus4t8mmx6pp"] [ext_resource type="Script" path="res://scripts/world.gd" id="1_d5cpg"] [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="Texture2D" uid="uid://bs880ox7qmqui" path="res://textures/world/biome/desert/sand.svg" id="4_gronf"] [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_0fcbb"] normal = Vector2(0, 1) @@ -13,7 +14,7 @@ normal = Vector2(-1, 0) distance = -3000.0 [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_5jryn"] -distance = -3000.0 +distance = -11000.0 [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_j3vu4"] normal = Vector2(1, 0) @@ -27,13 +28,18 @@ script = ExtResource("1_d5cpg") [node name="biomes" type="Node2D" parent="."] z_index = -10 -[node name="grass" type="Sprite2D" parent="biomes"] +[node name="forest" type="Sprite2D" parent="biomes"] texture_repeat = 2 texture = ExtResource("2_xtc31") region_enabled = true region_rect = Rect2(0, 0, 8000, 8000) -[node name="objects" type="Node2D" parent="."] +[node name="desert" type="Sprite2D" parent="biomes"] +texture_repeat = 2 +position = Vector2(0, 8000) +texture = ExtResource("4_gronf") +region_enabled = true +region_rect = Rect2(0, 0, 8000, 8000) [node name="world_boundaries" type="StaticBody2D" parent="."] diff --git a/scripts/world.gd b/scripts/world.gd index df27da0..1901925 100644 --- a/scripts/world.gd +++ b/scripts/world.gd @@ -2,20 +2,38 @@ extends Node2D -var objects = [ - "res://data/objects/stone.tscn", - "res://data/objects/tree.tscn" -] +var objects = { + "forest": [ + "res://data/objects/stone.tscn", + "res://data/objects/tree.tscn" + ], + "desert": [ + "res://data/objects/stone.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: + + #generate objects in forest + for object in objects.forest: for iter in range(object_ammount): var this_object = load(object).instantiate() + $biomes/forest.add_child(this_object) this_object.position.x = randf_range(-4000, 4000) this_object.position.y = randf_range(-4000, 4000) this_object.rotation_degrees = randf_range(0, 360) - $objects.add_child(this_object) + this_object.z_index = 10 + + #generate objects in desert + for object in objects.desert: + for iter in range(object_ammount): + var this_object = load(object).instantiate() + $biomes/desert.add_child(this_object) + this_object.position.x = randf_range(-4000, 4000) + this_object.position.y = randf_range(-4000, 4000) + this_object.rotation_degrees = randf_range(0, 360) + this_object.z_index = 10