made launch rigid more generic

This commit is contained in:
pennyrigate 2023-02-21 15:56:47 -05:00
parent 65a4fd8742
commit 40e10663d6
7 changed files with 158 additions and 19 deletions

View file

@ -1,13 +0,0 @@
extends RigidBody2D
#MINUMUM AND MAXIMUM IMPULSE
var impulse_min = 100
var impulse_max = 300
var rot = 0
func _ready():
#SHOOT OFF AT A RANDOM DIRECTION
var impulse_strength = rand_range(impulse_min, impulse_max)
var angle = rand_range(-360,360)
apply_central_impulse(Vector2(cos(angle), sin(angle)) * impulse_strength)

View file

@ -3,7 +3,7 @@
[ext_resource path="res://graphics/enemy/boss/scrump_gore/eyestalk.png" type="Texture" id=1]
[ext_resource path="res://graphics/enemy/boss/scrump_gore/eye.png" type="Texture" id=2]
[ext_resource path="res://graphics/enemy/boss/scrump_gore/headupper.png" type="Texture" id=3]
[ext_resource path="res://objects/enemy/boss/boss1_gore.gd" type="Script" id=4]
[ext_resource path="res://scripts/launch_rigid.gd" type="Script" id=4]
[ext_resource path="res://graphics/enemy/boss/scrump_gore/headlower.png" type="Texture" id=5]
[ext_resource path="res://graphics/enemy/boss/scrump_gore/tentacle5.png" type="Texture" id=6]
[ext_resource path="res://graphics/enemy/boss/scrump_gore/tentacle3.png" type="Texture" id=7]

View file

@ -27,3 +27,7 @@ func _physics_process(delta):
direction *= -1
if position.y <= startpos.y - (up_boundary):
direction *= -1
func die():
.die()
Game.instance_node(load("res://objects/enemy/tin_die.tscn"),position.x,position.y,get_parent())

9
objects/enemy/tin_die.gd Normal file
View file

@ -0,0 +1,9 @@
extends Node2D
func _ready():
$AnimatedSprite.playing = true
func _on_AnimatedSprite_animation_finished():
$AnimatedSprite.queue_free()

132
objects/enemy/tin_die.tscn Normal file
View file

@ -0,0 +1,132 @@
[gd_scene load_steps=13 format=2]
[ext_resource path="res://graphics/enemy/explosion_small.png" type="Texture" id=1]
[ext_resource path="res://objects/enemy/tin_die.gd" type="Script" id=2]
[ext_resource path="res://graphics/enemy/tin.png" type="Texture" id=3]
[ext_resource path="res://scripts/launch_rigid.gd" type="Script" id=4]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 16, 16 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 16, 0, 16, 16 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 32, 0, 16, 16 )
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 1 )
region = Rect2( 48, 0, 16, 16 )
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 1 )
region = Rect2( 64, 0, 16, 16 )
[sub_resource type="AtlasTexture" id=6]
atlas = ExtResource( 1 )
region = Rect2( 80, 0, 16, 16 )
[sub_resource type="SpriteFrames" id=7]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ) ],
"loop": false,
"name": "default",
"speed": 20.0
} ]
[sub_resource type="RectangleShape2D" id=8]
extents = Vector2( 2, 2 )
[node name="TinDie" type="Node2D"]
script = ExtResource( 2 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 7 )
[node name="Topleft" type="RigidBody2D" parent="."]
mass = 2.0
script = ExtResource( 4 )
impulse_max = 200
[node name="Sprite" type="Sprite" parent="Topleft"]
position = Vector2( -2, -2 )
texture = ExtResource( 3 )
hframes = 2
vframes = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="Topleft"]
position = Vector2( -2, -2 )
shape = SubResource( 8 )
[node name="Timer" type="Timer" parent="Topleft"]
wait_time = 5.0
autostart = true
[node name="TopRight" type="RigidBody2D" parent="."]
mass = 2.0
script = ExtResource( 4 )
impulse_max = 200
[node name="Sprite" type="Sprite" parent="TopRight"]
position = Vector2( 3, -2 )
texture = ExtResource( 3 )
hframes = 2
vframes = 2
frame = 1
[node name="CollisionShape2D" type="CollisionShape2D" parent="TopRight"]
position = Vector2( 2, -2 )
shape = SubResource( 8 )
[node name="Timer" type="Timer" parent="TopRight"]
wait_time = 5.3
autostart = true
[node name="BottomLeft" type="RigidBody2D" parent="."]
mass = 2.0
script = ExtResource( 4 )
impulse_max = 200
[node name="Sprite" type="Sprite" parent="BottomLeft"]
position = Vector2( -2, 3 )
texture = ExtResource( 3 )
hframes = 2
vframes = 2
frame = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="BottomLeft"]
position = Vector2( -2, 2 )
shape = SubResource( 8 )
[node name="Timer" type="Timer" parent="BottomLeft"]
wait_time = 5.5
autostart = true
[node name="BottomRight" type="RigidBody2D" parent="."]
position = Vector2( 3, 3 )
mass = 2.0
script = ExtResource( 4 )
impulse_max = 200
[node name="Sprite" type="Sprite" parent="BottomRight"]
texture = ExtResource( 3 )
hframes = 2
vframes = 2
frame = 3
[node name="CollisionShape2D" type="CollisionShape2D" parent="BottomRight"]
position = Vector2( -1, -1 )
shape = SubResource( 8 )
[node name="Timer" type="Timer" parent="BottomRight"]
wait_time = 5.8
autostart = true
[connection signal="animation_finished" from="AnimatedSprite" to="." method="_on_AnimatedSprite_animation_finished"]
[connection signal="timeout" from="Topleft/Timer" to="Topleft" method="queue_free"]
[connection signal="timeout" from="TopRight/Timer" to="TopRight" method="queue_free"]
[connection signal="timeout" from="BottomLeft/Timer" to="BottomLeft" method="queue_free"]
[connection signal="timeout" from="BottomRight/Timer" to="BottomRight" method="queue_free"]