forked from team-sg/hero-mark-2
chicken man
This commit is contained in:
parent
a7f5ad6db2
commit
63b24cb614
9 changed files with 1469 additions and 97 deletions
|
@ -46,6 +46,7 @@ const a_land = preload("res://audio/sounds/land.ogg")
|
||||||
const a_teleport = preload("res://audio/sounds/teleport.ogg")
|
const a_teleport = preload("res://audio/sounds/teleport.ogg")
|
||||||
const a_mkey = preload("res://audio/sounds/mkey.ogg")
|
const a_mkey = preload("res://audio/sounds/mkey.ogg")
|
||||||
const a_msx_die = preload("res://audio/sounds/msx_die.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 loop_section = null
|
||||||
var has_looped = false
|
var has_looped = false
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 159 B After Width: | Height: | Size: 4.1 KiB |
|
@ -17,6 +17,7 @@ tile_data = PoolIntArray( 1507297, 0, 1, 1507298, 0, 2, 1507299, 0, 2, 1507300,
|
||||||
|
|
||||||
[node name="2083" parent="." instance=ExtResource( 1 )]
|
[node name="2083" parent="." instance=ExtResource( 1 )]
|
||||||
position = Vector2( 0, 8 )
|
position = Vector2( 0, 8 )
|
||||||
|
famira_path = NodePath("../Famira")
|
||||||
|
|
||||||
[node name="Camera2D" type="Camera2D" parent="2083"]
|
[node name="Camera2D" type="Camera2D" parent="2083"]
|
||||||
offset = Vector2( 0, -8 )
|
offset = Vector2( 0, -8 )
|
||||||
|
@ -24,4 +25,5 @@ anchor_mode = 0
|
||||||
current = true
|
current = true
|
||||||
|
|
||||||
[node name="Famira" parent="." instance=ExtResource( 4 )]
|
[node name="Famira" parent="." instance=ExtResource( 4 )]
|
||||||
position = Vector2( 278, 176 )
|
position = Vector2( 185, 176 )
|
||||||
|
sg2083_path = NodePath("../2083")
|
||||||
|
|
|
@ -1,84 +1,87 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
export var decisions: Dictionary = {
|
export var push_speed: float = 60.0
|
||||||
"wait": 2,
|
export var chase_speed: float = 40.0
|
||||||
"chase": 3,
|
export var breath_dps: float = 50.0
|
||||||
"punch": 3,
|
export var punch_damage: float = 10.0
|
||||||
"beam": 1,
|
export var hurting: bool = false
|
||||||
}
|
export var sg2083_path: NodePath
|
||||||
export var wait_time: float = 1.0
|
|
||||||
export var chase_speed: float = 50.0
|
|
||||||
|
|
||||||
|
|
||||||
var rng := RandomNumberGenerator.new()
|
onready var animation_player: AnimationPlayer = $"%AnimationPlayer"
|
||||||
var current_action: String = "wait"
|
onready var state_chart: Node = $StateChart
|
||||||
|
onready var in_range_cast: RayCast2D = $InRangeCast
|
||||||
|
onready var out_range_cast: RayCast2D = $OutRangeCast
|
||||||
onready var punch_cast: RayCast2D = $PunchCast
|
onready var shoot_range_cast: RayCast2D = $ShootRangeCast
|
||||||
onready var chase_cast: RayCast2D = $ChaseCast
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
rng.seed = "HEROMARK2".hash()
|
|
||||||
_decide_action()
|
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
match current_action:
|
if not out_range_cast.is_colliding():
|
||||||
"chase":
|
state_chart.send_event("out_of_range")
|
||||||
if chase_cast.is_colliding():
|
elif in_range_cast.is_colliding():
|
||||||
print("huh")
|
state_chart.send_event("in_range")
|
||||||
_decide_action()
|
|
||||||
else:
|
|
||||||
print("hehe")
|
|
||||||
position.x -= chase_speed * delta
|
|
||||||
|
|
||||||
|
|
||||||
func _decide_action() -> void:
|
func start_push() -> void:
|
||||||
# fill array based on weights
|
state_chart.send_event("start_push")
|
||||||
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 wait() -> void:
|
func stop_push() -> void:
|
||||||
print("waiting")
|
state_chart.send_event("stop_push")
|
||||||
yield(get_tree().create_timer(wait_time, false), "timeout")
|
|
||||||
_decide_action()
|
|
||||||
|
|
||||||
|
|
||||||
func chase() -> void:
|
func _attack() -> void:
|
||||||
# TODO: play animation
|
var sg2083 := get_node(sg2083_path)
|
||||||
print("chasing")
|
if sg2083.has_method("hurt"):
|
||||||
|
sg2083.hurt(punch_damage)
|
||||||
|
|
||||||
|
|
||||||
func punch() -> void:
|
func _on_Roar_state_entered() -> void:
|
||||||
# TODO: play animation
|
animation_player.play("roar", 0.25)
|
||||||
print("PUNCH")
|
Audio.play_sound(Audio.a_famira, Audio.ac_boss)
|
||||||
yield(get_tree().create_timer(wait_time, false), "timeout")
|
|
||||||
_decide_action()
|
|
||||||
|
|
||||||
|
|
||||||
func beam() -> void:
|
func _on_Chasing_state_entered() -> void:
|
||||||
# TODO: play animation and stuff
|
animation_player.play("chasing", 0.25)
|
||||||
print("BEAM")
|
|
||||||
yield(get_tree().create_timer(wait_time, false), "timeout")
|
|
||||||
_decide_action()
|
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
|
@ -1,17 +1,19 @@
|
||||||
extends Node2D
|
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 Bullet = preload("res://objects/enemy/2600_bullet.tscn")
|
||||||
const SmallExplosion = preload("res://objects/enemy/boss/2600_small_explosion.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 shot_speed: float = 50.0
|
||||||
export var move_speed: float = 30.0
|
export var move_speed: float = 30.0
|
||||||
export var safe_from_breath: bool = false
|
export var safe_from_breath: bool = false
|
||||||
export var make_explosions: bool = false
|
export var make_explosions: bool = false
|
||||||
export var explosion_rect: Rect2
|
export var explosion_rect: Rect2
|
||||||
|
export var famira_path: NodePath
|
||||||
|
|
||||||
|
|
||||||
var state: int = State.STAND
|
var state: int = State.STAND
|
||||||
|
@ -24,6 +26,8 @@ onready var head_sprite = $"%Head"
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
match state:
|
match state:
|
||||||
|
State.DEAD:
|
||||||
|
return
|
||||||
State.STAND:
|
State.STAND:
|
||||||
if Input.is_action_pressed("move_down"):
|
if Input.is_action_pressed("move_down"):
|
||||||
state = State.DUCK
|
state = State.DUCK
|
||||||
|
@ -44,17 +48,16 @@ func _physics_process(delta: float) -> void:
|
||||||
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> 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):
|
if event.is_action_pressed("shoot") and (state == State.STAND or state == State.FORWARD or state == State.BACK):
|
||||||
shoot()
|
shoot()
|
||||||
if event.is_action_pressed("jump") and state == State.STAND:
|
if event.is_action_pressed("jump") and state == State.STAND:
|
||||||
beam()
|
beam()
|
||||||
if event.is_action_pressed("move_up"):
|
|
||||||
anims.play("die")
|
|
||||||
|
|
||||||
|
|
||||||
func shoot() -> void:
|
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():
|
for pos in bullet_positions.get_children():
|
||||||
var bullet = Bullet.instance()
|
var bullet = Bullet.instance()
|
||||||
bullet.global_position = pos.global_position
|
bullet.global_position = pos.global_position
|
||||||
|
@ -68,18 +71,32 @@ func beam() -> void:
|
||||||
anims.play("Beam")
|
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):
|
func _play_laser_sound(play: bool):
|
||||||
|
var famira = get_node(famira_path)
|
||||||
if play:
|
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:
|
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):
|
func _play_charge_sound(play: bool):
|
||||||
if play:
|
if play:
|
||||||
Audio.play_sound(Audio.a_2600_charge,Audio.ac_boss)
|
Audio.play_sound(Audio.a_2600_charge,Audio.ac_collectible)
|
||||||
else:
|
else:
|
||||||
Audio.ac_boss.playing = false
|
Audio.ac_collectible.playing = false
|
||||||
|
|
||||||
|
|
||||||
func _spawn_explosions() -> void:
|
func _spawn_explosions() -> void:
|
||||||
|
@ -106,3 +123,5 @@ func _on_animation_finished(anim_name: String) -> void:
|
||||||
state = State.STAND
|
state = State.STAND
|
||||||
"Beam":
|
"Beam":
|
||||||
state = State.STAND
|
state = State.STAND
|
||||||
|
"die":
|
||||||
|
pass
|
||||||
|
|
|
@ -1292,7 +1292,7 @@ tracks/1/keys = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=26]
|
[sub_resource type="RectangleShape2D" id=26]
|
||||||
extents = Vector2( 33.5, 76 )
|
extents = Vector2( 42, 76 )
|
||||||
|
|
||||||
[node name="2083" type="Node2D"]
|
[node name="2083" type="Node2D"]
|
||||||
z_index = 5
|
z_index = 5
|
||||||
|
@ -1644,7 +1644,7 @@ collision_mask = 0
|
||||||
monitoring = false
|
monitoring = false
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="DetectionBox"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="DetectionBox"]
|
||||||
position = Vector2( 53.5, 92 )
|
position = Vector2( 62, 92 )
|
||||||
shape = SubResource( 26 )
|
shape = SubResource( 26 )
|
||||||
|
|
||||||
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_animation_finished"]
|
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_animation_finished"]
|
||||||
|
|
|
@ -14,6 +14,11 @@ _global_script_classes=[ {
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/godot_state_charts/atomic_state.gd"
|
"path": "res://addons/godot_state_charts/atomic_state.gd"
|
||||||
}, {
|
}, {
|
||||||
|
"base": "Node2D",
|
||||||
|
"class": "BallSnake",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://scripts/ball_snake.gd"
|
||||||
|
}, {
|
||||||
"base": "State",
|
"base": "State",
|
||||||
"class": "CompoundState",
|
"class": "CompoundState",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
|
@ -56,6 +61,7 @@ _global_script_classes=[ {
|
||||||
} ]
|
} ]
|
||||||
_global_script_class_icons={
|
_global_script_class_icons={
|
||||||
"AtomicState": "res://addons/godot_state_charts/atomic_state.svg",
|
"AtomicState": "res://addons/godot_state_charts/atomic_state.svg",
|
||||||
|
"BallSnake": "",
|
||||||
"CompoundState": "res://addons/godot_state_charts/compound_state.svg",
|
"CompoundState": "res://addons/godot_state_charts/compound_state.svg",
|
||||||
"LevelEntry": "",
|
"LevelEntry": "",
|
||||||
"ParallelState": "res://addons/godot_state_charts/parallel_state.svg",
|
"ParallelState": "res://addons/godot_state_charts/parallel_state.svg",
|
||||||
|
|
29
scripts/ball_snake.gd
Normal file
29
scripts/ball_snake.gd
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue