add mine that explodes on contact with player, shot by arrow, or other mine's explosions

This commit is contained in:
Haze Weathers 2023-02-17 15:12:15 -05:00
parent c577f0a57c
commit 8a47c20d94
12 changed files with 338 additions and 7 deletions

BIN
graphics/enemy/chain.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/chain.png-418b1dbdc93cfd012f4f36fd87b0e225.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://graphics/enemy/chain.png"
dest_files=[ "res://.import/chain.png-418b1dbdc93cfd012f4f36fd87b0e225.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=1
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/explosion.png-04c26d31be903fe5209fbb88fb2b001b.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://graphics/enemy/explosion.png"
dest_files=[ "res://.import/explosion.png-04c26d31be903fe5209fbb88fb2b001b.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

BIN
graphics/enemy/mine.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 741 B

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/mine.png-64fede174f9ce16c1380d86ae4488e55.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://graphics/enemy/mine.png"
dest_files=[ "res://.import/mine.png-64fede174f9ce16c1380d86ae4488e55.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

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=22 format=2]
[gd_scene load_steps=24 format=2]
[ext_resource path="res://maps/map.gd" type="Script" id=1]
[ext_resource path="res://objects/hud/hud.tscn" type="PackedScene" id=2]
@ -10,6 +10,8 @@
[ext_resource path="res://objects/player/player.tscn" type="PackedScene" id=8]
[ext_resource path="res://objects/environment/ladder/ladder.tscn" type="PackedScene" id=9]
[ext_resource path="res://graphics/particles/bubble.png" type="Texture" id=10]
[ext_resource path="res://objects/enemy/mine.tscn" type="PackedScene" id=11]
[ext_resource path="res://objects/enemy/spider.tscn" type="PackedScene" id=12]
[sub_resource type="ShaderMaterial" id=1]
shader = ExtResource( 4 )
@ -170,17 +172,17 @@ max_fall_speed = 60.0
jump_force = 80
doublejump_force = 60
[node name="StaticBody2D" type="StaticBody2D" parent="."]
[node name="LevelBorders" type="StaticBody2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="LevelBorders"]
position = Vector2( -4, 256 )
shape = SubResource( 7 )
[node name="CollisionShape2D2" type="CollisionShape2D" parent="StaticBody2D"]
[node name="CollisionShape2D2" type="CollisionShape2D" parent="LevelBorders"]
position = Vector2( 260, 256 )
shape = SubResource( 7 )
[node name="CollisionShape2D3" type="CollisionShape2D" parent="StaticBody2D"]
[node name="CollisionShape2D3" type="CollisionShape2D" parent="LevelBorders"]
position = Vector2( 128, 580 )
shape = SubResource( 8 )
@ -192,6 +194,28 @@ cell_size = Vector2( 8, 8 )
format = 1
tile_data = PoolIntArray( 393233, 0, 196608, 458752, 0, 65536, 458753, 0, 65537, 458754, 0, 65537, 458755, 0, 65537, 458756, 0, 65537, 458757, 0, 65537, 458758, 0, 65538, 458769, 0, 196608, 458770, 0, 0, 458771, 0, 0, 524302, 0, 0, 524303, 0, 0, 524305, 0, 196608, 589835, 0, 0, 589841, 0, 196608, 655368, 0, 0, 655377, 0, 196608, 720913, 0, 196608, 786449, 0, 196608, 851976, 0, 0, 851977, 0, 0, 851978, 0, 0, 851979, 0, 0, 851980, 0, 0, 851981, 0, 0, 851982, 0, 0, 851983, 0, 0, 851984, 0, 0, 851985, 0, 0, 851986, 0, 0, 851987, 0, 0, 917511, 0, 0, 917512, 0, 0, 917513, 0, 0, 917514, 0, 0, 917515, 0, 0, 917516, 0, 0, 917517, 0, 0, 917518, 0, 0, 917519, 0, 0, 917520, 0, 0, 917521, 0, 0, 917522, 0, 0, 983048, 0, 0, 983049, 0, 0, 983050, 0, 0, 983051, 0, 0, 983052, 0, 0, 983053, 0, 0, 983054, 0, 0, 983055, 0, 0, 983056, 0, 0, 983057, 0, 0, 983058, 0, 0, 1048586, 0, 0, 1048587, 0, 0, 1048588, 0, 0, 1048589, 0, 0, 1048590, 0, 0, 1048591, 0, 0, 1048592, 0, 0, 1048593, 0, 0, 1114124, 0, 0, 1114125, 0, 0, 1114126, 0, 0, 1114127, 0, 0, 1114128, 0, 0 )
[node name="Ladder" parent="Tilemaps/Ground" instance=ExtResource( 9 )]
[node name="Ladders" type="Node2D" parent="."]
[node name="Ladder" parent="Ladders" instance=ExtResource( 9 )]
position = Vector2( 136, 48 )
scale = Vector2( 1, 7 )
[node name="Enemies" type="Node2D" parent="."]
[node name="Mines" type="Node2D" parent="Enemies"]
[node name="Mine" parent="Enemies/Mines" instance=ExtResource( 11 )]
position = Vector2( 96, 32 )
[node name="Mine2" parent="Enemies/Mines" instance=ExtResource( 11 )]
position = Vector2( 120, 32 )
[node name="Mine3" parent="Enemies/Mines" instance=ExtResource( 11 )]
position = Vector2( 144, 24 )
[node name="Mine4" parent="Enemies/Mines" instance=ExtResource( 11 )]
position = Vector2( 72, 48 )
[node name="Spider" parent="Enemies/Mines" instance=ExtResource( 12 )]
position = Vector2( 128, 160 )
down_boundary = 4

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=19 format=2]
[gd_scene load_steps=21 format=2]
[ext_resource path="res://objects/player/player.tscn" type="PackedScene" id=1]
[ext_resource path="res://tilesets/t_cave.tres" type="TileSet" id=2]
@ -17,6 +17,8 @@
[ext_resource path="res://objects/environment/moving_platform/moving_platform.tscn" type="PackedScene" id=15]
[ext_resource path="res://objects/respawn_point.tscn" type="PackedScene" id=16]
[ext_resource path="res://objects/player/arrow_projectile.tscn" type="PackedScene" id=17]
[ext_resource path="res://objects/enemy/mine.tscn" type="PackedScene" id=18]
[ext_resource path="res://objects/enemy/explosion.tscn" type="PackedScene" id=19]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 16, 20 )
@ -125,3 +127,9 @@ position = Vector2( 128, 128 )
[node name="ArrowProjectile2" parent="." instance=ExtResource( 17 )]
position = Vector2( 198, 130 )
speed = 0.0
[node name="Mine" parent="." instance=ExtResource( 18 )]
position = Vector2( 232, 144 )
[node name="Explosion" parent="." instance=ExtResource( 19 )]
position = Vector2( 160, 128 )

View file

@ -0,0 +1,10 @@
extends "res://objects/enemy/enemy.gd"
func _ready():
$AnimatedSprite.play("explode")
func _on_animation_finished():
queue_free()
func die():
return

View file

@ -0,0 +1,55 @@
[gd_scene load_steps=11 format=2]
[ext_resource path="res://objects/enemy/explosion.gd" type="Script" id=1]
[ext_resource path="res://graphics/enemy/explosion.png" type="Texture" id=2]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 2 )
region = Rect2( 0, 0, 64, 64 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 2 )
region = Rect2( 64, 0, 64, 64 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 2 )
region = Rect2( 128, 0, 64, 64 )
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 2 )
region = Rect2( 192, 0, 64, 64 )
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 2 )
region = Rect2( 256, 0, 64, 64 )
[sub_resource type="AtlasTexture" id=6]
atlas = ExtResource( 2 )
region = Rect2( 320, 0, 64, 64 )
[sub_resource type="SpriteFrames" id=7]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ) ],
"loop": false,
"name": "explode",
"speed": 10.0
} ]
[sub_resource type="RectangleShape2D" id=8]
extents = Vector2( 24, 24 )
[node name="Explosion" type="Node2D"]
script = ExtResource( 1 )
blood = false
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 7 )
animation = "explode"
[node name="Hitbox" type="Area2D" parent="." groups=["enemy_hitbox", "explosion"]]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
shape = SubResource( 8 )
[connection signal="animation_finished" from="AnimatedSprite" to="." method="_on_animation_finished"]
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]

