Heck yeah, you punch those trees, Gary!

This commit is contained in:
2025-10-31 21:10:55 +11:00
commit ee8deac651
27 changed files with 382 additions and 0 deletions

4
.editorconfig Normal file
View File

@@ -0,0 +1,4 @@
root = true
[*]
charset = utf-8

2
.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
# Godot 4+ specific ignores
.godot/
/android/

36
character/character.gd Normal file
View File

@@ -0,0 +1,36 @@
extends CharacterBody2D
var _grid_pos: Vector2i = Vector2i.ZERO
var _grid_tween: Tween = null
var _cached_dir: Vector2i = Vector2i.ZERO #used for reversing the current input
func _physics_process(delta: float) -> void:
#WARNING: this has the potential for getting stuck
if _grid_pos * 32 == Vector2i(position):
_check_grid_move(delta)
func _check_grid_move(delta: float) -> void:
if Input.is_action_pressed("input_north"):
_set_grid_move(Vector2i.UP)
elif Input.is_action_pressed("input_south"):
_set_grid_move(Vector2i.DOWN)
elif Input.is_action_pressed("input_west"):
_set_grid_move(Vector2i.LEFT)
elif Input.is_action_pressed("input_east"):
_set_grid_move(Vector2i.RIGHT)
func _set_grid_move(grid_dir: Vector2i):
_cached_dir = grid_dir
_grid_pos += grid_dir
_grid_tween = create_tween()
_grid_tween.set_ease(Tween.EASE_OUT_IN)
_grid_tween.set_trans(Tween.TRANS_QUAD)
_grid_tween.tween_property(self, "position", Vector2(_grid_pos * 32), 0.3)
func repel_collision(_other: Node2D) -> void:
#NOTE: character's collider has a 1 pixel margin
if _cached_dir != Vector2i.ZERO:
_grid_tween.kill()
_set_grid_move(-_cached_dir) #go backwards
_cached_dir = Vector2i.ZERO #only do this once each collision

View File

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

BIN
character/gary_pixels.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bhcajd6qgtt62"
path="res://.godot/imported/gary_pixels.png-3b277e035a73ecaf93d5fc604cea6ce4.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://character/gary_pixels.png"
dest_files=["res://.godot/imported/gary_pixels.png-3b277e035a73ecaf93d5fc604cea6ce4.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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

1
icon.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>

After

Width:  |  Height:  |  Size: 994 B

37
icon.svg.import Normal file
View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cenrv2i6tua12"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

49
project.godot Normal file
View File

@@ -0,0 +1,49 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="mini-garden"
run/main_scene="uid://8o4ffx055dof"
config/features=PackedStringArray("4.4", "GL Compatibility")
config/icon="res://icon.svg"
[input]
input_north={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
input_south={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
input_east={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
input_west={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
]
}
[rendering]
textures/canvas_textures/default_texture_filter=0
renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"

BIN
terrain/dirt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 934 B

34
terrain/dirt.png.import Normal file
View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c5lr861cmya6r"
path="res://.godot/imported/dirt.png-4b2e3b8f4083fb0baf8bb6a15680a151.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/dirt.png"
dest_files=["res://.godot/imported/dirt.png-4b2e3b8f4083fb0baf8bb6a15680a151.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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

BIN
terrain/grass.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

34
terrain/grass.png.import Normal file
View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bavfwcsgof0tp"
path="res://.godot/imported/grass.png-a4e0c50e89c55d70401dc2d88d40db84.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://terrain/grass.png"
dest_files=["res://.godot/imported/grass.png-a4e0c50e89c55d70401dc2d88d40db84.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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

9
terrain/terrain.gd Normal file
View File

@@ -0,0 +1,9 @@
extends TileMapLayer
var dirt_id = 0
var grass_id = 1
func _unhandled_input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed():
var coords: Vector2i = local_to_map(event.position)
set_cell(coords, dirt_id, Vector2i.ZERO, 0)

1
terrain/terrain.gd.uid Normal file
View File

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

View File

@@ -0,0 +1,19 @@
[gd_resource type="TileSet" load_steps=5 format=3 uid="uid://resk8tvqugsx"]
[ext_resource type="Texture2D" uid="uid://c5lr861cmya6r" path="res://terrain/dirt.png" id="1_m2li2"]
[ext_resource type="Texture2D" uid="uid://bavfwcsgof0tp" path="res://terrain/grass.png" id="2_54oqm"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_busfd"]
texture = ExtResource("1_m2li2")
texture_region_size = Vector2i(32, 32)
0:0/0 = 0
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_wkw05"]
texture = ExtResource("2_54oqm")
texture_region_size = Vector2i(32, 32)
0:0/0 = 0
[resource]
tile_size = Vector2i(32, 32)
sources/0 = SubResource("TileSetAtlasSource_busfd")
sources/1 = SubResource("TileSetAtlasSource_wkw05")

11
tree/small_tree.gd Normal file
View File

@@ -0,0 +1,11 @@
extends Area2D
var _durability: int = 3
func _on_body_entered(body: Node2D) -> void:
if body is CharacterBody2D:
_durability -= 1
body.repel_collision(self)
if _durability <= 0:
print("tree dead")
queue_free()

1
tree/small_tree.gd.uid Normal file
View File

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

BIN
tree/small_tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bfyw8l1ubdnsj"
path="res://.godot/imported/small_tree.png-6b7409adbeafd078c10945c05a21c2ab.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://tree/small_tree.png"
dest_files=["res://.godot/imported/small_tree.png-6b7409adbeafd078c10945c05a21c2ab.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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

21
tree/small_tree.tscn Normal file
View File

@@ -0,0 +1,21 @@
[gd_scene load_steps=4 format=3 uid="uid://d2re5mee0xayj"]
[ext_resource type="Texture2D" uid="uid://bfyw8l1ubdnsj" path="res://tree/small_tree.png" id="1_1ao6o"]
[ext_resource type="Script" uid="uid://clxosihgty8t5" path="res://tree/small_tree.gd" id="1_brd4x"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vb5bs"]
size = Vector2(32, 32)
[node name="Tree" type="Area2D"]
script = ExtResource("1_brd4x")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("1_1ao6o")
offset = Vector2(16, 16)
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false
position = Vector2(16, 16)
shape = SubResource("RectangleShape2D_vb5bs")
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

BIN
tree/small_tree.xcf Normal file

Binary file not shown.

15
working_scene.gd Normal file
View File

@@ -0,0 +1,15 @@
extends Node2D
@export var small_tree = preload("res://tree/small_tree.tscn")
func _ready() -> void:
randomize()
_procgen()
func _procgen() -> void:
for i in range(0, 15):
var grid_pos = Vector2i(randi() % 20, randi() % 20)
if grid_pos.x == 0 and grid_pos.y == 0: continue #NOTE: don't spawn on the player
var st = small_tree.instantiate()
st.position = Vector2(grid_pos * 32)
add_child(st)

1
working_scene.gd.uid Normal file
View File

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

35
working_scene.tscn Normal file

File diff suppressed because one or more lines are too long

BIN
workspace/tileset.xcf Normal file

Binary file not shown.