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 speed = 64
onready var player = $"../../Player"
func _ready():
hp = 15
func _process(delta):
$Sprite.flip_h = true if player.global_position.x > self.global_position.x else false
func _physics_process(_delta):
var player_position = player.global_position + Vector2(12, 12)
var angle = get_angle_to(player_position)

View File

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

View File

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

View File

@ -1,14 +1,10 @@
extends EnemyClass
onready var player = $"../../Player"
var velocity = Vector2.ZERO
var speed = 24
func _ready():
hp = 15
func _process(delta):
$Sprite.flip_h = true if player.global_position.x > self.global_position.x else false
func _physics_process(delta):
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]
func _ready():
Global.playing = true
Global.play_time = .0
Global.health = 3
Global.add_health(0)

View File

@ -1,5 +1,6 @@
extends KinematicBody2D
onready var player = $"../../Player"
var empty_material = load("res://res/shaders/empty_material.tscn")
var hp
var dead = false
@ -21,6 +22,11 @@ func deal_damage(amount):
if hp <= 0:
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():
dead = true
$Sprite.playing = false
@ -34,8 +40,8 @@ func _physics_process(delta):
if dead:
self.global_position = death_position
dead_timer += delta
$Sprite.modulate.a = 1 - (dead_timer / 2)
if dead_timer >= 2.0:
$Sprite.modulate.a = 1 - (dead_timer * 2)
if dead_timer >= 0.5:
self.call_deferred("free")
if poisoned:

View File

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