From 8740b632a1b39ccf2dfd6215586478e9cac1c26a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Melvin=20Wei=C3=9F?= Date: Wed, 24 Sep 2025 16:37:34 +0200 Subject: [PATCH] Added grass --- buildings/building.gd | 6 ++++-- traps/bear_trap.tscn | 1 + world/earth.gd | 6 ++++++ world/earth.tscn | 4 +++- world/grass.png | Bin 0 -> 3301 bytes world/grass.png.import | 40 ++++++++++++++++++++++++++++++++++++++++ world/grass.tscn | 35 +++++++++++++++++++++++++++++++++++ 7 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 world/grass.png create mode 100644 world/grass.png.import create mode 100644 world/grass.tscn diff --git a/buildings/building.gd b/buildings/building.gd index 25f3686..c5b3809 100644 --- a/buildings/building.gd +++ b/buildings/building.gd @@ -2,6 +2,8 @@ class_name Building extends Node2D @export var location : Vector2i # x is the angle, y is the height in the grid @export var dimension : Vector2i = Vector2(2, 1) # same as above +@export var blocks_area = true + @onready var grid : Grid = get_parent() var objects = [] @@ -14,8 +16,8 @@ func _ready() -> void: var angle = location.x * TAU / grid.num_collumns; # currently assumes anchor is bottom left var height = grid.ground_radius + location.y * grid.cell_height; position = height * Vector2.from_angle(angle) - - grid.buildings.append(self) + if blocks_area: + grid.buildings.append(self) await get_tree().create_timer(0.2).timeout if get_node_or_null("EnemyList") != null: diff --git a/traps/bear_trap.tscn b/traps/bear_trap.tscn index ab249e2..93fe4fb 100644 --- a/traps/bear_trap.tscn +++ b/traps/bear_trap.tscn @@ -42,6 +42,7 @@ shape = SubResource("CircleShape2D_yh007") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] modulate = Color(2.1168277, 2.1168277, 2.1168277, 1) +z_index = 2 position = Vector2(5.9604645e-08, -37.000004) scale = Vector2(0.7, 0.7) sprite_frames = SubResource("SpriteFrames_3n4a6") diff --git a/world/earth.gd b/world/earth.gd index ae7a630..4e6770c 100644 --- a/world/earth.gd +++ b/world/earth.gd @@ -1,7 +1,13 @@ extends Node2D +@export var grass : PackedScene + func _ready() -> void: ItemSpawn.item_pool = ResourceLoader.load("res://items/generic/item_pool.tres","",ResourceLoader.CACHE_MODE_IGNORE) + for column in range($Grid.num_collumns): + var grass_placed : Building = grass.instantiate() + grass_placed.location = Vector2(column, 0) + $Grid.add_child(grass_placed) func get_grid() -> Grid: return $Grid diff --git a/world/earth.tscn b/world/earth.tscn index 774215e..bc2a6b3 100644 --- a/world/earth.tscn +++ b/world/earth.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=14 format=3 uid="uid://jjoyj1ldafkf"] +[gd_scene load_steps=15 format=3 uid="uid://jjoyj1ldafkf"] [ext_resource type="Script" uid="uid://vgxh2xdevat7" path="res://world/earth.gd" id="1_wxnww"] +[ext_resource type="PackedScene" uid="uid://xrbh432lrjge" path="res://world/grass.tscn" id="2_abvrx"] [ext_resource type="Script" uid="uid://m3vyyfk8gnma" path="res://world/grid.gd" id="3_2bhor"] [ext_resource type="Shader" uid="uid://ptqflyxta2qd" path="res://world/earth.gdshader" id="3_640fc"] [ext_resource type="PackedScene" uid="uid://djawvtdwp423v" path="res://buildings/room_temple.tscn" id="3_nihcy"] @@ -22,6 +23,7 @@ shader_parameter/color = Color(0, 0, 0, 1) [node name="Earth" type="Node2D"] script = ExtResource("1_wxnww") +grass = ExtResource("2_abvrx") [node name="Ground" type="StaticBody2D" parent="."] collision_layer = 41 diff --git a/world/grass.png b/world/grass.png new file mode 100644 index 0000000000000000000000000000000000000000..ab5641fa50bb74681d2d1c18bc55885a2e8cee8d GIT binary patch literal 3301 zcmeHJc{JPk7XP7rQKs5yskUnAv}$RKsWH|jRJ9WtTdf@_+QA4yC7N0is*I_1DpOjb zf+DskMva67T{6aqy|facMIzRcN+l#O`rbR|z4zBUXa0GA%st#>=q4>%FhKybNaC z8oj-qU!X|1*#*$7Xg(T;wG+9&6KIKpmxQ~K-k?;w6%oVVh#w`ZO=rx;|r4pE+wsYdkm=h5JtPP4WS8_W`Cm!5 zZ|x@#utOGUa>m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G^7{u9JDK51fr`3Suh7toTPJ0ryzp6czcU)z_Y(d#g{t%O-C6 zc9JP~vWNKcq+3k3j{1S}c!m;@hhdu!s4Z7`45gBlhXJt9D|-RE`$jeY1e+0avr1b8 z_1|d$ux6TS24&??F0?N;Cc|Sunw29vUEdR^c1EWhh1qJh1Iv`i(vuUgstRSeI!P|! zNo^XBiht)Z0;A;2FStYgz|)RQ0>pO?SB&co6&=_u7FBHB%T3AT(mi>8lsL4UhfU4C zKTwOFcTfl5SpKf+WusU~sukR-cI;BTocUx*IyOd+KqP~;I&ISLFZ~A;jfUeszL|fi zSBa7?nG)tYdFL1>nOs z9D8uFVc)3@s}hCOY~&ni64RxnE!aUJxbv7`pVbl%%p9Z1a5CYQq?c=4<7kfPFjBv2 zWMIsQP-*t>Q0O^4!76sH;wyT>`s-x1;dbO*>ec(oxa;~wO|^x@RsJrtWqE%Q_Q|w; z)zV;2h-b$}?N(u*zt?@_a1z|8&CmU6_V^J5JqeU&*47Fsav%A;x`3D=nV*M*u1@$= T5~k9&e~?fI=kw%q0m**{NPOh8 literal 0 HcmV?d00001 diff --git a/world/grass.png.import b/world/grass.png.import new file mode 100644 index 0000000..353db19 --- /dev/null +++ b/world/grass.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bywwrf3d65rsv" +path="res://.godot/imported/grass.png-6a0ba0babdf91a4884e4357e37a3b3bf.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://world/grass.png" +dest_files=["res://.godot/imported/grass.png-6a0ba0babdf91a4884e4357e37a3b3bf.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/world/grass.tscn b/world/grass.tscn new file mode 100644 index 0000000..de0639e --- /dev/null +++ b/world/grass.tscn @@ -0,0 +1,35 @@ +[gd_scene load_steps=7 format=3 uid="uid://xrbh432lrjge"] + +[ext_resource type="Script" uid="uid://b2ji03ekijjnn" path="res://buildings/building.gd" id="1_k0ih8"] +[ext_resource type="Shader" uid="uid://c7gb1nqwvkr37" path="res://buildings/building.gdshader" id="2_hhh8n"] +[ext_resource type="Texture2D" uid="uid://bywwrf3d65rsv" path="res://world/grass.png" id="3_co4wa"] +[ext_resource type="Script" uid="uid://dj7d4d2xs3nci" path="res://buildings/building_mesh.gd" id="4_q1c74"] +[ext_resource type="Texture2D" uid="uid://3weywjfsapax" path="res://buildings/Building 2x1 downside.png" id="5_tnolt"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_pfkkr"] +shader = ExtResource("2_hhh8n") +shader_parameter/ground_height = 3000.0 +shader_parameter/cell_height = 300.0 +shader_parameter/num_cells = 60 + +[node name="GrassBuilding" type="Node2D"] +z_index = 1 +script = ExtResource("1_k0ih8") +blocks_area = false + +[node name="Sprite2D2" type="Sprite2D" parent="."] +z_index = 1 +material = SubResource("ShaderMaterial_pfkkr") +scale = Vector2(25, 25) +texture = ExtResource("3_co4wa") +flip_v = true +script = ExtResource("4_q1c74") + +[node name="EnemyList" type="Node2D" parent="."] + +[node name="DebugSprite" type="Sprite2D" parent="."] +visible = false +position = Vector2(300, -150) +scale = Vector2(1.172, 1.172) +texture = ExtResource("5_tnolt") +flip_v = true