SP, Ething
SP, Ething
file, the
tween code looks really messy in this format, but the idea was just tween the
sprite
from the shadow to - 70, then back down again, and when that tween finishes change
the state to HIT, play the explosion, flicker the collision for damage on enemies
and
player, then queue free.
the only other tricky thing was having the TNT go where I click. I do global
position - mouse position on the right click when I spawn the TNT, and then I made
the
speed equal to the strength of the distance. kinda hard to explain but I'll post it
too
Player Code:
if TNTAmount > 0:
playerCanThrow = false
throwTimer.start()
TNTAmount -=1
get\_parent().add\_child(TNTInstance)
TNTInstance.global\_position = self.global\_position
I'm not sure how readable this will be, but here is the code for the TNT file, the
tween code looks really messy in this format, but the idea was just tween the
sprite from the shadow to - 70, then back down again, and when that tween finishes
change the state to HIT, play the explosion, flicker the collision for damage on
enemies and player, then queue free.
the only other tricky thing was having the TNT go where I click. I do global
position - mouse position on the right click when I spawn the TNT, and then I made
the speed equal to the strength of the distance. kinda hard to explain but I'll
post it too
Player Code:
playerCanThrow = false
throwTimer.start()
TNTAmount -=1
get\_parent().add\_child(TNTInstance)
TNTInstance.global\_position = self.global\_position
extends KinematicBody2D
var damage = 10
var speed = 40
var knockback_amount = .4
MOVE
HIT
}
func _ready():
hurtArea.disabled = true
randomize()
sprite.rotation = rand\_range(0,90)
tween.start()
yield(tween,"tween\_all\_completed")
sprite.visible = false
shadow.visible = false
state = HIT
audio.play()
explosionSprite.visible = true
explosionSprite.position.y = -5
explosionSprite.play("start")
hurtArea.disabled = false
tween.start()
yield(explosionSprite,"animation\_finished")
hurtArea.disabled = true
explosionSprite.position.y = 0
explosionSprite.play("end")
yield(explosionSprite,"animation\_finished")
explosionSprite.visible = false
yield(audio,"finished")
queue\_free()
speed = max\_speed
match state:
MOVE:
sprite.rotation += .04
if col:
direction = direction.bounce(col.normal)
HIT:
if area.get\_parent().is\_in\_group("player"):
var enemy\_damage = .5
area.get\_parent().invuln(enemy\_damage)