28
objects/enemy/mine.gd Normal file
View file

@ -0,0 +1,28 @@
extends "res://objects/enemy/enemy.gd"
const Explosion = preload("res://objects/enemy/explosion.tscn")
onready var chain = $Chain
onready var hitbox = $Hitbox
func _ready():
var ground_cast = $GroundCast
ground_cast.force_raycast_update()
if ground_cast.is_colliding():
chain.points[1].y = chain.to_local(ground_cast.get_collision_point()).y
func _process(delta):
chain.points[0].x = hitbox.position.x
func _on_Hitbox_area_entered(area):
if area.is_in_group("explosion"):
var timer = get_tree().create_timer(0.2, false)
timer.connect("timeout", self, "die")
if area.is_in_group("player"):
die()
func die():
var explosion = Explosion.instance()
explosion.global_position = hitbox.global_position
get_parent().call_deferred("add_child", explosion)
queue_free()

101
objects/enemy/mine.tscn Normal file
View file

@ -0,0 +1,101 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://objects/enemy/mine.gd" type="Script" id=1]
[ext_resource path="res://graphics/enemy/mine.png" type="Texture" id=2]
[ext_resource path="res://graphics/enemy/chain.png" type="Texture" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 8, 8 )
[sub_resource type="Animation" id=2]
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath("Hitbox:position")
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": [ Vector2( 8, 8 ) ]
}
tracks/1/type = "bezier"
tracks/1/path = NodePath("Hitbox:position:x")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"points": PoolRealArray( 8, -0.25, 0, 0.25, 0 ),
"times": PoolRealArray( 0 )
}
tracks/2/type = "bezier"
tracks/2/path = NodePath("Hitbox:position:y")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"points": PoolRealArray( 8, -0.25, 0, 0.25, 0 ),
"times": PoolRealArray( 0 )
}
[sub_resource type="Animation" id=3]
resource_name = "sway"
length = 8.0
loop = true
tracks/0/type = "bezier"
tracks/0/path = NodePath("Hitbox:position:x")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"points": PoolRealArray( 4, -1.7, -0.0788159, 1.7, 0.0788159, 12, -1.9, -0.00271606, 1.9, 0.00271606, 4, -1.6, -0.0139103, 1.6, 0.0139103 ),
"times": PoolRealArray( 0, 4, 8 )
}
tracks/1/type = "bezier"
tracks/1/path = NodePath("Hitbox:position:y")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"points": PoolRealArray( 8, -0.25, 0, 0.25, 0, 8, -0.25, 0, 0.25, 0, 8, -0.25, 0, 0.25, 0, 8, -0.25, 0, 0.25, 0, 8, -0.25, 0, 0.25, 0 ),
"times": PoolRealArray( 0, 2, 4, 6, 8 )
}
[node name="Mine" type="Node2D"]
script = ExtResource( 1 )
blood = false
[node name="GroundCast" type="RayCast2D" parent="."]
visible = false
position = Vector2( 8, 8 )
cast_to = Vector2( 0, 192 )
[node name="Chain" type="Line2D" parent="."]
position = Vector2( 0, 8 )
points = PoolVector2Array( 8, 0, 8, 16 )
width = 4.0
default_color = Color( 1, 1, 1, 1 )
texture = ExtResource( 3 )
texture_mode = 1
[node name="Hitbox" type="Area2D" parent="." groups=["enemy_hitbox"]]
position = Vector2( 8, 8 )
[node name="Sprite" type="Sprite" parent="Hitbox"]
texture = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
shape = SubResource( 1 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "sway"
anims/RESET = SubResource( 2 )
anims/sway = SubResource( 3 )
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]