chicken man

This commit is contained in:
Haze Weathers 2024-02-03 02:02:25 -05:00
parent a7f5ad6db2
commit 63b24cb614
9 changed files with 1469 additions and 97 deletions

View file

@ -46,6 +46,7 @@ const a_land = preload("res://audio/sounds/land.ogg")
const a_teleport = preload("res://audio/sounds/teleport.ogg")
const a_mkey = preload("res://audio/sounds/mkey.ogg")
const a_msx_die = preload("res://audio/sounds/msx_die.ogg")
const a_famira = preload("res://audio/sounds/famira.ogg")
var loop_section = null
var has_looped = false

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 B

After

Width:  |  Height:  |  Size: 4.1 KiB

Before After
Before After

View file

@ -17,6 +17,7 @@ tile_data = PoolIntArray( 1507297, 0, 1, 1507298, 0, 2, 1507299, 0, 2, 1507300,
[node name="2083" parent="." instance=ExtResource( 1 )]
position = Vector2( 0, 8 )
famira_path = NodePath("../Famira")
[node name="Camera2D" type="Camera2D" parent="2083"]
offset = Vector2( 0, -8 )
@ -24,4 +25,5 @@ anchor_mode = 0
current = true
[node name="Famira" parent="." instance=ExtResource( 4 )]
position = Vector2( 278, 176 )
position = Vector2( 185, 176 )
sg2083_path = NodePath("../2083")

View file

@ -1,84 +1,87 @@
extends Node2D
export var decisions: Dictionary = {
"wait": 2,
"chase": 3,
"punch": 3,
"beam": 1,
}
export var wait_time: float = 1.0
export var chase_speed: float = 50.0
export var push_speed: float = 60.0
export var chase_speed: float = 40.0
export var breath_dps: float = 50.0
export var punch_damage: float = 10.0
export var hurting: bool = false
export var sg2083_path: NodePath
var rng := RandomNumberGenerator.new()
var current_action: String = "wait"
onready var punch_cast: RayCast2D = $PunchCast
onready var chase_cast: RayCast2D = $ChaseCast
func _ready() -> void:
rng.seed = "HEROMARK2".hash()
_decide_action()
onready var animation_player: AnimationPlayer = $"%AnimationPlayer"
onready var state_chart: Node = $StateChart
onready var in_range_cast: RayCast2D = $InRangeCast
onready var out_range_cast: RayCast2D = $OutRangeCast
onready var shoot_range_cast: RayCast2D = $ShootRangeCast
func _physics_process(delta: float) -> void:
match current_action:
"chase":
if chase_cast.is_colliding():
print("huh")
_decide_action()
else:
print("hehe")
position.x -= chase_speed * delta
if not out_range_cast.is_colliding():
state_chart.send_event("out_of_range")
elif in_range_cast.is_colliding():
state_chart.send_event("in_range")
func _decide_action() -> void:
# fill array based on weights
var weighted_decisions := []
for k in decisions.keys():
for i in decisions[k]:
weighted_decisions.append(k)
# choose an action
current_action = weighted_decisions[rng.randi() % weighted_decisions.size()]
# act based on new action
match current_action:
"wait":
wait()
"chase":
chase()
"punch":
if punch_cast.is_colliding():
punch()
else:
current_action = "chase"
chase()
"beam":
beam()
func start_push() -> void:
state_chart.send_event("start_push")
func wait() -> void:
print("waiting")
yield(get_tree().create_timer(wait_time, false), "timeout")
_decide_action()
func stop_push() -> void:
state_chart.send_event("stop_push")
func chase() -> void:
# TODO: play animation
print("chasing")
func _attack() -> void:
var sg2083 := get_node(sg2083_path)
if sg2083.has_method("hurt"):
sg2083.hurt(punch_damage)
func punch() -> void:
# TODO: play animation
print("PUNCH")
yield(get_tree().create_timer(wait_time, false), "timeout")
_decide_action()
func _on_Roar_state_entered() -> void:
animation_player.play("roar", 0.25)
Audio.play_sound(Audio.a_famira, Audio.ac_boss)
func beam() -> void:
# TODO: play animation and stuff
print("BEAM")
yield(get_tree().create_timer(wait_time, false), "timeout")
_decide_action()
func _on_Chasing_state_entered() -> void:
animation_player.play("chasing", 0.25)
func _on_Punching_state_entered() -> void:
animation_player.play("punching", 0.25)
func _on_PunchCooldown_state_entered() -> void:
animation_player.play("RESET", 0.5)
func _on_Shooting_state_entered() -> void:
animation_player.play("shooting")
func _on_PushedBack_state_entered() -> void:
animation_player.play("pushed", 0.25)
func _on_Dying_state_entered() -> void:
queue_free()
func _on_PushedBack_event_received(event) -> void:
print(event)
func _on_Chasing_state_physics_processing(delta) -> void:
position.x -= chase_speed * delta
func _on_PushedBack_state_physics_processing(delta) -> void:
position.x += push_speed * delta
func _on_Shooting_state_physics_processing(delta) -> void:
if hurting and shoot_range_cast.is_colliding():
var sg2083 := get_node(sg2083_path)
if sg2083.has_method("hurt"):
var distance := shoot_range_cast.to_local(shoot_range_cast.get_collision_point()).x
var weight := inverse_lerp(shoot_range_cast.cast_to.x, 0.0, distance)
sg2083.hurt(breath_dps * weight * delta, true)

File diff suppressed because it is too large Load diff

View file

@ -1,17 +1,19 @@
extends Node2D
enum State {STAND, FORWARD, BACK, DUCK, BEAM}
enum State {STAND, FORWARD, BACK, DUCK, BEAM, DEAD}
const Bullet = preload("res://objects/enemy/2600_bullet.tscn")
const SmallExplosion = preload("res://objects/enemy/boss/2600_small_explosion.tscn")
export var hp: float = 100.0
export var shot_speed: float = 50.0
export var move_speed: float = 30.0
export var safe_from_breath: bool = false
export var make_explosions: bool = false
export var explosion_rect: Rect2
export var famira_path: NodePath
var state: int = State.STAND
@ -24,6 +26,8 @@ onready var head_sprite = $"%Head"
func _physics_process(delta: float) -> void:
match state:
State.DEAD:
return
State.STAND:
if Input.is_action_pressed("move_down"):
state = State.DUCK
@ -44,17 +48,16 @@ func _physics_process(delta: float) -> void:
func _input(event: InputEvent) -> void:
if state == State.DEAD:
return
if event.is_action_pressed("shoot") and (state == State.STAND or state == State.FORWARD or state == State.BACK):
shoot()
if event.is_action_pressed("jump") and state == State.STAND:
beam()
if event.is_action_pressed("move_up"):
anims.play("die")
func shoot() -> void:
Audio.play_sound(Audio.a_bullet_barrage,Audio.ac_boss)
Audio.play_sound(Audio.a_bullet_barrage,Audio.ac_collectible)
for pos in bullet_positions.get_children():
var bullet = Bullet.instance()
bullet.global_position = pos.global_position
@ -68,18 +71,32 @@ func beam() -> void:
anims.play("Beam")
func hurt(amount: float, can_duck: bool = false) -> void:
if can_duck and state == State.DUCK:
return
hp -= amount
if state != State.DEAD and hp <= 0.0:
state = State.DEAD
anims.play("die")
func _play_laser_sound(play: bool):
var famira = get_node(famira_path)
if play:
Audio.play_sound(Audio.a_rainbow_laser,Audio.ac_boss)
if famira.has_method("start_push"):
famira.start_push()
Audio.play_sound(Audio.a_rainbow_laser,Audio.ac_collectible)
else:
Audio.ac_boss.playing = false
if famira.has_method("stop_push"):
famira.stop_push()
Audio.ac_collectible.playing = false
func _play_charge_sound(play: bool):
if play:
Audio.play_sound(Audio.a_2600_charge,Audio.ac_boss)
Audio.play_sound(Audio.a_2600_charge,Audio.ac_collectible)
else:
Audio.ac_boss.playing = false
Audio.ac_collectible.playing = false
func _spawn_explosions() -> void:
@ -106,3 +123,5 @@ func _on_animation_finished(anim_name: String) -> void:
state = State.STAND
"Beam":
state = State.STAND
"die":
pass

View file

@ -1292,7 +1292,7 @@ tracks/1/keys = {
}
[sub_resource type="RectangleShape2D" id=26]
extents = Vector2( 33.5, 76 )
extents = Vector2( 42, 76 )
[node name="2083" type="Node2D"]
z_index = 5
@ -1644,7 +1644,7 @@ collision_mask = 0
monitoring = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="DetectionBox"]
position = Vector2( 53.5, 92 )
position = Vector2( 62, 92 )
shape = SubResource( 26 )
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_animation_finished"]

