Added grass

This commit is contained in:
Melvin Weiß 2025-09-24 16:37:34 +02:00
parent f98c89ef94
commit 8740b632a1
7 changed files with 89 additions and 3 deletions

View file

@ -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:

View file

@ -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")

View file

@ -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

View file

@ -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

BIN
world/grass.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

40
world/grass.png.import Normal file
View file

@ -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

35
world/grass.tscn Normal file
View file

@ -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