mirror of https://github.com/profan/ld-39-jam.git
animated explosion
This commit is contained in:
parent
dcdc9171cd
commit
a9aeaf20b0
|
@ -1,5 +1,7 @@
|
||||||
extends KinematicBody2D
|
extends KinematicBody2D
|
||||||
|
|
||||||
|
var ExplosionEffect = load("res://ExplosionEffect.tscn")
|
||||||
|
|
||||||
var rect = Rect2(0, 0, 0, 0)
|
var rect = Rect2(0, 0, 0, 0)
|
||||||
var velocity = Vector2(0, 0)
|
var velocity = Vector2(0, 0)
|
||||||
var rot_vel = 0
|
var rot_vel = 0
|
||||||
|
@ -31,6 +33,10 @@ func wrap(v, v_min, v_max):
|
||||||
return v
|
return v
|
||||||
|
|
||||||
func on_explode():
|
func on_explode():
|
||||||
|
# create bullet impact
|
||||||
|
var new_ee = ExplosionEffect.instance()
|
||||||
|
get_tree().get_root().add_child(new_ee)
|
||||||
|
new_ee.set_global_pos(get_global_pos())
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
func do_damage(v):
|
func do_damage(v):
|
||||||
|
|
|
@ -5,7 +5,7 @@ var BulletImpact = load("res://BulletImpact.tscn")
|
||||||
var velocity = Vector2(1, 0)
|
var velocity = Vector2(1, 0)
|
||||||
var lifetime = 16 # seconds
|
var lifetime = 16 # seconds
|
||||||
|
|
||||||
var bullet_dmg = 0.25
|
var bullet_dmg = 25
|
||||||
|
|
||||||
onready var sprite = get_node("Sprite")
|
onready var sprite = get_node("Sprite")
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
extends Sprite
|
||||||
|
|
||||||
|
var current_time = 0
|
||||||
|
var frames_per_second = 0.05
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
set_process(true)
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
|
||||||
|
if int(current_time / frames_per_second) >= get_hframes() - 1:
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
set_frame(int(current_time / frames_per_second))
|
||||||
|
current_time += delta
|
|
@ -0,0 +1,13 @@
|
||||||
|
[gd_scene load_steps=3 format=1]
|
||||||
|
|
||||||
|
[ext_resource path="res://raw/explosion_1.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://ExplosionEffect.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[node name="ExplosionEffect" type="Sprite"]
|
||||||
|
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
hframes = 8
|
||||||
|
region_rect = Rect2( 0, 0, 32, 32 )
|
||||||
|
script/script = ExtResource( 2 )
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:b900489b98c048ae8c0891147a23232788780d5aececd7ee23b8563874dc694a
|
||||||
|
size 5525
|
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
|
@ -0,0 +1,2 @@
|
||||||
|
filter=false
|
||||||
|
gen_mipmaps=false
|
Loading…
Reference in New Issue