View file

@ -14,6 +14,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://addons/godot_state_charts/atomic_state.gd"
}, {
"base": "Node2D",
"class": "BallSnake",
"language": "GDScript",
"path": "res://scripts/ball_snake.gd"
}, {
"base": "State",
"class": "CompoundState",
"language": "GDScript",
@ -56,6 +61,7 @@ _global_script_classes=[ {
} ]
_global_script_class_icons={
"AtomicState": "res://addons/godot_state_charts/atomic_state.svg",
"BallSnake": "",
"CompoundState": "res://addons/godot_state_charts/compound_state.svg",
"LevelEntry": "",
"ParallelState": "res://addons/godot_state_charts/parallel_state.svg",

29
scripts/ball_snake.gd Normal file
View file

@ -0,0 +1,29 @@
tool
class_name BallSnake
extends Node2D
export var texture: Texture
export var segments: int = 1
export var target: NodePath
export var end_pieces: bool = true
func _process(delta: float) -> void:
update()
func _draw() -> void:
var node := get_node(target) as Node2D
if node:
if end_pieces:
draw_texture(texture, texture.get_size() * -0.5)
var end_pos := to_local(node.global_position)
for i in segments:
var weight := 1.0 / float(segments + 1) * float(i + 1)
draw_texture(
texture,
lerp(Vector2.ZERO, end_pos, weight) + texture.get_size() * -0.5
)
if end_pieces:
draw_texture(texture, end_pos + texture.get_size() * -0.5)