settings, small fixes
This commit is contained in:
parent
b12c193636
commit
e08e3ebb13
174 changed files with 997 additions and 1040 deletions
|
|
@ -11,14 +11,3 @@ func _process(delta: float) -> void:
|
|||
# Calculate the new Y position using a sine wave
|
||||
position.y = sin(time * float_time) * float_str + float_offset
|
||||
queue_redraw()
|
||||
|
||||
func switch_mask(new : Types.mask_types):
|
||||
$MeleeMask.visible = false
|
||||
$RangedMask.visible = false
|
||||
$SpitMask.visible = false
|
||||
if (new == Types.mask_types.Melee):
|
||||
$MeleeMask.visible = true
|
||||
elif (new == Types.mask_types.Ranged):
|
||||
$RangedMask.visible = true
|
||||
elif (new == Types.mask_types.Spit):
|
||||
$SpitMask.visible = true
|
||||
|
|
|
|||
38
scripts/arrow.gd
Normal file
38
scripts/arrow.gd
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
extends Node2D
|
||||
|
||||
@export var min_distance := 250.0
|
||||
@export var rotation_speed := 8.0
|
||||
|
||||
var _target_pos: Vector2
|
||||
var _has_target := false
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
_find_target()
|
||||
_update_rotation(delta)
|
||||
|
||||
func _find_target() -> void:
|
||||
var enemies = get_tree().get_nodes_in_group("enemy")
|
||||
var closest_enemy: Node2D = null
|
||||
var shortest_dist := INF
|
||||
|
||||
for enemy in enemies:
|
||||
if enemy is Node2D:
|
||||
var dist = global_position.distance_to(enemy.global_position)
|
||||
if dist < shortest_dist:
|
||||
shortest_dist = dist
|
||||
closest_enemy = enemy
|
||||
|
||||
if closest_enemy and shortest_dist > min_distance:
|
||||
_target_pos = closest_enemy.global_position
|
||||
_has_target = true
|
||||
visible = true
|
||||
else:
|
||||
_has_target = false
|
||||
visible = false
|
||||
|
||||
func _update_rotation(delta: float) -> void:
|
||||
if not _has_target:
|
||||
return
|
||||
|
||||
var desired_angle = global_position.angle_to_point(_target_pos)
|
||||
rotation = lerp_angle(rotation, desired_angle, rotation_speed * delta)
|
||||
1
scripts/arrow.gd.uid
Normal file
1
scripts/arrow.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dn6ro2vef1qps
|
||||
|
|
@ -6,15 +6,12 @@ extends Camera2D
|
|||
@export var min_speed : float = 0.1
|
||||
@export var ui_layer : CanvasLayer
|
||||
|
||||
# --- NEW VARIABLE ---
|
||||
# 0.0 = no movement, 0.5 = camera moves halfway to mouse, 1.0 = camera centers on mouse
|
||||
@export_range(0.0, 1.0) var mouse_look_strength : float = 0.15
|
||||
# --------------------
|
||||
|
||||
@export var shake_decay : float = 5.0
|
||||
@export var max_offset : Vector2 = Vector2(10, 10)
|
||||
|
||||
var pixel_material : ShaderMaterial
|
||||
@onready var pixel_material : ShaderMaterial = $Pixelator.material
|
||||
|
||||
var scaling : Vector2
|
||||
var actual_pos : Vector2
|
||||
|
|
@ -22,22 +19,16 @@ var actual_pos : Vector2
|
|||
var shake_trauma : float = 0.0
|
||||
|
||||
func _ready():
|
||||
# Safety check to prevent crash if node is missing
|
||||
if has_node("Pixelator"):
|
||||
pixel_material = get_node("Pixelator").material
|
||||
|
||||
get_viewport().size_changed.connect(_on_viewport_resized)
|
||||
EventBus.player_dmg.connect(_on_player_dmg)
|
||||
EventBus.screenshake.connect(_on_screenshake)
|
||||
|
||||
_on_viewport_resized()
|
||||
|
||||
|
||||
func _fract(x : Vector2) -> Vector2:
|
||||
return x - floor(x)
|
||||
|
||||
func _on_player_dmg():
|
||||
# Apply a default punchy shake when hit
|
||||
add_shake(0.5)
|
||||
|
||||
func _on_screenshake(intensity: float):
|
||||
|
|
@ -47,13 +38,11 @@ func add_shake(amount: float):
|
|||
shake_trauma = clamp(shake_trauma + amount, 0.0, 1.0)
|
||||
|
||||
func _apply_shake():
|
||||
# Squaring trauma makes the shake feel more organic (stronger at start, tapers off)
|
||||
var amount = pow(shake_trauma, 2)
|
||||
var offset = Vector2(
|
||||
var offset := Vector2(
|
||||
max_offset.x * amount * randf_range(-1, 1),
|
||||
max_offset.y * amount * randf_range(-1, 1)
|
||||
)
|
||||
# Apply floor to keep the shake aligned with your pixel grid
|
||||
global_position = floor(actual_pos + offset)
|
||||
|
||||
func _on_viewport_resized():
|
||||
|
|
@ -74,23 +63,17 @@ func _on_viewport_resized():
|
|||
func _process(delta : float):
|
||||
var parent_pos : Vector2 = get_parent().global_position
|
||||
|
||||
# --- NEW MOUSE LOOK LOGIC ---
|
||||
var mouse_pos = get_viewport().get_mouse_position()
|
||||
var vp_size = get_viewport().get_visible_rect().size
|
||||
var center = vp_size / 2.0
|
||||
var mouse_pos := get_viewport().get_mouse_position()
|
||||
var vp_size := get_viewport().get_visible_rect().size
|
||||
var center := vp_size / 2.0
|
||||
|
||||
# Calculate how far mouse is from center
|
||||
var offset_from_center = mouse_pos - center
|
||||
var offset_from_center := mouse_pos - center
|
||||
|
||||
# Apply strength factor
|
||||
offset_from_center *= mouse_look_strength
|
||||
|
||||
# Convert screen pixels to world units by dividing by the current scaling/zoom
|
||||
# (We guard against division by zero just in case)
|
||||
if scaling.x != 0 and scaling.y != 0:
|
||||
var world_offset = offset_from_center / scaling
|
||||
var world_offset := offset_from_center / scaling
|
||||
parent_pos += world_offset
|
||||
# ---------------------------
|
||||
|
||||
var dist := actual_pos.distance_to(parent_pos)
|
||||
var speed : float = max(min_speed, dist * cam_speed) * delta
|
||||
|
|
|
|||
17
scripts/click.gd
Normal file
17
scripts/click.gd
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
extends BaseButton
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
button_down.connect(down)
|
||||
print("button")
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func down() -> void:
|
||||
print("clikced!!")
|
||||
SoundManager.play_sfx("click")
|
||||
1
scripts/click.gd.uid
Normal file
1
scripts/click.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://llka3aa044jo
|
||||
15
scripts/credits.gd
Normal file
15
scripts/credits.gd
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
extends Node2D
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
get_tree().quit()
|
||||
1
scripts/credits.gd.uid
Normal file
1
scripts/credits.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b178407fwlyvs
|
||||
|
|
@ -4,6 +4,8 @@ var lines : Array[String] = []
|
|||
|
||||
func _ready() -> void:
|
||||
EventBus.debug_print.connect(_on_debug_print)
|
||||
EventBus.debug_enable.connect(enable_debug)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
$Label.text = "FPS: " + str(Engine.get_frames_per_second()) + "\n"
|
||||
|
|
@ -16,7 +18,5 @@ func _on_debug_print(msg : String):
|
|||
if len(lines) > 10:
|
||||
lines.pop_front()
|
||||
|
||||
|
||||
func _shortcut_input(event: InputEvent) -> void:
|
||||
if (event.is_action_pressed("debug")):
|
||||
visible = !visible
|
||||
func enable_debug(value : bool):
|
||||
visible = value
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@ extends ColorRect
|
|||
|
||||
func _ready():
|
||||
EventBus.player_dmg.connect(flash_red)
|
||||
|
||||
visible = false
|
||||
color.a = 0
|
||||
|
||||
func flash_red():
|
||||
var tween = create_tween()
|
||||
|
||||
visible = true
|
||||
color.a = 0.3
|
||||
|
||||
tween.tween_property(self, "color:a", 0.0, 0.2).set_trans(Tween.TRANS_SINE)
|
||||
tween.tween_property(self, "visible", false, 0.0);
|
||||
|
|
|
|||
62
scripts/enemy.gd
Normal file
62
scripts/enemy.gd
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
class_name Enemy extends Entity
|
||||
|
||||
@export var attack_charge_time: float = 0.7
|
||||
@export var flee_range: float = 20.0
|
||||
@export var approach_range: float = 100.0
|
||||
|
||||
@onready var nav_agent: NavigationAgent2D = $NavigationAgent2D
|
||||
@onready var sprite = $Anim
|
||||
|
||||
var current_charge: float = 0.0
|
||||
var target_node: Node2D
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group("enemy")
|
||||
nav_agent.velocity_computed.connect(_on_velocity_computed)
|
||||
target_node = get_tree().get_first_node_in_group("player")
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if not target_node: return
|
||||
|
||||
nav_agent.target_position = target_node.global_position
|
||||
var dist = global_position.distance_to(target_node.global_position)
|
||||
var next_path_pos = nav_agent.get_next_path_position()
|
||||
var dir = global_position.direction_to(next_path_pos)
|
||||
|
||||
if dist > approach_range:
|
||||
velocity += dir * move_speed
|
||||
current_charge = 0
|
||||
elif dist < flee_range:
|
||||
velocity -= dir * move_speed
|
||||
current_charge = 0
|
||||
else:
|
||||
_handle_attack_charge(delta)
|
||||
|
||||
sprite.flip_h = target_node.global_position.x > global_position.x
|
||||
scale = Vector2.ONE * (1 + (current_charge * 0.2))
|
||||
|
||||
super._physics_process(delta)
|
||||
|
||||
func _handle_attack_charge(delta):
|
||||
current_charge += delta
|
||||
|
||||
if current_charge >= attack_charge_time:
|
||||
use_mask(target_node.global_position)
|
||||
current_charge = 0
|
||||
|
||||
func _on_velocity_computed(safe_vel: Vector2):
|
||||
velocity = safe_vel
|
||||
|
||||
func knockback():
|
||||
velocity += global_position.direction_to(nav_agent.target_position).normalized() * -2000
|
||||
|
||||
func die():
|
||||
var drop_scene := load("res://scenes/mask_drop.tscn")
|
||||
var drop : MaskDrop = drop_scene.instantiate()
|
||||
drop.mask_type = current_mask_data
|
||||
get_parent().add_child(drop)
|
||||
drop.global_position = global_position
|
||||
|
||||
EventBus.screenshake.emit(10)
|
||||
super.die()
|
||||
queue_free()
|
||||
1
scripts/enemy.gd.uid
Normal file
1
scripts/enemy.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b1t0k6dfubsmk
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
extends GPUParticles2D
|
||||
|
||||
func _ready() -> void:
|
||||
emitting = true
|
||||
|
||||
func _on_finished() -> void:
|
||||
queue_free()
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
extends Node2D
|
||||
|
||||
@export var enemies: Array[PackedScene] # Drag your enemy .tscn here
|
||||
@export var num_circles: int = 3 # How many rings of enemies
|
||||
@export var enemies_per_circle: int = 8 # Base number of enemies
|
||||
@export var radius_step: float = 100.0 # Distance between each ring
|
||||
@export var enemies: Array[PackedScene]
|
||||
@export var num_circles: int = 3
|
||||
@export var enemies_per_circle: int = 8
|
||||
@export var radius_step: float = 100.0
|
||||
@export var initial_radius: float = 150.0
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -11,7 +11,6 @@ func _ready() -> void:
|
|||
|
||||
func spawn_concentric_horde() -> void:
|
||||
for i in range(num_circles):
|
||||
# We calculate the radius for this specific ring
|
||||
var current_radius = initial_radius + (i * radius_step)
|
||||
|
||||
for j in range(enemies_per_circle):
|
||||
|
|
@ -19,7 +18,6 @@ func spawn_concentric_horde() -> void:
|
|||
|
||||
func spawn_enemy_at_random_angle(radius: float) -> void:
|
||||
var random_angle = randf_range(0, 2 * PI)
|
||||
|
||||
|
||||
var spawn_pos = Vector2(
|
||||
radius * cos(random_angle),
|
||||
|
|
|
|||
50
scripts/entity.gd
Normal file
50
scripts/entity.gd
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
class_name Entity extends CharacterBody2D
|
||||
|
||||
signal health_changed(new_amount)
|
||||
signal died
|
||||
|
||||
@export var current_mask_data: MaskData
|
||||
@export var max_health: int = 3
|
||||
@export var move_speed: float = 50.0
|
||||
@export var friction: float = 0.7
|
||||
@export var death_scene : PackedScene
|
||||
|
||||
@onready var health: int = max_health
|
||||
var mask_use_cd = 0
|
||||
|
||||
var can_attack: bool = true
|
||||
|
||||
func use_mask(target : Vector2):
|
||||
if mask_use_cd <= 0:
|
||||
current_mask_data.activate(self, target)
|
||||
mask_use_cd = current_mask_data.cooldown
|
||||
|
||||
func damage(amount: int = 1) -> void:
|
||||
health -= amount
|
||||
health_changed.emit(health)
|
||||
|
||||
_play_hit_flash()
|
||||
|
||||
if health <= 0:
|
||||
die()
|
||||
|
||||
func die():
|
||||
if death_scene:
|
||||
var death : Node2D = death_scene.instantiate()
|
||||
get_parent().add_child(death)
|
||||
death.global_position = global_position
|
||||
died.emit()
|
||||
|
||||
|
||||
func _apply_movement(_delta: float) -> void:
|
||||
velocity *= friction
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
mask_use_cd -= delta
|
||||
_apply_movement(delta)
|
||||
move_and_slide()
|
||||
|
||||
func _play_hit_flash():
|
||||
var tween = create_tween()
|
||||
tween.tween_property(self, "modulate", Color.CRIMSON, 0.1)
|
||||
tween.tween_property(self, "modulate", Color.WHITE, 0.3)
|
||||
1
scripts/entity.gd.uid
Normal file
1
scripts/entity.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bkkqx3tw1tbn2
|
||||
12
scripts/floattt.gd
Normal file
12
scripts/floattt.gd
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
extends Node2D
|
||||
|
||||
@export var float_str = 10.0
|
||||
@export var float_time = 2.0
|
||||
@export var float_offset = -12.0
|
||||
var time = 0
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
time += delta
|
||||
# Calculate the new Y position using a sine wave
|
||||
position.y = sin(time * float_time) * float_str + float_offset
|
||||
1
scripts/floattt.gd.uid
Normal file
1
scripts/floattt.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bhgj68nop1igc
|
||||
|
|
@ -4,8 +4,6 @@ extends TextureRect
|
|||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
EventBus.health_changed.connect(_on_health_changed)
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_health_changed(new : int):
|
||||
texture.region = Rect2(0, new * 32, 0, 32)
|
||||
|
|
|
|||
|
|
@ -14,22 +14,18 @@ func _on_body_entered(body: Node) -> void:
|
|||
print(body)
|
||||
if body is Enemy and from_player:
|
||||
var bname := str(body.name)
|
||||
if body.has_method("hit"):
|
||||
body.hit()
|
||||
onhit.emit()
|
||||
body.knockback()
|
||||
EventBus.debug_print.emit("Hit: " + bname)
|
||||
else:
|
||||
EventBus.debug_print.emit("Hitbox touched " + bname + " but it lacks 'reduce_health' method.")
|
||||
body.damage()
|
||||
onhit.emit()
|
||||
body.knockback()
|
||||
EventBus.debug_print.emit("Hit: " + bname)
|
||||
|
||||
if body is Player and not from_player and not hitplayer:
|
||||
var bname := str(body.name)
|
||||
if body.has_method("hit"):
|
||||
hitplayer = true
|
||||
body.hit()
|
||||
onhit.emit()
|
||||
EventBus.debug_print.emit("Hit: " + bname)
|
||||
else:
|
||||
EventBus.debug_print.emit("Hitbox touched " + bname + " but it lacks 'reduce_health' method.")
|
||||
EventBus.debug_print.emit(str(body))
|
||||
if body is TileMapLayer:
|
||||
hitplayer = true
|
||||
body.damage()
|
||||
onhit.emit()
|
||||
EventBus.debug_print.emit("Hit: " + bname)
|
||||
|
||||
EventBus.debug_print.emit(str(body))
|
||||
if body is StaticBody2D:
|
||||
onhit.emit()
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class_name MagicCircle extends Node2D
|
|||
@export var rot_speed : float = 0.1;
|
||||
@export var line_width : float = 0.6
|
||||
|
||||
var runes : Texture2D = load("res://assets/runes.png");
|
||||
var runes : Texture2D = load("res://assets/vfx/runes.png");
|
||||
|
||||
var rot = 0;
|
||||
var time = 0;
|
||||
|
|
|
|||
39
scripts/mask_data.gd
Normal file
39
scripts/mask_data.gd
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
class_name MaskData extends Resource
|
||||
|
||||
enum MaskType { MELEE, RANGED, SPIT }
|
||||
|
||||
@export_group("Assets")
|
||||
@export var mask_name: String
|
||||
@export var texture: Texture2D
|
||||
@export var drop_texture: Texture2D
|
||||
@export var spawn_sfx : String
|
||||
|
||||
@export_group("Combat")
|
||||
@export var attack_scene: PackedScene
|
||||
@export var cooldown: float = 0.5
|
||||
@export var damage: int = 1
|
||||
@export var is_parented_to_attacker: bool = false
|
||||
|
||||
func activate(attacker: Node2D, target_pos: Vector2) -> void:
|
||||
if not attack_scene:
|
||||
return
|
||||
|
||||
var atk = attack_scene.instantiate()
|
||||
|
||||
if is_parented_to_attacker:
|
||||
attacker.add_child(atk)
|
||||
atk.position = Vector2.ZERO
|
||||
else:
|
||||
attacker.get_parent().add_child(atk)
|
||||
atk.global_position = attacker.global_position
|
||||
|
||||
atk.look_at(target_pos)
|
||||
|
||||
if atk.get("start_position"):
|
||||
atk.start_position = attacker.global_position
|
||||
atk.target_position = target_pos
|
||||
|
||||
if atk.has_method("set_from_player"):
|
||||
atk.set_from_player(attacker.is_in_group("player"))
|
||||
|
||||
SoundManager.play_sfx(spawn_sfx)
|
||||
1
scripts/mask_data.gd.uid
Normal file
1
scripts/mask_data.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c37qcqntd6ofm
|
||||
|
|
@ -1,33 +1,27 @@
|
|||
class_name MaskDrop extends Node2D
|
||||
|
||||
@export var mask_type : Types.mask_types
|
||||
@onready var popup := $Popup
|
||||
@export var mask_type : MaskData
|
||||
@export var time_to_live = 14
|
||||
@export var initial_blink_speed: float = 0.7
|
||||
|
||||
@onready var popup := $Popup
|
||||
@onready var sprite := $Sprite2D
|
||||
@onready var blink_timer = $Timer
|
||||
|
||||
var alive_time = 0
|
||||
var target_position : Vector2
|
||||
@onready var blink_timer = $Timer
|
||||
|
||||
func _ready() -> void:
|
||||
blink_timer.wait_time = initial_blink_speed
|
||||
blink_timer.timeout.connect(_on_timeout)
|
||||
blink_timer.start()
|
||||
blink_timer.paused = true
|
||||
$MeleeMask.rotate(randf() * PI - (PI / 2))
|
||||
$RangedMask.rotate(randf() * PI - (PI / 2))
|
||||
sprite.rotate(randf() * PI - (PI / 2))
|
||||
sprite.rotate(randf() * PI - (PI / 2))
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
alive_time += delta
|
||||
$MeleeMask.visible = false
|
||||
$RangedMask.visible = false
|
||||
$SpitMask.visible = false
|
||||
if (mask_type == Types.mask_types.Melee):
|
||||
$MeleeMask.visible = true
|
||||
elif (mask_type == Types.mask_types.Ranged):
|
||||
$RangedMask.visible = true
|
||||
elif (mask_type == Types.mask_types.Spit):
|
||||
$SpitMask.visible = true
|
||||
sprite.texture = mask_type.drop_texture
|
||||
|
||||
var progress = alive_time / time_to_live
|
||||
if progress > 0.5:
|
||||
|
|
|
|||
104
scripts/player.gd
Normal file
104
scripts/player.gd
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
class_name Player extends Entity
|
||||
|
||||
@export var dash_base_cd: float = 0.7
|
||||
|
||||
@onready var player_sprite :AnimatedSprite2D = $PlayerSprite
|
||||
@onready var mask_sprite : Sprite2D = $PlayerSprite/MaskSprite
|
||||
|
||||
var dash_active := false
|
||||
var dash_cd_timer := 0.0
|
||||
|
||||
var mask_start_time = 10
|
||||
var mask_time_remaining := 15.0
|
||||
|
||||
var closest_mask_drop: MaskDrop
|
||||
var last_mask_drop : MaskDrop
|
||||
const INTERACT_DIST = 60.0
|
||||
|
||||
var dead = false
|
||||
|
||||
func _ready() -> void:
|
||||
health_changed.connect(EventBus.health_changed.emit)
|
||||
health_changed.emit(health)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if dead: return
|
||||
var input_vector := Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||
|
||||
if input_vector != Vector2.ZERO:
|
||||
velocity += input_vector * move_speed
|
||||
|
||||
dash_cd_timer -= delta
|
||||
if Input.is_action_just_pressed("dash") and dash_cd_timer <= 0:
|
||||
start_dash(input_vector)
|
||||
|
||||
_handle_mask_durability(delta)
|
||||
|
||||
_check_items()
|
||||
|
||||
super._physics_process(delta)
|
||||
|
||||
func die():
|
||||
if dead: return
|
||||
super.die()
|
||||
dead = true
|
||||
visible = false
|
||||
|
||||
func revive():
|
||||
if not dead: return
|
||||
dead = false
|
||||
visible = true
|
||||
|
||||
|
||||
func start_dash(dir: Vector2):
|
||||
dash_active = true
|
||||
dash_cd_timer = dash_base_cd
|
||||
velocity += dir * move_speed * 40
|
||||
|
||||
var tween = create_tween()
|
||||
tween.tween_property(player_sprite, "scale:x", 0.5, 0.1)
|
||||
tween.tween_property(player_sprite, "scale:x", 1, 0.1)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("attack") and current_mask_data:
|
||||
use_mask(get_global_mouse_position())
|
||||
|
||||
if event.is_action_pressed("interact") and closest_mask_drop:
|
||||
equip_mask(closest_mask_drop)
|
||||
|
||||
func equip_mask(drop_node : MaskDrop):
|
||||
if drop_node.has_method("collect"):
|
||||
drop_node.collect(global_position)
|
||||
|
||||
current_mask_data = drop_node.mask_type
|
||||
mask_time_remaining = mask_start_time
|
||||
|
||||
mask_sprite.texture = current_mask_data.texture
|
||||
EventBus.mask_changed.emit(current_mask_data.mask_name)
|
||||
|
||||
func _handle_mask_durability(delta : float):
|
||||
if get_tree().get_node_count_in_group("enemy") > 0:
|
||||
mask_time_remaining -= delta
|
||||
if mask_time_remaining <= 0:
|
||||
die()
|
||||
EventBus.mask_time_changed.emit(mask_time_remaining / mask_start_time)
|
||||
|
||||
func _check_items():
|
||||
var masks : Array[Node] = get_tree().get_nodes_in_group("mask")
|
||||
closest_mask_drop = null
|
||||
var min_dist := INF
|
||||
|
||||
for mask : MaskDrop in masks:
|
||||
var dist := global_position.distance_to(mask.global_position)
|
||||
if dist < INTERACT_DIST + 10:
|
||||
min_dist = dist
|
||||
closest_mask_drop = mask
|
||||
|
||||
if last_mask_drop and closest_mask_drop != last_mask_drop:
|
||||
last_mask_drop.hide_popup()
|
||||
last_mask_drop = closest_mask_drop
|
||||
if closest_mask_drop:
|
||||
if min_dist < INTERACT_DIST:
|
||||
closest_mask_drop.show_popup()
|
||||
else:
|
||||
closest_mask_drop.hide_popup()
|
||||
1
scripts/player.gd.uid
Normal file
1
scripts/player.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://sbseykg05177
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
extends Enemy
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
queue_redraw()
|
||||
|
||||
func _draw():
|
||||
if charge > 0.1:
|
||||
var color = Color.RED.lerp(Color.WHITE, charge / charge_time)
|
||||
draw_dashed_line(Vector2.ZERO, to_local(player.global_position), color, 1, 5)
|
||||
if current_charge > 0 and target_node:
|
||||
var color = Color.RED.lerp(Color.WHITE, current_charge / attack_charge_time)
|
||||
draw_dashed_line(Vector2.ZERO, to_local(target_node.global_position), color, 1, 5)
|
||||
|
|
|
|||
4
scripts/screen_particles.gd
Normal file
4
scripts/screen_particles.gd
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
extends GPUParticles2D
|
||||
|
||||
func _ready() -> void:
|
||||
RenderingServer.canvas_item_set_custom_rect(get_canvas_item(), true, get_viewport_rect())
|
||||
1
scripts/screen_particles.gd.uid
Normal file
1
scripts/screen_particles.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cakh44cbphr4s
|
||||
|
|
@ -1,14 +1,13 @@
|
|||
extends NinePatchRect
|
||||
extends Control
|
||||
|
||||
@export var volume_slider : HSlider
|
||||
@export var fullscreen_check : CheckBox
|
||||
@export var vsync_check : CheckBox
|
||||
|
||||
@export var glow_check : CheckBox
|
||||
|
||||
func _ready():
|
||||
_update_settings()
|
||||
|
||||
#Settings.apply_all()
|
||||
|
||||
func _update_settings():
|
||||
volume_slider.value = Settings.master_volume
|
||||
|
|
@ -49,3 +48,7 @@ func _on_exit_button_pressed() -> void:
|
|||
func _on_continue_button_pressed() -> void:
|
||||
visible = false
|
||||
get_tree().paused = visible
|
||||
|
||||
|
||||
func _on_glow_toggled(enabled: bool) -> void:
|
||||
EventBus.change_glow.emit(enabled)
|
||||
|
|
|
|||
26
scripts/singletons/debug.gd
Normal file
26
scripts/singletons/debug.gd
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
extends Node2D
|
||||
|
||||
var debug_enabled = false
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if debug_enabled:
|
||||
var player = get_tree().get_first_node_in_group("player")
|
||||
if player:
|
||||
player.health = player.max_health
|
||||
handle_debug()
|
||||
|
||||
func handle_debug():
|
||||
if Input.is_key_pressed(KEY_1):
|
||||
var player = get_tree().get_first_node_in_group("player")
|
||||
print(player)
|
||||
if player:
|
||||
player.global_position = get_global_mouse_position()
|
||||
if Input.is_key_pressed(KEY_2):
|
||||
EventBus.dialogue_requested.emit("Test dialogue!!")
|
||||
EventBus.dialogue_requested.emit("More dialogue!!")
|
||||
EventBus.dialogue_requested.emit("End dialogue")
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("debug"):
|
||||
debug_enabled = !debug_enabled
|
||||
EventBus.debug_enable.emit(debug_enabled)
|
||||
1
scripts/singletons/debug.gd.uid
Normal file
1
scripts/singletons/debug.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cjtbxjqm1lwb5
|
||||
|
|
@ -2,7 +2,7 @@ extends Node
|
|||
|
||||
signal dialogue_requested(text: String)
|
||||
signal dialogue_finished()
|
||||
signal debug_print(text : String)
|
||||
|
||||
signal mask_changed(new : Types.mask_types)
|
||||
signal mask_uses_changed(new : int)
|
||||
signal health_changed(new : int)
|
||||
|
|
@ -10,3 +10,10 @@ signal player_dmg()
|
|||
signal screenshake(intensity : float)
|
||||
signal mask_time_changed(time : float)
|
||||
signal cut_grass_at(p, r)
|
||||
|
||||
# settings
|
||||
signal change_glow(new : bool)
|
||||
|
||||
# debug
|
||||
signal debug_print(text : String)
|
||||
signal debug_enable(new : bool)
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@ extends Node
|
|||
|
||||
var master_volume: float = 1.0
|
||||
var fullscreen: bool = false
|
||||
var vsync : bool = false
|
||||
var vsync : bool = true
|
||||
var max_fps: int = 60
|
||||
var glow = false
|
||||
|
||||
func apply_volume():
|
||||
var bus_index := AudioServer.get_bus_index("Master")
|
||||
|
|
@ -11,6 +12,9 @@ func apply_volume():
|
|||
bus_index,
|
||||
linear_to_db(master_volume)
|
||||
)
|
||||
|
||||
func apply_bloom():
|
||||
EventBus.change_glow.emit(glow)
|
||||
|
||||
func apply_fullscreen():
|
||||
DisplayServer.window_set_mode(
|
||||
|
|
@ -18,7 +22,7 @@ func apply_fullscreen():
|
|||
else DisplayServer.WINDOW_MODE_WINDOWED
|
||||
)
|
||||
if not fullscreen:
|
||||
get_window().size = Vector2i(480*3, 270*3);
|
||||
get_window().size = Vector2i(640*2, 360*2);
|
||||
|
||||
func apply_vsync():
|
||||
DisplayServer.window_set_vsync_mode(
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
extends Enemy
|
||||
|
||||
func _draw():
|
||||
if charge > 0.1:
|
||||
var color = Color.RED.lerp(Color.WHITE, charge / charge_time)
|
||||
if player:
|
||||
draw_dashed_line(Vector2.ZERO, to_local(player.global_position), color, 1, 5)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
super._process(delta)
|
||||
if (charge > 0.1):
|
||||
$Anim.play("attack")
|
||||
else:
|
||||
$Anim.play("default")
|
||||
#func _draw():
|
||||
#if charge > 0.1:
|
||||
#var color = Color.RED.lerp(Color.WHITE, charge / charge_time)
|
||||
#if player:
|
||||
#draw_dashed_line(Vector2.ZERO, to_local(player.global_position), color, 1, 5)
|
||||
#
|
||||
#func _process(delta: float) -> void:
|
||||
#super._process(delta)
|
||||
#if (charge > 0.1):
|
||||
#$Anim.play("attack")
|
||||
#else:
|
||||
#$Anim.play("default")
|
||||
|
|
|
|||
28
scripts/start_menu.gd
Normal file
28
scripts/start_menu.gd
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
extends Node2D
|
||||
|
||||
@export var settings : Control
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
SoundManager.play_music("title")
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_start_button_pressed() -> void:
|
||||
if !WorldState.done_tuto:
|
||||
WorldState.done_tuto = true
|
||||
SceneTransition.change_scene("res://scenes/tutorial.tscn")
|
||||
else:
|
||||
SceneTransition.change_scene("res://scenes/stage1.tscn")
|
||||
|
||||
|
||||
func _on_settings_pressed() -> void:
|
||||
settings.visible = true
|
||||
|
||||
|
||||
func _on_exit_pressed() -> void:
|
||||
get_tree().quit()
|
||||
1
scripts/start_menu.gd.uid
Normal file
1
scripts/start_menu.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://nf16c5x6khy6
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
extends Node2D
|
||||
|
||||
|
||||
@onready var player : Player = get_tree().get_first_node_in_group("player")
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
|
@ -8,8 +8,6 @@ func _ready() -> void:
|
|||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
var player = get_tree().get_first_node_in_group("player")
|
||||
if player:
|
||||
if player.global_position.distance_to(global_position) > 600:
|
||||
player.hit()
|
||||
pass
|
||||
player.damage()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue