Mob Death: Mob Not Strong -- Dead Mob Can't Flip

main
Luna Brovchuk 2023-10-01 20:58:47 +02:00
parent 138584b335
commit 2acab5dd13
7 changed files with 12 additions and 16 deletions

View File

@ -3,14 +3,9 @@ extends EnemyClass
var velocity = Vector2.ZERO var velocity = Vector2.ZERO
var speed = 64 var speed = 64
onready var player = $"../../Player"
func _ready(): func _ready():
hp = 15 hp = 15
func _process(delta):
$Sprite.flip_h = true if player.global_position.x > self.global_position.x else false
func _physics_process(_delta): func _physics_process(_delta):
var player_position = player.global_position + Vector2(12, 12) var player_position = player.global_position + Vector2(12, 12)
var angle = get_angle_to(player_position) var angle = get_angle_to(player_position)

View File

@ -25,7 +25,7 @@ flip_h = true
use_parent_material = true use_parent_material = true
frames = ExtResource( 1 ) frames = ExtResource( 1 )
animation = "idle" animation = "idle"
frame = 1 frame = 2
playing = true playing = true
centered = false centered = false

View File

@ -1,6 +1,5 @@
extends EnemyClass extends EnemyClass
onready var player = $"../../Player"
var dash_target = Vector2.ZERO var dash_target = Vector2.ZERO
var afterdash_timer = .0 var afterdash_timer = .0
var afterdash = false var afterdash = false

View File

@ -1,14 +1,10 @@
extends EnemyClass extends EnemyClass
onready var player = $"../../Player"
var velocity = Vector2.ZERO var velocity = Vector2.ZERO
var speed = 24 var speed = 24
func _ready(): func _ready():
hp = 15 hp = 15
func _process(delta):
$Sprite.flip_h = true if player.global_position.x > self.global_position.x else false
func _physics_process(delta): func _physics_process(delta):
global_position = global_position.move_toward(player.global_position + Vector2(8, 8), speed * delta * speed_multiplier) global_position = global_position.move_toward(player.global_position + Vector2(8, 8), speed * delta * speed_multiplier)

View File

@ -12,6 +12,7 @@ var mob_timers = [.0, .0, .0, .0]
var mob_threshold = [5, 7, 10, 7] var mob_threshold = [5, 7, 10, 7]
func _ready(): func _ready():
Global.playing = true
Global.play_time = .0 Global.play_time = .0
Global.health = 3 Global.health = 3
Global.add_health(0) Global.add_health(0)

View File

@ -1,5 +1,6 @@
extends KinematicBody2D extends KinematicBody2D
onready var player = $"../../Player"
var empty_material = load("res://res/shaders/empty_material.tscn") var empty_material = load("res://res/shaders/empty_material.tscn")
var hp var hp
var dead = false var dead = false
@ -21,6 +22,11 @@ func deal_damage(amount):
if hp <= 0: if hp <= 0:
death() death()
func _process(delta):
if Global.playing and not dead and is_in_group("enemy"):
player = get_tree().get_root().get_node("Game/View/Player")
$Sprite.flip_h = true if player.global_position.x > self.global_position.x else false
func death(): func death():
dead = true dead = true
$Sprite.playing = false $Sprite.playing = false
@ -34,8 +40,8 @@ func _physics_process(delta):
if dead: if dead:
self.global_position = death_position self.global_position = death_position
dead_timer += delta dead_timer += delta
$Sprite.modulate.a = 1 - (dead_timer / 2) $Sprite.modulate.a = 1 - (dead_timer * 2)
if dead_timer >= 2.0: if dead_timer >= 0.5:
self.call_deferred("free") self.call_deferred("free")
if poisoned: if poisoned:

View File

@ -3,12 +3,11 @@ extends Node
var GAME_SCENE = preload("res://src/scenes/game/Game.tscn") var GAME_SCENE = preload("res://src/scenes/game/Game.tscn")
var MENU_SCENE = preload("res://src/scenes/menu/Menu.tscn") var MENU_SCENE = preload("res://src/scenes/menu/Menu.tscn")
var playing = true var playing = false
var play_time = .0 var play_time = .0
var health = 2 var health = 2
func game_start(): func game_start():
playing = true
get_tree().change_scene_to(GAME_SCENE) get_tree().change_scene_to(GAME_SCENE)
func return_to_menu(): func return_to_menu():