2022 demo

This commit is contained in:
pennyrigate 2022-12-31 21:47:38 -05:00
parent c60375cb98
commit 4727fb0f55
41 changed files with 761 additions and 68 deletions

View file

@ -24,8 +24,11 @@ var jump_force = 150
var doublejump_force = 120
var current_ladder = null #Used for checking climbing every frame instead of area entered
var can_doublejump = true
var can_move_in_air = false
#Positions
var arrowpos = Vector2(5,3)
#Tiles
onready var deathtiles = map.get_node("Death")
##Preload
var pre_arrow = preload("res://objects/player/arrow_projectile.tscn")
@ -95,8 +98,9 @@ func _process_walk():
collision.get_collider().push(collision.normal)
func _process_idle_walk():
can_doublejump = false
can_move_in_air = false
velocity.y = 0
can_doublejump = true
#Goto Fall
if !is_on_floor(): current_state = State.FALL
#Goto Jump
@ -123,6 +127,8 @@ func _process_fall():
if is_on_floor():
current_state = State.IDLE
return
#Cant move in air
if !can_move_in_air: velocity.x = 0
func _process_jump_fall():
check_double_jump()
@ -131,6 +137,7 @@ func _process_jump_fall():
check_shoot()
func _process_climb():
can_move_in_air = true
can_doublejump = true
#Graphics
anims.play("climb")
@ -184,6 +191,8 @@ func check_jump():
position.x -= sprite.scale.x * 5
anims.set_speed_scale(1)
# Jump
can_doublejump = true
can_move_in_air = true
velocity.y = 0
jump_pressure = 0
current_state = State.JUMP
@ -209,9 +218,10 @@ func check_shoot():
anims.play("shoot air") #Shoot immediately in air
func move(hsp,vsp,flip:bool):
velocity.x = hsp * axis.x
#Flip
if flip: if sign(axis.x) != 0: sprite.scale.x = axis.x
if is_on_floor() or can_move_in_air:
velocity.x = hsp * axis.x
#Flip
if flip: if sign(axis.x) != 0: sprite.scale.x = axis.x
func check_ladder():
if climb_ray.get_collider() != null:
@ -231,7 +241,20 @@ func check_ladder():
climb_ray.position.x = 4 * sprite.scale.x
func die():
get_tree().reload_current_scene()
position = Game.respawn_point
Game.lives -= 1
Game.play_sound(Game.a_die,Game.ac_die)
if Game.lives < 0:
if Game.score > Game.high_score: Game.high_score = Game.score
Game.score = 0
Game.golds = 0
Game.stars = [false,false,false,false,false]
Game.shards = 0
Game.arrows = 0
Game.lives = 2
Game.ac_climb.stop()
get_tree().reload_current_scene()
func _on_AnimationPlayer_animation_finished(anim_name):
#Return to idle after slash
@ -255,3 +278,4 @@ func debug():
if Input.is_action_pressed("debug_move_player"):
position = get_viewport().get_mouse_position()
print(get_viewport().get_mouse_position())