initial work on sg2083 controls

This commit is contained in:
Haze Weathers 2023-11-06 15:40:07 -05:00
parent 69d6a4b4f7
commit b0bb26a81b
2 changed files with 716 additions and 396 deletions

View file

@ -1,20 +1,59 @@
extends Node2D
const Bullet = preload("res://objects/enemy/2600_bullet.tscn")
export var shot_speed: float = 50
export var fire_rate: float = 1
enum State {STAND, FORWARD, BACK, DUCK, BEAM}
const Bullet = preload("res://objects/enemy/2600_bullet.tscn")
const SmallExplosion = preload("res://objects/enemy/boss/2600_small_explosion.tscn")
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
var state: int = State.STAND
onready var bullet_positions = $"%BulletPositions"
onready var shoot_timer = $ShootTimer
onready var anims = $AnimationPlayer
onready var anims: AnimationPlayer = $"%AnimationPlayer"
onready var head_sprite = $"%Head"
func _input(event):
if Input.is_action_pressed("shoot"):
shoot()
func shoot():
func _physics_process(delta: float) -> void:
match state:
State.STAND:
if Input.is_action_pressed("move_down"):
state = State.DUCK
anims.play("Duck")
elif Input.is_action_pressed("move_right"):
state = State.FORWARD
anims.play("Walk")
elif Input.is_action_pressed("move_left"):
state = State.BACK
anims.play("Walk", -1.0, -1.0, true)
State.DUCK:
if not Input.is_action_pressed("move_down") and anims.current_animation.empty():
anims.play("UnDuck")
State.FORWARD:
position.x += move_speed * delta
State.BACK:
position.x -= move_speed * delta
func _input(event: InputEvent) -> void:
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)
for pos in bullet_positions.get_children():
var bullet = Bullet.instance()
@ -22,4 +61,48 @@ func shoot():
bullet.direction = Vector2.LEFT.rotated(pos.rotation)
bullet.speed = shot_speed
get_parent().add_child(bullet)
shoot_timer.wait_time = fire_rate
func beam() -> void:
state = State.BEAM
anims.play("Beam")
func _play_laser_sound(play: bool):
if play:
Audio.play_sound(Audio.a_rainbow_laser,Audio.ac_boss)
else:
Audio.ac_boss.playing = false
func _play_charge_sound(play: bool):
if play:
Audio.play_sound(Audio.a_2600_charge,Audio.ac_boss)
else:
Audio.ac_boss.playing = false
func _spawn_explosions() -> void:
while make_explosions:
yield(get_tree().create_timer(randf() * 0.5, false), "timeout")
var explosion = SmallExplosion.instance()
explosion.position = Vector2(
rand_range(explosion_rect.position.x, explosion_rect.end.x),
rand_range(explosion_rect.position.y, explosion_rect.end.y)
)
add_child(explosion)
func _on_animation_finished(anim_name: String) -> void:
match anim_name:
"UnDuck":
state = State.STAND
"Walk":
if state == State.FORWARD and Input.is_action_pressed("move_right"):
anims.play("Walk")
elif state == State.BACK and Input.is_action_pressed("move_left"):
anims.play("Walk", -1.0, -1.0, true)
else:
state = State.STAND
"Beam":
state = State.STAND

File diff suppressed because it is too large Load diff