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

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