-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
67 changed files
with
386 additions
and
141 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
6 changes: 5 additions & 1 deletion
6
godot/shared/FrameFreeze.gd → godot/src/base-system/FrameFreeze.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
class_name FrameFreeze | ||
extends Node | ||
|
||
func freeze(time_scale: float, duration: float): | ||
@export var time_scale := 0.05 | ||
@export var duration := 0.5 | ||
|
||
func freeze(): | ||
Engine.time_scale = time_scale | ||
await get_tree().create_timer(duration * time_scale).timeout | ||
Engine.time_scale = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extends Area2D | ||
|
||
@export var node: Node | ||
|
||
func _ready(): | ||
area_entered.connect(func(_a): node.queue_free()) | ||
body_entered.connect(func(_a): node.queue_free()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class_name FreeOnExit | ||
extends VisibleOnScreenNotifier2D | ||
|
||
@export var node: Node | ||
|
||
func _ready(): | ||
if node: | ||
screen_exited.connect(func(): node.queue_free()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class_name FreeOnFinish | ||
extends AnimatedSprite2D | ||
|
||
func _ready(): | ||
animation_finished.connect(func(): queue_free()) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class_name OneShotParticles | ||
extends GPUParticles2D | ||
|
||
signal finished() | ||
|
||
@export var wait_time := -1.0 | ||
@onready var time := lifetime if wait_time < 0 else wait_time | ||
|
||
func _ready(): | ||
emitting = true | ||
get_tree().create_timer(time).timeout.connect(func(): | ||
finished.emit() | ||
queue_free() | ||
) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../addons/base-system/menu/RemapButton.tscn → godot/src/base-system/menu/RemapButton.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class_name BulletController | ||
extends CharacterController | ||
|
||
@export var dir := Vector2.RIGHT | ||
|
||
func get_motion(): | ||
return dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class_name CharacterController | ||
extends Node2D | ||
|
||
func get_motion(): | ||
return Vector2.ZERO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class_name TargetController | ||
extends CharacterController | ||
|
||
@export var node: Node2D | ||
|
||
func get_motion(): | ||
return global_position.direction_to(node.global_position) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
extends Node | ||
|
||
@export var ctrl: CharacterController | ||
@export var speed_value: ValueProvider | ||
@export var speed := 300 | ||
@export var accel := 900 | ||
|
||
@export var debug := false | ||
|
||
var _logger := Logger.new("TopDownMove2D") | ||
|
||
func move(velocity: Vector2, delta: float): | ||
var motion = Vector2.ZERO | ||
if ctrl: | ||
motion = ctrl.get_motion() | ||
|
||
if debug: | ||
_logger.debug("Moving to %s" % motion) | ||
|
||
var s = _get_speed() | ||
return velocity.move_toward(motion * s, accel * delta) | ||
|
||
func _get_speed(): | ||
return speed_value.get_value() if speed_value else speed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class_name TopDownPlayerController | ||
extends CharacterController | ||
|
||
@export var input: PlayerInput | ||
|
||
func get_motion(): | ||
var motion_x = input.get_action_strength("move_right") - input.get_action_strength("move_left") | ||
var motion_y = input.get_action_strength("move_down") - input.get_action_strength("move_up") | ||
return Vector2(motion_x, motion_y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class_name DelayedDamage | ||
extends Timer | ||
|
||
@export var health: Health | ||
@export var damage := 1 | ||
|
||
func _ready(): | ||
timeout.connect(func(): | ||
if health: | ||
health.hurt(damage) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class_name HitBox | ||
extends Area2D | ||
|
||
@export var damage := 1 | ||
@export var damage_value: NumberValue | ||
@export var knockback_force := 0 | ||
|
||
func _ready(): | ||
area_entered.connect(func(area): | ||
if area is HurtBox: | ||
_do_damage(area) | ||
) | ||
|
||
func _do_damage(area: HurtBox): | ||
var dmg = damage_value.get_value() if damage_value else damage | ||
var knockback_dir = global_position.direction_to(area.global_position) | ||
return area.damage(dmg, knockback_dir * knockback_force) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class_name HitFlash2D | ||
extends Node | ||
|
||
@export var time := 0.1 | ||
@export var node: Node2D | ||
|
||
func flash(): | ||
if node and node.material: | ||
var mat = node.material as ShaderMaterial | ||
_set_hit_flash(mat, true) | ||
await get_tree().create_timer(time).timeout | ||
_set_hit_flash(mat, false) | ||
|
||
func reset(): | ||
if node: | ||
_set_hit_flash(node.material, false) | ||
|
||
func _set_hit_flash(mat: ShaderMaterial, enable: bool): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
class_name HurtBox | ||
extends Area2D | ||
|
||
@export var health: Health | ||
@export var hit_sound: AudioStreamPlayer | ||
@export var frame_freeze: FrameFreeze | ||
@export var hit_flash: HitFlash2D | ||
|
||
@export var invincible_time := 0.0 | ||
|
||
signal hit(dmg) | ||
signal knockback(dir) | ||
|
||
var invincible := false | ||
|
||
func damage(dmg: int, knockback_force: Vector2): | ||
if invincible: | ||
return false | ||
|
||
invincible = true | ||
hit.emit(dmg) | ||
if knockback_force: | ||
knockback.emit(knockback_force) | ||
|
||
if health: | ||
health.hurt(dmg) | ||
if hit_sound: | ||
hit_sound.play() | ||
if hit_flash: | ||
hit_flash.flash() | ||
if frame_freeze and not health.is_dead(): | ||
frame_freeze.freeze() | ||
|
||
get_tree().create_timer(invincible_time).timeout.connect(func(): invincible = false) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
class_name Health | ||
extends Node | ||
|
||
signal health_changed(hp) | ||
signal zero_health() | ||
|
||
@export var max_health_value: ValueProvider | ||
@export var max_health := 1 | ||
@onready var health := max_health : set = _set_health | ||
|
||
func hurt(dmg: int): | ||
self.health -= dmg | ||
|
||
func heal(amount: int): | ||
self.health += amount | ||
|
||
func _get_max_health(): | ||
return max_health_value.get_value() if max_health_value else max_health | ||
|
||
func _set_health(v: int): | ||
health = clamp(v, 0, max_health) | ||
health_changed.emit(health) | ||
|
||
if is_dead(): | ||
zero_health.emit() | ||
|
||
func is_full_health(): | ||
return health == max_health | ||
|
||
func is_dead(): | ||
return health <= 0 | ||
|
||
func get_health_percent(): | ||
return float(health) / float(max_health) |
Oops, something went wrong.