From d59c37eb496aac19143792f27aca5b0d96334dce Mon Sep 17 00:00:00 2001 From: Haze Weathers Date: Mon, 5 Jun 2023 17:42:14 -0400 Subject: [PATCH] add letter block --- graphics/hud/letter_blocks.png | Bin 0 -> 1043 bytes graphics/hud/letter_blocks.png.import | 35 ++++++++++++++++++ maps/test_room.tscn | 32 +++++++++++++++-- objects/hud/letter_block.gd | 49 ++++++++++++++++++++++++++ objects/hud/letter_block.tscn | 25 +++++++++++++ 5 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 graphics/hud/letter_blocks.png create mode 100644 graphics/hud/letter_blocks.png.import create mode 100644 objects/hud/letter_block.gd create mode 100644 objects/hud/letter_block.tscn diff --git a/graphics/hud/letter_blocks.png b/graphics/hud/letter_blocks.png new file mode 100644 index 0000000000000000000000000000000000000000..7bd463ee4eedc7dc134e6123e8ea051283e3ce9c GIT binary patch literal 1043 zcmV+u1nm2XP)EX>4Tx04R}tkv&MmKp2MKw$_SN9Lyl%kfAzR2NiMDDionYs1;guFuC*(nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~>f)s6A|-y86k5c1$8itueecWNcR;XFVVc!73uwA+ zrjrRVn_CqlujodY<~RhIS;m|srQkch?h)YoU7Tn6*Zn#A)V#%jfJi*c4AUmwAfDc| z4bJ<-0xQWX@j3CBNf#u3R-^Y&AJOM(_z?I(iR~x|0C+YRJ z7CQp^w}Ff6wx;X>mpj1VlOdb3D}`tU3kBf)jJ_!c4BP^}YhK@4=Qw=;GSsWo4RCM> zj20<--RIpsoqhYarq#b6XY6vKH3aNL00006VoOIv0QCSf07A!TA143+010qNS#tmY zE*}5@E*}AS?txzb000McNliru=LQ7^4-Olq$#MVy0uV_=K~!ko?V7u712GJSWr3CF zNs&H4MoE<_(_|UfX*@zkNEg7ZQz;P6BKecl`2?Q?7%+|!sRt>3=J{}af4im~H%cj` z%hz{P`1$*jK3<<6T2A$YzNUk--x^Q7PN+8QJwfE2 zK^ATqOD%(*_|*DD!=|VG`a6|$Ahk!9A0`Ox9E5Ux0hNz*337ePGj6;kb4dC%8=7n> z&&!Jexk$Wu9?3G=0ciOjNrSbVdM{wD&CznaH;rfO;2smSfJ!gQ9?;RobGkerHbH2D&;+3vNLWBg(;opLRKAq0QW1(|kxfG2UiE+;X-=yK zS;uEf9`&H+D6OoE4FS!?Ep+Gc0K|hdFR14q3IPv@L_sR51D#*9COAQ8g3x?5rgA{f zS66GjT9YnGZhnLoHR@+l8k9&(`>8A)z|y`q(}+KZQPAjR+?s+>57NBg=DolO5kz}ISN|bc#2k3Mv;4~MH7T32u%>OgUA}7vw1-TO+gyyAQhvL zDnn#FAt}$I6{C?_wp4U9N<%9~L)HYNHN77H5!yTiMuC~TZ@`{G=nv;2iB>8${lx$P N002ovPDHLkV1oUh)=dBa literal 0 HcmV?d00001 diff --git a/graphics/hud/letter_blocks.png.import b/graphics/hud/letter_blocks.png.import new file mode 100644 index 0000000..f8b9d43 --- /dev/null +++ b/graphics/hud/letter_blocks.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/letter_blocks.png-b999452f443d17ac8d79aa4caf470f5a.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/hud/letter_blocks.png" +dest_files=[ "res://.import/letter_blocks.png-b999452f443d17ac8d79aa4caf470f5a.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/maps/test_room.tscn b/maps/test_room.tscn index 0a50ea1..a8d6aeb 100644 --- a/maps/test_room.tscn +++ b/maps/test_room.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=29 format=2] +[gd_scene load_steps=30 format=2] [ext_resource path="res://objects/enemy/squig.tscn" type="PackedScene" id=1] [ext_resource path="res://tilesets/t_cave.tres" type="TileSet" id=2] @@ -7,6 +7,7 @@ [ext_resource path="res://tilesets/t_death.tres" type="TileSet" id=5] [ext_resource path="res://objects/Camera2D.tscn" type="PackedScene" id=6] [ext_resource path="res://graphics/backgrounds/canopy.png" type="Texture" id=7] +[ext_resource path="res://objects/hud/letter_block.tscn" type="PackedScene" id=8] [ext_resource path="res://objects/environment/rock/rock.tscn" type="PackedScene" id=9] [ext_resource path="res://objects/enemy/slime.tscn" type="PackedScene" id=10] [ext_resource path="res://maps/map.gd" type="Script" id=11] @@ -132,7 +133,6 @@ position = Vector2( 48, 120 ) [node name="AnimatedSprite" parent="RollingFiend" index="0"] visible = false -frame = 1 [node name="SawTest2" type="AnimatedSprite" parent="RollingFiend"] material = SubResource( 4 ) @@ -170,4 +170,32 @@ position = Vector2( 112, 176 ) [node name="Squig" parent="." instance=ExtResource( 1 )] position = Vector2( 128, 152 ) +[node name="LetterBlock" parent="." instance=ExtResource( 8 )] +position = Vector2( 184, 160 ) +glyph = 16 + +[node name="LetterBlock2" parent="." instance=ExtResource( 8 )] +position = Vector2( 192, 152 ) +glyph = 16 + +[node name="LetterBlock3" parent="." instance=ExtResource( 8 )] +position = Vector2( 176, 144 ) +glyph = 16 + +[node name="LetterBlock4" parent="." instance=ExtResource( 8 )] +position = Vector2( 192, 136 ) +glyph = 16 + +[node name="LetterBlock5" parent="." instance=ExtResource( 8 )] +position = Vector2( 216, 152 ) +glyph = 16 + +[node name="LetterBlock6" parent="." instance=ExtResource( 8 )] +position = Vector2( 208, 128 ) +glyph = 16 + +[node name="LetterBlock7" parent="." instance=ExtResource( 8 )] +position = Vector2( 224, 136 ) +glyph = 16 + [editable path="RollingFiend"] diff --git a/objects/hud/letter_block.gd b/objects/hud/letter_block.gd new file mode 100644 index 0000000..3852bb7 --- /dev/null +++ b/objects/hud/letter_block.gd @@ -0,0 +1,49 @@ +tool +extends "res://objects/enemy/enemy.gd" + +signal letter_chosen(letter) + +enum Glyph { + A, B, C, D, E, F, G, H, + I, J, K, L, M, N, O, P, + Q, R, S, T, U, V, W, X, + Y, Z, _0, _1, _2, _3, _4, _5, + _6, _7, _8, _9, +} +const GLYPH_STRINGS = [ + "A", "B", "C", "D", "E", "F", "G", "H", + "I", "J", "K", "L", "M", "N", "O", "P", + "Q", "R", "S", "T", "U", "V", "W", "X", + "Y", "Z", "0", "1", "2", "3", "4", "5", + "6", "7", "8", "9", +] + +export (Glyph) var glyph: int = 0 setget _set_glyph + +onready var sprite: Sprite = $Sprite +onready var _seed: float = randf() * 250.0 + +func _set_glyph(value: int) -> void: + glyph = value + get_node("Sprite").frame = value + +func _ready() -> void: + if Engine.editor_hint: + return + # connect to node in "gets_letters" group so don't have to do the shit manually + for node in get_tree().get_nodes_in_group("gets_letters"): + if node.has_method("_on_letter_chosen"): + connect("letter_chosen", node, "_on_letter_chosen") + +func _process(delta: float) -> void: + if Engine.editor_hint: + return + sprite.position.x = 4.0 + sin(float(Time.get_ticks_msec()) / 250.0 + _seed) + sprite.position.y = 5.0 + sin(float(Time.get_ticks_msec()) / 125.0 + _seed) + +func die() -> void: + emit_signal("letter_chosen", GLYPH_STRINGS[glyph]) + +func _on_Hitbox_area_entered(area): + emit_signal("letter_chosen", GLYPH_STRINGS[glyph]) + ._on_Hitbox_area_entered(area) diff --git a/objects/hud/letter_block.tscn b/objects/hud/letter_block.tscn new file mode 100644 index 0000000..06dbcfc --- /dev/null +++ b/objects/hud/letter_block.tscn @@ -0,0 +1,25 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://objects/hud/letter_block.gd" type="Script" id=1] +[ext_resource path="res://graphics/hud/letter_blocks.png" type="Texture" id=2] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 3, 3.5 ) + +[node name="LetterBlock" type="Node2D" groups=["enemy"]] +script = ExtResource( 1 ) +blood = false + +[node name="Sprite" type="Sprite" parent="."] +position = Vector2( 4, 5 ) +texture = ExtResource( 2 ) +hframes = 8 +vframes = 5 + +[node name="Hitbox" type="Area2D" parent="." groups=["enemy_hitbox"]] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"] +position = Vector2( 4, 4.5 ) +shape = SubResource( 1 ) + +[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]