From 4790b2b2a47c959072cc6787e33fdf557ded6b45 Mon Sep 17 00:00:00 2001 From: pennyrigate Date: Wed, 7 Dec 2022 02:23:21 -0500 Subject: [PATCH] enemies can be squashed by rocks --- ...e.png-62fa29b1c63ec21bc37f2348e6ccfbe5.md5 | 4 +-- ....png-62fa29b1c63ec21bc37f2348e6ccfbe5.stex | Bin 122 -> 122 bytes graphics/enemy/slime.png | Bin 223 -> 221 bytes maps/map01.tscn | 23 +++++++----------- objects/enemy/enemy.gd | 7 +++++- objects/enemy/enemy_stationary.gd | 4 --- objects/enemy/slime.tscn | 7 +++--- objects/rock/rock.gd | 1 + objects/rock/rock.tscn | 14 ++++++++++- 9 files changed, 34 insertions(+), 26 deletions(-) delete mode 100644 objects/enemy/enemy_stationary.gd diff --git a/.import/slime.png-62fa29b1c63ec21bc37f2348e6ccfbe5.md5 b/.import/slime.png-62fa29b1c63ec21bc37f2348e6ccfbe5.md5 index 1ee8ad4..0862fc7 100644 --- a/.import/slime.png-62fa29b1c63ec21bc37f2348e6ccfbe5.md5 +++ b/.import/slime.png-62fa29b1c63ec21bc37f2348e6ccfbe5.md5 @@ -1,3 +1,3 @@ -source_md5="ba0f18fbc880afaa809050eefe6ffa1a" -dest_md5="c2f722aa299fb7c7e51f196a477370cc" +source_md5="234b7948dfce0e2acd7cadd00f04daa1" +dest_md5="21956716b623996381004ca0e06ba1ef" diff --git a/.import/slime.png-62fa29b1c63ec21bc37f2348e6ccfbe5.stex b/.import/slime.png-62fa29b1c63ec21bc37f2348e6ccfbe5.stex index 36168e3df99bac901306ad2c29ede3bf4a0007a3..6b6c7eddf6a20f7798a21c3e2e8ab890b6e1c718 100644 GIT binary patch delta 79 zcmV-V0I>ghdXO+mMF0Q*FBt#>5FZc&H2?D-Vggo?BsghdXO+mMgRZ+FBt#>5FZc&H2?D-Vgd${Y&SWYgrFx9Xh#u%gg8yWP_q!x l{|Vr)6+pBD80=X(ayl@Olkq;t$>Bb$MTgr5tp-C>{sR9u9gP40 diff --git a/graphics/enemy/slime.png b/graphics/enemy/slime.png index 46d54fd75751556bdd03d4f4250f08a6af8b0a36..a8ce6b97952f61c1d1065bfa9172ad57415263c8 100644 GIT binary patch delta 115 zcmV-(0F3|N0o?(Racsf>01m1m zfii>uyYf>YiWN>|cIN}2RhKQobX6L)R8A@`Dr~Brm@1g(9x8CPV);UA%xA93YyiEJ V0#{-ulDz-`002ovPDHLkV1m~vETI4Z delta 117 zcmV-*0E++J0p9_Tac;u^01m?e$8V@)0000?NklaKgaf-V9f;07do@7=5 Xy~hGq#x>XK00000NkvXXu0mjfVFoU1 diff --git a/maps/map01.tscn b/maps/map01.tscn index 5636202..fdf9067 100644 --- a/maps/map01.tscn +++ b/maps/map01.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=14 format=2] +[gd_scene load_steps=12 format=2] [ext_resource path="res://objects/player/player.tscn" type="PackedScene" id=1] [ext_resource path="res://objects/ladder/ladder.tscn" type="PackedScene" id=2] [ext_resource path="res://graphics/backgrounds/blue_sky.png" type="Texture" id=3] -[ext_resource path="res://objects/enemy/snake.tscn" type="PackedScene" id=4] [ext_resource path="res://objects/enemy/slime.tscn" type="PackedScene" id=5] [ext_resource path="res://tilesets/t_grass.tres" type="TileSet" id=7] [ext_resource path="res://objects/Camera2D.tscn" type="PackedScene" id=8] @@ -11,7 +10,6 @@ [ext_resource path="res://tilesets/t_water.tres" type="TileSet" id=10] [ext_resource path="res://objects/rock/rock.tscn" type="PackedScene" id=11] [ext_resource path="res://objects/collectibles/shard.tscn" type="PackedScene" id=12] -[ext_resource path="res://objects/barrier/barrier.tscn" type="PackedScene" id=13] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 8, 96 ) @@ -33,7 +31,7 @@ __meta__ = { tile_set = ExtResource( 7 ) cell_size = Vector2( 8, 8 ) format = 1 -tile_data = PoolIntArray( 6, 0, 0, 7, 0, 0, 65542, 0, 1, 65543, 0, 1, 131078, 0, 1, 131079, 0, 1, 196614, 0, 1, 196615, 0, 1, 393219, 0, 65536, 393220, 0, 65537, 393221, 0, 65537, 393222, 0, 65537, 393223, 0, 65537, 393224, 0, 65537, 393225, 0, 65537, 393226, 0, 65537, 393227, 0, 65538, 393230, 0, 65536, 393231, 0, 65537, 393232, 0, 65537, 393233, 0, 65538, 393236, 0, 65536, 393237, 0, 65537, 393238, 0, 65537, 393239, 0, 65537, 393240, 0, 65537, 393241, 0, 65538, 720904, 0, 65536, 720905, 0, 65537, 720906, 0, 65537, 720907, 0, 65537, 720908, 0, 65537, 720909, 0, 65537, 720910, 0, 65537, 720911, 0, 65538, 786433, 0, 65536, 786434, 0, 65537, 786435, 0, 65537, 786436, 0, 65537, 786437, 0, 65538, 917521, 0, 65536, 917522, 0, 65537, 917523, 0, 65537, 917524, 0, 65537, 917525, 0, 65537, 917526, 0, 65537, 917527, 0, 65537, 917528, 0, 65537, 917529, 0, 65537, 917530, 0, 65537, 917531, 0, 65537, 917532, 0, 65538, 1114118, 0, 65536, 1114119, 0, 65537, 1114120, 0, 65537, 1114121, 0, 65537, 1114122, 0, 65537, 1114123, 0, 65537, 1114124, 0, 65537, 1114125, 0, 65537, 1114126, 0, 65538, 1179649, 0, 65536, 1179650, 0, 65537, 1179651, 0, 65538, 1310736, 0, 131072, 1310737, 536870912, 0, 1310738, 536870912, 0, 1310739, 536870912, 0, 1310740, 0, 131073, 1376271, 0, 131072, 1376272, 0, 131075, 1376273, 536870912, 1, 1376274, 536870912, 1, 1376275, 536870912, 1, 1376276, 0, 131074, 1376277, 0, 131073, 1441792, 0, 0, 1441793, 0, 0, 1441794, 0, 0, 1441795, 0, 0, 1441796, 0, 0, 1441797, 0, 0, 1441798, 0, 0, 1441799, 0, 0, 1441800, 0, 0, 1441801, 0, 0, 1441802, 0, 0, 1441803, 0, 0, 1441804, 0, 0, 1441805, 0, 0, 1441806, 0, 0, 1441807, 0, 131075, 1441808, 0, 1, 1441809, 0, 1, 1441810, 0, 1, 1441811, 0, 1, 1441812, 0, 1, 1441813, 0, 131074, 1441814, 0, 0, 1441815, 0, 0, 1441816, 0, 0, 1441817, 0, 0, 1441818, 0, 0, 1441819, 0, 0, 1441820, 0, 0, 1441821, 0, 0, 1441822, 0, 0, 1441823, 0, 0, 1441824, 0, 0, 1441825, 0, 0, 1441826, 0, 0, 1441827, 0, 0, 1441828, 0, 0, 1441829, 0, 0, 1441830, 0, 0, 1441831, 0, 0, 1441832, 0, 0, 1441833, 0, 0, 1441834, 0, 0, 1441835, 0, 0, 1441836, 0, 0, 1441837, 0, 0, 1441838, 0, 0, 1441839, 0, 0, 1507328, 0, 1, 1507329, 0, 1, 1507330, 0, 1, 1507331, 0, 1, 1507332, 0, 1, 1507333, 0, 1, 1507334, 0, 1, 1507335, 0, 1, 1507336, 0, 1, 1507337, 0, 1, 1507338, 0, 1, 1507339, 0, 1, 1507340, 0, 1, 1507341, 0, 1, 1507342, 0, 1, 1507343, 0, 1, 1507344, 0, 1, 1507345, 0, 1, 1507346, 0, 1, 1507347, 0, 1, 1507348, 0, 1, 1507349, 0, 1, 1507350, 0, 1, 1507351, 0, 1, 1507352, 0, 1, 1507353, 0, 1, 1507354, 0, 1, 1507355, 0, 1, 1507356, 0, 1, 1507357, 0, 1, 1507358, 0, 1, 1507359, 0, 1, 1507360, 0, 1, 1507361, 0, 1, 1507362, 0, 1, 1507363, 0, 1, 1507364, 0, 1, 1507365, 0, 1, 1507366, 0, 1, 1507367, 0, 1, 1507368, 0, 1, 1507369, 0, 1, 1507370, 0, 1, 1507371, 0, 1, 1507372, 0, 1, 1507373, 0, 1, 1507374, 0, 1, 1507375, 0, 1 ) +tile_data = PoolIntArray( 393219, 0, 65536, 393220, 0, 65537, 393221, 0, 65537, 393222, 0, 65537, 393223, 0, 65537, 393224, 0, 65537, 393225, 0, 65537, 393226, 0, 65537, 393227, 0, 65538, 393230, 0, 65536, 393231, 0, 65537, 393232, 0, 65537, 393233, 0, 65538, 393236, 0, 65536, 393237, 0, 65537, 393238, 0, 65537, 393239, 0, 65537, 393240, 0, 65537, 393241, 0, 65538, 720904, 0, 65536, 720905, 0, 65537, 720906, 0, 65537, 720907, 0, 65537, 720908, 0, 65537, 720909, 0, 65537, 720910, 0, 65537, 720911, 0, 65538, 786433, 0, 65536, 786434, 0, 65537, 786435, 0, 65537, 786436, 0, 65537, 786437, 0, 65538, 917521, 0, 65536, 917522, 0, 65537, 917523, 0, 65537, 917524, 0, 65537, 917525, 0, 65537, 917526, 0, 65537, 917527, 0, 65537, 917528, 0, 65537, 917529, 0, 65537, 917530, 0, 65537, 917531, 0, 65537, 917532, 0, 65538, 1114118, 0, 65536, 1114119, 0, 65537, 1114120, 0, 65537, 1114121, 0, 65537, 1114122, 0, 65537, 1114123, 0, 65537, 1114124, 0, 65537, 1114125, 0, 65537, 1114126, 0, 65538, 1179649, 0, 65536, 1179650, 0, 65537, 1179651, 0, 65538, 1310736, 0, 131072, 1310737, 536870912, 0, 1310738, 536870912, 0, 1310739, 536870912, 0, 1310740, 0, 131073, 1376271, 0, 131072, 1376272, 0, 131075, 1376273, 536870912, 1, 1376274, 536870912, 1, 1376275, 536870912, 1, 1376276, 0, 131074, 1376277, 0, 131073, 1441792, 0, 0, 1441793, 0, 0, 1441794, 0, 0, 1441795, 0, 0, 1441796, 0, 0, 1441797, 0, 0, 1441798, 0, 0, 1441799, 0, 0, 1441800, 0, 0, 1441801, 0, 0, 1441802, 0, 0, 1441803, 0, 0, 1441804, 0, 0, 1441805, 0, 0, 1441806, 0, 0, 1441807, 0, 131075, 1441808, 0, 1, 1441809, 0, 1, 1441810, 0, 1, 1441811, 0, 1, 1441812, 0, 1, 1441813, 0, 131074, 1441814, 0, 0, 1441815, 0, 0, 1441816, 0, 0, 1441817, 0, 0, 1441818, 0, 0, 1441819, 0, 0, 1441820, 0, 0, 1441821, 0, 0, 1441822, 0, 0, 1441823, 0, 0, 1441824, 0, 0, 1441825, 0, 0, 1441826, 0, 0, 1441827, 0, 0, 1441828, 0, 0, 1441829, 0, 0, 1441830, 0, 0, 1441831, 0, 0, 1441832, 0, 0, 1441833, 0, 0, 1441834, 0, 0, 1441835, 0, 0, 1441836, 0, 0, 1441837, 0, 0, 1441838, 0, 0, 1441839, 0, 0, 1507328, 0, 1, 1507329, 0, 1, 1507330, 0, 1, 1507331, 0, 1, 1507332, 0, 1, 1507333, 0, 1, 1507334, 0, 1, 1507335, 0, 1, 1507336, 0, 1, 1507337, 0, 1, 1507338, 0, 1, 1507339, 0, 1, 1507340, 0, 1, 1507341, 0, 1, 1507342, 0, 1, 1507343, 0, 1, 1507344, 0, 1, 1507345, 0, 1, 1507346, 0, 1, 1507347, 0, 1, 1507348, 0, 1, 1507349, 0, 1, 1507350, 0, 1, 1507351, 0, 1, 1507352, 0, 1, 1507353, 0, 1, 1507354, 0, 1, 1507355, 0, 1, 1507356, 0, 1, 1507357, 0, 1, 1507358, 0, 1, 1507359, 0, 1, 1507360, 0, 1, 1507361, 0, 1, 1507362, 0, 1, 1507363, 0, 1, 1507364, 0, 1, 1507365, 0, 1, 1507366, 0, 1, 1507367, 0, 1, 1507368, 0, 1, 1507369, 0, 1, 1507370, 0, 1, 1507371, 0, 1, 1507372, 0, 1, 1507373, 0, 1, 1507374, 0, 1, 1507375, 0, 1 ) [node name="Water" type="TileMap" parent="."] tile_set = ExtResource( 10 ) @@ -42,7 +40,7 @@ format = 1 tile_data = PoolIntArray( 1507376, 0, 0, 1507377, 0, 0, 1507378, 0, 0, 1507379, 0, 0, 1507380, 0, 0, 1507381, 0, 0, 1507382, 0, 0, 1507383, 0, 0, 1507384, 0, 0, 1507385, 0, 0, 1507386, 0, 0, 1507387, 0, 0, 1507388, 0, 0, 1507389, 0, 0, 1507390, 0, 0, 1507391, 0, 0 ) [node name="Player" parent="." instance=ExtResource( 1 )] -position = Vector2( 88, 112 ) +position = Vector2( 168, 96 ) [node name="Ladder" type="TileMap" parent="."] tile_set = ExtResource( 7 ) @@ -71,19 +69,16 @@ scale = Vector2( 1, 9 ) [node name="Shard" parent="Collectibles" instance=ExtResource( 12 )] position = Vector2( 32, 40 ) -[node name="Slime" parent="Collectibles" instance=ExtResource( 5 )] -position = Vector2( 144, 160 ) +[node name="Enemies" type="Node2D" parent="."] -[node name="Snake" parent="Collectibles" instance=ExtResource( 4 )] -position = Vector2( 56, 168 ) -right_down_boundry = 3.0 +[node name="Slime" parent="Enemies" instance=ExtResource( 5 )] +position = Vector2( 128, 152 ) [node name="Rock" parent="." instance=ExtResource( 11 )] -position = Vector2( 104, 128 ) +position = Vector2( 144, 104 ) -[node name="Barrier" parent="." instance=ExtResource( 13 )] -position = Vector2( 48, 32 ) -cost = 3 +[node name="Rock2" parent="." instance=ExtResource( 11 )] +position = Vector2( 144, 152 ) [node name="ColorRect" type="ColorRect" parent="."] margin_left = 256.0 diff --git a/objects/enemy/enemy.gd b/objects/enemy/enemy.gd index 0cfc198..9c616ca 100644 --- a/objects/enemy/enemy.gd +++ b/objects/enemy/enemy.gd @@ -1,6 +1,7 @@ extends Node2D export var can_be_killed_by_sword = true +export var can_be_squashed = true func _on_Area2D_area_entered(area): #Kill player @@ -10,4 +11,8 @@ func _on_Area2D_area_entered(area): if area.is_in_group("sword"): if can_be_killed_by_sword: queue_free() - + #Die from rock/ get squashed + if area.is_in_group("squash"): + var squasher = area.get_parent() + if squasher.position.y + squasher.bottom.position.y < global_position.y: + queue_free() diff --git a/objects/enemy/enemy_stationary.gd b/objects/enemy/enemy_stationary.gd deleted file mode 100644 index aa523af..0000000 --- a/objects/enemy/enemy_stationary.gd +++ /dev/null @@ -1,4 +0,0 @@ -extends "res://objects/enemy/enemy.gd" - -func _process(delta): - scale.x = -1 diff --git a/objects/enemy/slime.tscn b/objects/enemy/slime.tscn index a221914..927aa09 100644 --- a/objects/enemy/slime.tscn +++ b/objects/enemy/slime.tscn @@ -3,7 +3,7 @@ [ext_resource path="res://graphics/enemy/slime.png" type="Texture" id=1] [ext_resource path="res://scripts/recolor_border.shader" type="Shader" id=2] [ext_resource path="res://graphics/enemy/slime_purple.png" type="Texture" id=3] -[ext_resource path="res://objects/enemy/enemy_stationary.gd" type="Script" id=4] +[ext_resource path="res://objects/enemy/enemy.gd" type="Script" id=4] [sub_resource type="ShaderMaterial" id=1] shader = ExtResource( 2 ) @@ -35,15 +35,14 @@ script = ExtResource( 4 ) [node name="AnimatedSprite" type="AnimatedSprite" parent="."] material = SubResource( 1 ) -position = Vector2( 5, -5 ) +position = Vector2( 5, 3 ) frames = SubResource( 4 ) playing = true [node name="Area2D" type="Area2D" parent="."] -visible = false [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] -position = Vector2( 4.5, -4.5 ) +position = Vector2( 4.5, 3.5 ) shape = SubResource( 5 ) [connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"] diff --git a/objects/rock/rock.gd b/objects/rock/rock.gd index a6ad8cb..c34d587 100644 --- a/objects/rock/rock.gd +++ b/objects/rock/rock.gd @@ -1,5 +1,6 @@ extends KinematicBody2D var velocity = Vector2.ZERO +onready var bottom = $Bottom func _physics_process(delta): if !is_on_floor(): diff --git a/objects/rock/rock.tscn b/objects/rock/rock.tscn index 16e9ef6..d63cdf7 100644 --- a/objects/rock/rock.tscn +++ b/objects/rock/rock.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://graphics/rock/rock.png" type="Texture" id=1] [ext_resource path="res://scripts/1px_border.gdshader" type="Shader" id=2] @@ -12,6 +12,9 @@ shader_param/border_corners = false [sub_resource type="RectangleShape2D" id=2] extents = Vector2( 5, 4.5 ) +[sub_resource type="RectangleShape2D" id=3] +extents = Vector2( 5, 4.5 ) + [node name="Rock" type="KinematicBody2D" groups=["pushable"]] script = ExtResource( 3 ) @@ -24,3 +27,12 @@ centered = false [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2( 5, 3.5 ) shape = SubResource( 2 ) + +[node name="Area2D" type="Area2D" parent="." groups=["squash"]] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +position = Vector2( 5, 3.5 ) +shape = SubResource( 3 ) + +[node name="Bottom" type="Position2D" parent="."] +position = Vector2( 5, 8 )