diff --git a/graphics/enemy/turtle.png b/graphics/enemy/turtle.png new file mode 100644 index 0000000..981663f Binary files /dev/null and b/graphics/enemy/turtle.png differ diff --git a/graphics/enemy/turtle.png.import b/graphics/enemy/turtle.png.import new file mode 100644 index 0000000..4564080 --- /dev/null +++ b/graphics/enemy/turtle.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/turtle.png-7f0700b33935e20aa7dac9deef68652e.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/enemy/turtle.png" +dest_files=[ "res://.import/turtle.png-7f0700b33935e20aa7dac9deef68652e.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 a8d6aeb..bdc2e6e 100644 --- a/maps/test_room.tscn +++ b/maps/test_room.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=30 format=2] +[gd_scene load_steps=31 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] @@ -17,6 +17,7 @@ [ext_resource path="res://objects/npc/msx.tscn" type="PackedScene" id=15] [ext_resource path="res://objects/respawn_point.tscn" type="PackedScene" id=16] [ext_resource path="res://shaders/1px_border.gdshader" type="Shader" id=17] +[ext_resource path="res://objects/enemy/turtle.tscn" type="PackedScene" id=18] [ext_resource path="res://objects/environment/switches/button.tscn" type="PackedScene" id=19] [ext_resource path="res://objects/enemy/tin.tscn" type="PackedScene" id=20] [ext_resource path="res://graphics/enemy/sawblade.png" type="Texture" id=21] @@ -139,6 +140,7 @@ material = SubResource( 4 ) position = Vector2( 4, 4 ) z_index = -3 frames = SubResource( 5 ) +frame = 1 playing = true [node name="Steam" parent="." instance=ExtResource( 23 )] @@ -146,6 +148,9 @@ position = Vector2( 27, 128 ) [node name="StaticBody2D" type="StaticBody2D" parent="."] +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"] +polygon = PoolVector2Array( 136, 176, 144, 160, 160, 160, 168, 176 ) + [node name="Hatch" parent="." instance=ExtResource( 14 )] position = Vector2( 40, 120 ) @@ -172,15 +177,15 @@ position = Vector2( 128, 152 ) [node name="LetterBlock" parent="." instance=ExtResource( 8 )] position = Vector2( 184, 160 ) -glyph = 16 +glyph = 4 [node name="LetterBlock2" parent="." instance=ExtResource( 8 )] position = Vector2( 192, 152 ) -glyph = 16 +glyph = 26 [node name="LetterBlock3" parent="." instance=ExtResource( 8 )] position = Vector2( 176, 144 ) -glyph = 16 +glyph = 12 [node name="LetterBlock4" parent="." instance=ExtResource( 8 )] position = Vector2( 192, 136 ) @@ -188,14 +193,20 @@ glyph = 16 [node name="LetterBlock5" parent="." instance=ExtResource( 8 )] position = Vector2( 216, 152 ) -glyph = 16 +glyph = 3 [node name="LetterBlock6" parent="." instance=ExtResource( 8 )] position = Vector2( 208, 128 ) -glyph = 16 +glyph = 30 [node name="LetterBlock7" parent="." instance=ExtResource( 8 )] position = Vector2( 224, 136 ) -glyph = 16 +glyph = 27 + +[node name="Turtle" parent="." instance=ExtResource( 18 )] +position = Vector2( 40, 160 ) +left_up_boundary = 2.0 +right_down_boundary = 4.0 +speed = 10 [editable path="RollingFiend"] diff --git a/objects/enemy/turtle.gd b/objects/enemy/turtle.gd new file mode 100644 index 0000000..a7dbf10 --- /dev/null +++ b/objects/enemy/turtle.gd @@ -0,0 +1,31 @@ +tool +extends "res://objects/enemy/enemy_move_sidesideupdown.gd" + +export var spike_delay: float = 2.0 +export var spike_time: float = 0.25 + +var spike_tween: SceneTreeTween + +onready var sprite: Sprite = $"%Sprite" +onready var spike_shape: CollisionShape2D = $"%SpikeShape" + +func _ready() -> void: + if Engine.editor_hint: + return + spike_tween = create_tween().set_loops() + + spike_tween.tween_property(spike_shape, "disabled", true, 0.0) + spike_tween.tween_property(sprite, "frame_coords:y", 0.0, 0.0) + spike_tween.tween_interval(spike_delay) + spike_tween.tween_property(sprite, "frame_coords:y", 1.0, 0.0) + spike_tween.tween_interval(spike_time * 2.0) + spike_tween.tween_property(spike_shape, "disabled", false, 0.0) + spike_tween.tween_property(sprite, "frame_coords:y", 2.0, 0.0) + spike_tween.tween_interval(spike_time) + +func die() -> void: + spike_tween.kill() + spike_shape.disabled = true + sprite.frame_coords.y = 3 + Audio.play_sound(death_sound, Audio.ac_die) + $"%DeathSplatter".emitting = true diff --git a/objects/enemy/turtle.tscn b/objects/enemy/turtle.tscn new file mode 100644 index 0000000..032e842 --- /dev/null +++ b/objects/enemy/turtle.tscn @@ -0,0 +1,91 @@ +[gd_scene load_steps=8 format=2] + +[ext_resource path="res://graphics/enemy/turtle.png" type="Texture" id=1] +[ext_resource path="res://objects/enemy/turtle.gd" type="Script" id=2] +[ext_resource path="res://objects/enemy/death_particles.tscn" type="PackedScene" id=3] + +[sub_resource type="Animation" id=1] +length = 0.001 +tracks/0/type = "value" +tracks/0/path = NodePath("ToFlip/Sprite:frame_coords:x") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ 0.0 ] +} + +[sub_resource type="Animation" id=2] +resource_name = "swim" +length = 0.9 +loop = true +tracks/0/type = "value" +tracks/0/path = NodePath("ToFlip/Sprite:frame_coords:x") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.3, 0.6, 0.9 ), +"transitions": PoolRealArray( 1, 1, 1, 1 ), +"update": 1, +"values": [ 0.0, 1.0, 2.0, 0.0 ] +} + +[sub_resource type="RectangleShape2D" id=3] +extents = Vector2( 2.5, 2.5 ) + +[sub_resource type="RectangleShape2D" id=5] +extents = Vector2( 6, 1.5 ) + +[node name="Turtle" type="Node2D" groups=["enemy"]] +script = ExtResource( 2 ) +blood = false +speed = 20 +node_to_flip = NodePath("ToFlip") + +[node name="ToFlip" type="Node2D" parent="."] +position = Vector2( 8.5, 4 ) + +[node name="Sprite" type="Sprite" parent="ToFlip"] +unique_name_in_owner = true +position = Vector2( -9.5, -9 ) +texture = ExtResource( 1 ) +centered = false +hframes = 3 +vframes = 4 +frame = 6 + +[node name="SwimPlayer" type="AnimationPlayer" parent="ToFlip"] +root_node = NodePath("../..") +autoplay = "swim" +anims/RESET = SubResource( 1 ) +anims/swim = SubResource( 2 ) + +[node name="HeadHitbox" type="Area2D" parent="." groups=["enemy_hitbox"]] +position = Vector2( 8.5, 4 ) + +[node name="HeadShape" type="CollisionShape2D" parent="HeadHitbox"] +position = Vector2( 11, -0.5 ) +shape = SubResource( 3 ) + +[node name="DeathSplatter" parent="HeadHitbox/HeadShape" instance=ExtResource( 3 )] +unique_name_in_owner = true + +[node name="SpikeHitbox" type="Area2D" parent="."] + +[node name="SpikeShape" type="CollisionShape2D" parent="SpikeHitbox"] +unique_name_in_owner = true +position = Vector2( 8.5, -1.5 ) +shape = SubResource( 5 ) + +[node name="Platform" type="KinematicBody2D" parent="."] + +[node name="PlatformShape" type="CollisionPolygon2D" parent="Platform"] +polygon = PoolVector2Array( 2, 0, 15, 0, 17, 4, 0, 4 ) + +[connection signal="area_entered" from="SpikeHitbox" to="." method="_on_Hitbox_area_entered"]