completed l4 win condition
This commit is contained in:
@@ -10,49 +10,49 @@ var counter: int = 0
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
velocity = Vector2.ZERO
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
if player and position.distance_to(player.position) > 1:
|
||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||
if player and position.distance_to(player.position) > 1:
|
||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||
|
||||
|
||||
if hit == true:
|
||||
if counter < 15:
|
||||
if counter % 5 == 0:
|
||||
$AnimatedSprite.visible = false
|
||||
else:
|
||||
$AnimatedSprite.visible = true
|
||||
counter += 1
|
||||
velocity = Vector2.ZERO
|
||||
else:
|
||||
counter = 0
|
||||
hit = false
|
||||
if hit == true:
|
||||
if counter < 15:
|
||||
if counter % 5 == 0:
|
||||
$AnimatedSprite.visible = false
|
||||
else:
|
||||
$AnimatedSprite.visible = true
|
||||
counter += 1
|
||||
velocity = Vector2.ZERO
|
||||
else:
|
||||
counter = 0
|
||||
hit = false
|
||||
|
||||
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
return
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_body_exited(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = null
|
||||
return
|
||||
if body.is_in_group('player'):
|
||||
player = null
|
||||
return
|
||||
|
||||
|
||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||
if area.is_in_group('player_weapon_1'):
|
||||
health -= 1
|
||||
hit = true
|
||||
elif area.is_in_group('player_weapon_2'):
|
||||
health -= 2
|
||||
hit = true
|
||||
if area.is_in_group('player_weapon_1'):
|
||||
health -= 1
|
||||
hit = true
|
||||
elif area.is_in_group('player_weapon_2'):
|
||||
health -= 2
|
||||
hit = true
|
||||
|
||||
if health <= 0:
|
||||
call_deferred('queue_free')
|
||||
return
|
||||
if health <= 0:
|
||||
call_deferred('queue_free')
|
||||
return
|
||||
|
@@ -10,65 +10,65 @@ var counter: int = 0
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
velocity = Vector2.ZERO
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
if player and position.distance_to(player.position) > 1:
|
||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||
var angle = position.angle_to_point(player.position)
|
||||
if abs(angle) > PI/2:
|
||||
$AnimatedSprite1.scale.x = -0.563
|
||||
else:
|
||||
$AnimatedSprite1.scale.x = 0.563
|
||||
if player and position.distance_to(player.position) > 1:
|
||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||
var angle = position.angle_to_point(player.position)
|
||||
if abs(angle) > PI/2:
|
||||
$AnimatedSprite1.scale.x = -0.563
|
||||
else:
|
||||
$AnimatedSprite1.scale.x = 0.563
|
||||
|
||||
if hit == true:
|
||||
if counter < 15:
|
||||
if counter % 5 == 0:
|
||||
$AnimatedSprite1.visible = false
|
||||
else:
|
||||
$AnimatedSprite1.visible = true
|
||||
counter += 1
|
||||
velocity = Vector2.ZERO
|
||||
else:
|
||||
counter = 0
|
||||
hit = false
|
||||
if hit == true:
|
||||
if counter < 15:
|
||||
if counter % 5 == 0:
|
||||
$AnimatedSprite1.visible = false
|
||||
else:
|
||||
$AnimatedSprite1.visible = true
|
||||
counter += 1
|
||||
velocity = Vector2.ZERO
|
||||
else:
|
||||
counter = 0
|
||||
hit = false
|
||||
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
$AnimatedSprite1.animation = 'Running'
|
||||
return
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
$AnimatedSprite1.animation = 'Running'
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_body_exited(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = null
|
||||
$AnimatedSprite1.animation = 'Idle'
|
||||
return
|
||||
if body.is_in_group('player'):
|
||||
player = null
|
||||
$AnimatedSprite1.animation = 'Idle'
|
||||
return
|
||||
|
||||
|
||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||
if area.is_in_group('player_weapon_1'):
|
||||
health -= 1
|
||||
hit = true
|
||||
elif area.is_in_group('player_weapon_2'):
|
||||
health -= 2
|
||||
hit = true
|
||||
if area.is_in_group('player_weapon_1'):
|
||||
health -= 1
|
||||
hit = true
|
||||
elif area.is_in_group('player_weapon_2'):
|
||||
health -= 2
|
||||
hit = true
|
||||
|
||||
if health <= 0:
|
||||
call_deferred('queue_free')
|
||||
return
|
||||
if health <= 0:
|
||||
call_deferred('queue_free')
|
||||
return
|
||||
|
||||
func _on_Player_Detector__Attack_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
$AnimatedSprite1.animation = 'Jump'
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
$AnimatedSprite1.animation = 'Jump'
|
||||
|
||||
|
||||
func _on_Player_Detector__Attack_body_exited(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
$AnimatedSprite1.animation = 'Running'
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
$AnimatedSprite1.animation = 'Running'
|
||||
|
88
GUI/HUD.gd
88
GUI/HUD.gd
@@ -5,76 +5,76 @@ var weapon = "sword"
|
||||
|
||||
|
||||
func _on_Add_Currency_pressed() -> void:
|
||||
emit_signal('add_currency', 1)
|
||||
return
|
||||
emit_signal('add_currency', 1)
|
||||
return
|
||||
|
||||
|
||||
func update_currency(amount: int) -> void:
|
||||
$Currency.set_text(String(amount))
|
||||
return
|
||||
$Currency.set_text(String(amount))
|
||||
return
|
||||
|
||||
|
||||
func update_health(value: int) -> void:
|
||||
$'Health Bar'.value = value
|
||||
return
|
||||
$'Health Bar'.value = value
|
||||
return
|
||||
|
||||
|
||||
func _on_weapon_slot_pressed() -> void:
|
||||
$'Weapon Selection'.set_visible(not $'Weapon Selection'.visible)
|
||||
return
|
||||
$'Weapon Selection'.set_visible(not $'Weapon Selection'.visible)
|
||||
return
|
||||
|
||||
|
||||
func _on_select_bow_pressed() -> void:
|
||||
$'Weapon Selection/Bow'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Bow/Weapon'.get_normal_texture())
|
||||
$'Weapon Selection/Bow'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Bow/Weapon'.get_normal_texture())
|
||||
|
||||
$'Weapon Selection/Javelin'.set_visible(true)
|
||||
$'Weapon Selection/Staff'.set_visible(true)
|
||||
$'Weapon Selection/Sword'.set_visible(true)
|
||||
$'Weapon Selection/Javelin'.set_visible(true)
|
||||
$'Weapon Selection/Staff'.set_visible(true)
|
||||
$'Weapon Selection/Sword'.set_visible(true)
|
||||
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "bow"
|
||||
return
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "bow"
|
||||
return
|
||||
|
||||
|
||||
func _on_select_javelin_pressed() -> void:
|
||||
$'Weapon Selection/Javelin'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Javelin/Weapon'.get_normal_texture())
|
||||
$'Weapon Selection/Javelin'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Javelin/Weapon'.get_normal_texture())
|
||||
|
||||
$'Weapon Selection/Bow'.set_visible(true)
|
||||
$'Weapon Selection/Staff'.set_visible(true)
|
||||
$'Weapon Selection/Sword'.set_visible(true)
|
||||
$'Weapon Selection/Bow'.set_visible(true)
|
||||
$'Weapon Selection/Staff'.set_visible(true)
|
||||
$'Weapon Selection/Sword'.set_visible(true)
|
||||
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "javelin"
|
||||
return
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "javelin"
|
||||
return
|
||||
|
||||
|
||||
func _on_select_staff_pressed() -> void:
|
||||
$'Weapon Selection/Staff'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Staff/Weapon'.get_normal_texture())
|
||||
$'Weapon Selection/Staff'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Staff/Weapon'.get_normal_texture())
|
||||
|
||||
$'Weapon Selection/Bow'.set_visible(true)
|
||||
$'Weapon Selection/Javelin'.set_visible(true)
|
||||
$'Weapon Selection/Sword'.set_visible(true)
|
||||
$'Weapon Selection/Bow'.set_visible(true)
|
||||
$'Weapon Selection/Javelin'.set_visible(true)
|
||||
$'Weapon Selection/Sword'.set_visible(true)
|
||||
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "staff"
|
||||
return
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "staff"
|
||||
return
|
||||
|
||||
|
||||
func _on_select_sword_pressed() -> void:
|
||||
$'Weapon Selection/Sword'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Sword/Weapon'.get_normal_texture())
|
||||
$'Weapon Selection/Sword'.set_visible(false)
|
||||
$'Equipped Weapon/Weapon'.set_normal_texture(
|
||||
$'Weapon Selection/Sword/Weapon'.get_normal_texture())
|
||||
|
||||
$'Weapon Selection/Bow'.set_visible(true)
|
||||
$'Weapon Selection/Javelin'.set_visible(true)
|
||||
$'Weapon Selection/Staff'.set_visible(true)
|
||||
$'Weapon Selection/Bow'.set_visible(true)
|
||||
$'Weapon Selection/Javelin'.set_visible(true)
|
||||
$'Weapon Selection/Staff'.set_visible(true)
|
||||
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "sword"
|
||||
return
|
||||
$'Weapon Selection'.set_visible(false)
|
||||
weapon = "sword"
|
||||
return
|
||||
|
@@ -4,36 +4,36 @@ signal complete(option)
|
||||
|
||||
|
||||
func _on_new_game_button_pressed() -> void:
|
||||
emit_signal('complete', 'new game')
|
||||
return
|
||||
emit_signal('complete', 'new game')
|
||||
return
|
||||
|
||||
|
||||
func _on_quit_button_pressed() -> void:
|
||||
get_tree().quit()
|
||||
return
|
||||
get_tree().quit()
|
||||
return
|
||||
|
||||
|
||||
func _on_continue_button_mouse_entered() -> void:
|
||||
if not $'Menu/Menu Elements/Menu Options/Continue/Continue Button'.disabled:
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
if not $'Menu/Menu Elements/Menu Options/Continue/Continue Button'.disabled:
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
|
||||
|
||||
func _on_new_game_button_mouse_entered() -> void:
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
|
||||
|
||||
func _on_settings_button_mouse_entered() -> void:
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
|
||||
|
||||
func _on_credits_button_mouse_entered() -> void:
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
|
||||
|
||||
func _on_quit_button_mouse_entered() -> void:
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
$'Menu Button Hover'.play(0.0)
|
||||
return
|
||||
|
@@ -4,26 +4,26 @@ signal complete
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# Fade in
|
||||
if not $Tween.interpolate_property(self, 'self_modulate:a', 0, 1, 3, Tween.TRANS_LINEAR, Tween.EASE_IN):
|
||||
print('ERROR: Splash Screen fade in animation has errors.')
|
||||
if not $Tween.start():
|
||||
print('ERROR: Splash Screen fade in animation failed to start.')
|
||||
# Fade in
|
||||
if not $Tween.interpolate_property(self, 'self_modulate:a', 0, 1, 3, Tween.TRANS_LINEAR, Tween.EASE_IN):
|
||||
print('ERROR: Splash Screen fade in animation has errors.')
|
||||
if not $Tween.start():
|
||||
print('ERROR: Splash Screen fade in animation failed to start.')
|
||||
|
||||
yield($Tween, 'tween_completed') # Wait for fade in to complete
|
||||
yield($Tween, 'tween_completed') # Wait for fade in to complete
|
||||
|
||||
# Fade out
|
||||
if not $Tween.interpolate_property(self, 'self_modulate:a', 1, 0, 3, Tween.TRANS_LINEAR, Tween.EASE_OUT, 2):
|
||||
print('ERROR: Splash Screen fade out animation has errors.')
|
||||
if not $Tween.start():
|
||||
print('ERROR: Splash Screen fade out animation failed to start.')
|
||||
# Fade out
|
||||
if not $Tween.interpolate_property(self, 'self_modulate:a', 1, 0, 3, Tween.TRANS_LINEAR, Tween.EASE_OUT, 2):
|
||||
print('ERROR: Splash Screen fade out animation has errors.')
|
||||
if not $Tween.start():
|
||||
print('ERROR: Splash Screen fade out animation failed to start.')
|
||||
|
||||
yield($Tween, 'tween_completed') # Wait for fade out to complete
|
||||
emit_signal('complete')
|
||||
return
|
||||
yield($Tween, 'tween_completed') # Wait for fade out to complete
|
||||
emit_signal('complete')
|
||||
return
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed('ui_accept'):
|
||||
emit_signal('complete')
|
||||
return
|
||||
if event.is_action_pressed('ui_accept'):
|
||||
emit_signal('complete')
|
||||
return
|
||||
|
@@ -7,51 +7,51 @@ var score = 0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
$YSort/Player.load_hud($HUD)
|
||||
screensize = get_viewport_rect().size
|
||||
spawn_coins(8)
|
||||
return
|
||||
$YSort/Player.load_hud($HUD)
|
||||
screensize = get_viewport_rect().size
|
||||
spawn_coins(8)
|
||||
return
|
||||
|
||||
|
||||
func spawn_coins(num: int) -> void:
|
||||
for _i in range(num):
|
||||
var g: Node = coin.instance()
|
||||
$'coin_container'.add_child(g)
|
||||
g.connect('coin_grabbed', self, '_on_coin_grabbed')
|
||||
#g.set_pos(Vector2(rand_range(0, screensize.x - 40), rand_range(0, screensize.y - 40)))
|
||||
g.position = Vector2(rand_range(0, screensize.x - 40), rand_range(0, screensize.y - 40))
|
||||
return
|
||||
for _i in range(num):
|
||||
var g: Node = coin.instance()
|
||||
$'coin_container'.add_child(g)
|
||||
g.connect('coin_grabbed', self, '_on_coin_grabbed')
|
||||
#g.set_pos(Vector2(rand_range(0, screensize.x - 40), rand_range(0, screensize.y - 40)))
|
||||
g.position = Vector2(rand_range(0, screensize.x - 40), rand_range(0, screensize.y - 40))
|
||||
return
|
||||
|
||||
|
||||
func _on_coin_grabbed() -> void:
|
||||
score += 1
|
||||
print(score)
|
||||
$'Level 3 HUD/Label'.set_text(str(score) + '/5')
|
||||
return
|
||||
score += 1
|
||||
print(score)
|
||||
$'Level 3 HUD/Label'.set_text(str(score) + '/5')
|
||||
return
|
||||
|
||||
|
||||
func _timer_out() -> void:
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||
queue_free()
|
||||
return
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||
queue_free()
|
||||
return
|
||||
|
||||
|
||||
func _on_TreasureChest_ice_key_collected() -> void:
|
||||
$YSort/Door/doorClosed.visible = false
|
||||
$YSort/Door/doorOpened.visible = true
|
||||
$YSort/DoorCollision.layers = 5
|
||||
return
|
||||
$YSort/Door/doorClosed.visible = false
|
||||
$YSort/Door/doorOpened.visible = true
|
||||
$YSort/DoorCollision.layers = 5
|
||||
return
|
||||
|
||||
|
||||
func _on_DoorDetector_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
print('WIN WIN WIN')
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||
return
|
||||
if body.is_in_group('player'):
|
||||
print('WIN WIN WIN')
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||
return
|
||||
|
||||
|
||||
func _on_DoorDetector_area_entered(area: Area2D) -> void:
|
||||
if area.get_parent().name == 'Player':
|
||||
get_tree().change_scene('res://GUI/Level Complete.tscn')
|
||||
queue_free()
|
||||
return
|
||||
if area.get_parent().name == 'Player':
|
||||
get_tree().change_scene('res://GUI/Level Complete.tscn')
|
||||
queue_free()
|
||||
return
|
||||
|
@@ -3,26 +3,26 @@ extends Node2D
|
||||
var gems: int = 4
|
||||
|
||||
func _ready() -> void:
|
||||
#$YSort/Player.position = get_viewport_rect().size / 2
|
||||
$YSort/Player.load_hud($HUD)
|
||||
return
|
||||
#$YSort/Player.position = get_viewport_rect().size / 2
|
||||
$YSort/Player.load_hud($HUD)
|
||||
return
|
||||
|
||||
|
||||
func _on_TreasureChest_gem_collected() -> void:
|
||||
gems -= 1
|
||||
gems -= 1
|
||||
|
||||
if gems == 0:
|
||||
$YSort/Items/Door/doorClosed.visible = false
|
||||
$YSort/Items/Door/doorOpened.visible = true
|
||||
$DoorCollision.layers = 5
|
||||
if gems == 0:
|
||||
$YSort/Items/Door/doorClosed.visible = false
|
||||
$YSort/Items/Door/doorOpened.visible = true
|
||||
$DoorCollision.layers = 5
|
||||
|
||||
|
||||
|
||||
func _on_NextArea_area_entered(area: Area2D) -> void:
|
||||
if area.get_parent().name == 'Player':
|
||||
$YSort/Player.position.x = 195
|
||||
$YSort/Player.position.y = -335
|
||||
if area.get_parent().name == 'Player':
|
||||
$YSort/Player.position.x = 195
|
||||
$YSort/Player.position.y = -335
|
||||
|
||||
|
||||
func _on_Demon_Boss_demon_boss_death() -> void:
|
||||
get_tree().change_scene('res://Levels/Hub World.tscn')
|
||||
get_tree().change_scene('res://GUI/Level Complete.tscn')
|
||||
|
@@ -2,5 +2,5 @@ extends Node2D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
$YSort/Player.load_hud($HUD)
|
||||
return
|
||||
$YSort/Player.load_hud($HUD)
|
||||
return
|
||||
|
96
Main.gd
96
Main.gd
@@ -7,76 +7,76 @@ export var hub_world_path: String
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
randomize()
|
||||
var splash_screen: Node = play_splash_screen()
|
||||
yield(splash_screen, 'complete')
|
||||
splash_screen = null
|
||||
randomize()
|
||||
var splash_screen: Node = play_splash_screen()
|
||||
yield(splash_screen, 'complete')
|
||||
splash_screen = null
|
||||
|
||||
var main_menu: Node = play_main_menu()
|
||||
yield(main_menu, 'complete')
|
||||
free_connected_node(main_menu, 'main_menu_option')
|
||||
main_menu = null
|
||||
return
|
||||
var main_menu: Node = play_main_menu()
|
||||
yield(main_menu, 'complete')
|
||||
free_connected_node(main_menu, 'main_menu_option')
|
||||
main_menu = null
|
||||
return
|
||||
|
||||
|
||||
func play_splash_screen() -> Node:
|
||||
var splash_screen: Node = load(splash_screen_path).instance()
|
||||
if splash_screen.connect('complete', self, 'free_connected_node',
|
||||
[splash_screen, 'free_connected_node']) != OK:
|
||||
print('ERROR: Splash Screen "complete" signal already connected.')
|
||||
var splash_screen: Node = load(splash_screen_path).instance()
|
||||
if splash_screen.connect('complete', self, 'free_connected_node',
|
||||
[splash_screen, 'free_connected_node']) != OK:
|
||||
print('ERROR: Splash Screen "complete" signal already connected.')
|
||||
|
||||
add_child(splash_screen)
|
||||
return splash_screen
|
||||
add_child(splash_screen)
|
||||
return splash_screen
|
||||
|
||||
|
||||
func play_main_menu() -> Node:
|
||||
var main_menu: Node = load(main_menu_path).instance()
|
||||
if main_menu.connect('complete', self, 'main_menu_option') != OK:
|
||||
print('ERROR: Main Menu "complete" signal already connected.')
|
||||
var main_menu: Node = load(main_menu_path).instance()
|
||||
if main_menu.connect('complete', self, 'main_menu_option') != OK:
|
||||
print('ERROR: Main Menu "complete" signal already connected.')
|
||||
|
||||
add_child(main_menu)
|
||||
return main_menu
|
||||
add_child(main_menu)
|
||||
return main_menu
|
||||
|
||||
|
||||
func main_menu_option(option: String) -> void:
|
||||
if option == 'new game':
|
||||
if get_tree().change_scene(hub_world_path) != OK:
|
||||
print('ERROR: Main failed to change scene to Hub World.')
|
||||
queue_free()
|
||||
#var level_select_menu: Node = play_level_select_menu()
|
||||
#yield(level_select_menu, 'complete')
|
||||
#free_connected_node(level_select_menu, 'level_select_menu_option')
|
||||
#level_select_menu = null
|
||||
return
|
||||
if option == 'new game':
|
||||
if get_tree().change_scene(hub_world_path) != OK:
|
||||
print('ERROR: Main failed to change scene to Hub World.')
|
||||
queue_free()
|
||||
#var level_select_menu: Node = play_level_select_menu()
|
||||
#yield(level_select_menu, 'complete')
|
||||
#free_connected_node(level_select_menu, 'level_select_menu_option')
|
||||
#level_select_menu = null
|
||||
return
|
||||
|
||||
|
||||
func play_level_select_menu() -> Node:
|
||||
var level_select_menu: Node = load(level_select_menu_path).instance()
|
||||
if level_select_menu.connect('complete', self, 'level_select_menu_option') != OK:
|
||||
print('ERROR: Level Select Menu "complete" signal already connected.')
|
||||
var level_select_menu: Node = load(level_select_menu_path).instance()
|
||||
if level_select_menu.connect('complete', self, 'level_select_menu_option') != OK:
|
||||
print('ERROR: Level Select Menu "complete" signal already connected.')
|
||||
|
||||
add_child(level_select_menu)
|
||||
return level_select_menu
|
||||
add_child(level_select_menu)
|
||||
return level_select_menu
|
||||
|
||||
|
||||
func level_select_menu_option(option: String) -> void:
|
||||
var level: String = 'res://Levels/'
|
||||
if option == 'H':
|
||||
level += 'Hub World.tscn'
|
||||
else:
|
||||
level += 'Level ' + option + '.tscn'
|
||||
var level: String = 'res://Levels/'
|
||||
if option == 'H':
|
||||
level += 'Hub World.tscn'
|
||||
else:
|
||||
level += 'Level ' + option + '.tscn'
|
||||
|
||||
new_game(level)
|
||||
return
|
||||
new_game(level)
|
||||
return
|
||||
|
||||
func free_connected_node(node: Node, connected_function: String) -> void:
|
||||
node.disconnect('complete', self, connected_function)
|
||||
node.queue_free()
|
||||
return
|
||||
node.disconnect('complete', self, connected_function)
|
||||
node.queue_free()
|
||||
return
|
||||
|
||||
|
||||
func new_game(level: String) -> void:
|
||||
if get_tree().change_scene(level) != OK:
|
||||
print('ERROR: Main failed to change scene to Level.')
|
||||
queue_free()
|
||||
return
|
||||
if get_tree().change_scene(level) != OK:
|
||||
print('ERROR: Main failed to change scene to Level.')
|
||||
queue_free()
|
||||
return
|
||||
|
174
Player/Player.gd
174
Player/Player.gd
@@ -14,137 +14,137 @@ var velocity: Vector2 = Vector2.ZERO
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_weapon_position(Vector2(1, 0))
|
||||
return
|
||||
set_weapon_position(Vector2(1, 0))
|
||||
return
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var input_vector: Vector2 = Vector2.ZERO
|
||||
var input_vector: Vector2 = Vector2.ZERO
|
||||
|
||||
input_vector.x = Input.get_action_strength('player_right') \
|
||||
- Input.get_action_strength('player_left')
|
||||
input_vector.y = Input.get_action_strength('player_down') \
|
||||
- Input.get_action_strength('player_up')
|
||||
input_vector = input_vector.normalized()
|
||||
input_vector.x = Input.get_action_strength('player_right') \
|
||||
- Input.get_action_strength('player_left')
|
||||
input_vector.y = Input.get_action_strength('player_down') \
|
||||
- Input.get_action_strength('player_up')
|
||||
input_vector = input_vector.normalized()
|
||||
|
||||
if input_vector != Vector2.ZERO:
|
||||
$AnimationTree.set('parameters/Idle/blend_position', input_vector)
|
||||
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
|
||||
set_weapon_position(input_vector)
|
||||
else:
|
||||
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
|
||||
if input_vector != Vector2.ZERO:
|
||||
$AnimationTree.set('parameters/Idle/blend_position', input_vector)
|
||||
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
|
||||
set_weapon_position(input_vector)
|
||||
else:
|
||||
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
|
||||
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
|
||||
|
||||
func load_hud(node: CanvasLayer) -> void:
|
||||
hud = node
|
||||
if hud.connect('add_currency', self, 'add_currency') != OK:
|
||||
print('ERROR: HUD "add_currency" signal already connected.')
|
||||
hud = node
|
||||
if hud.connect('add_currency', self, 'add_currency') != OK:
|
||||
print('ERROR: HUD "add_currency" signal already connected.')
|
||||
|
||||
hud.update_health(HEALTH_SLICES[health_index])
|
||||
hud.update_currency($Inventory.get_currency())
|
||||
return
|
||||
hud.update_health(HEALTH_SLICES[health_index])
|
||||
hud.update_currency($Inventory.get_currency())
|
||||
return
|
||||
|
||||
|
||||
func set_weapon_position(pos: Vector2) -> void:
|
||||
# Facing left
|
||||
if pos[0] < 0:
|
||||
$Sword.rotation_degrees = -90
|
||||
$Javelin.rotation_degrees = -90
|
||||
# Facing left
|
||||
if pos[0] < 0:
|
||||
$Sword.rotation_degrees = -90
|
||||
$Javelin.rotation_degrees = -90
|
||||
|
||||
# Facing right
|
||||
elif pos[0] > 0:
|
||||
$Sword.rotation_degrees = 90
|
||||
$Javelin.rotation_degrees = 90
|
||||
# Facing right
|
||||
elif pos[0] > 0:
|
||||
$Sword.rotation_degrees = 90
|
||||
$Javelin.rotation_degrees = 90
|
||||
|
||||
# Facing up
|
||||
elif pos[1] < 0:
|
||||
$Sword.rotation_degrees = 0
|
||||
$Javelin.rotation_degrees = 0
|
||||
# Facing up
|
||||
elif pos[1] < 0:
|
||||
$Sword.rotation_degrees = 0
|
||||
$Javelin.rotation_degrees = 0
|
||||
|
||||
# Facing down
|
||||
elif pos[1] > 0:
|
||||
$Sword.rotation_degrees = 180
|
||||
$Javelin.rotation_degrees = 180
|
||||
return
|
||||
# Facing down
|
||||
elif pos[1] > 0:
|
||||
$Sword.rotation_degrees = 180
|
||||
$Javelin.rotation_degrees = 180
|
||||
return
|
||||
|
||||
|
||||
func add_currency(amount: int) -> void:
|
||||
$Inventory.add_currency(amount)
|
||||
return
|
||||
$Inventory.add_currency(amount)
|
||||
return
|
||||
|
||||
|
||||
func has_item(item: String) -> bool:
|
||||
return $Inventory.contains(item)
|
||||
return $Inventory.contains(item)
|
||||
|
||||
|
||||
func add_item(item: String) -> void:
|
||||
$Inventory.add(item)
|
||||
return
|
||||
$Inventory.add(item)
|
||||
return
|
||||
|
||||
|
||||
func remove_item(item: String) -> void:
|
||||
$Inventory.remove(item)
|
||||
return
|
||||
$Inventory.remove(item)
|
||||
return
|
||||
|
||||
|
||||
func _on_Inventory_update_currency(amount: int) -> void:
|
||||
hud.update_currency(amount)
|
||||
return
|
||||
hud.update_currency(amount)
|
||||
return
|
||||
|
||||
|
||||
func _on_hitbox_area_entered(area: Area2D) -> void:
|
||||
var hit: int = 0
|
||||
var hit: int = 0
|
||||
|
||||
if area.is_in_group('enemy_hitbox_1') or area.is_in_group('enemy_projectile_1'):
|
||||
hit = 1
|
||||
elif area.is_in_group('enemy_hitbox_2') or area.is_in_group('enemy_projectile_2'):
|
||||
hit = 2
|
||||
elif area.is_in_group('enemy_hitbox_3') or area.is_in_group('enemy_projectile_3'):
|
||||
hit = 3
|
||||
elif area.is_in_group('freeze'):
|
||||
emit_signal('frozen')
|
||||
$Sprite.self_modulate = Color(0, 0.5, 1)
|
||||
else:
|
||||
return
|
||||
if area.is_in_group('enemy_hitbox_1') or area.is_in_group('enemy_projectile_1'):
|
||||
hit = 1
|
||||
elif area.is_in_group('enemy_hitbox_2') or area.is_in_group('enemy_projectile_2'):
|
||||
hit = 2
|
||||
elif area.is_in_group('enemy_hitbox_3') or area.is_in_group('enemy_projectile_3'):
|
||||
hit = 3
|
||||
elif area.is_in_group('freeze'):
|
||||
emit_signal('frozen')
|
||||
$Sprite.self_modulate = Color(0, 0.5, 1)
|
||||
else:
|
||||
return
|
||||
|
||||
if health_index != 0:
|
||||
health_index -= hit
|
||||
if health_index < 0:
|
||||
health_index = 0
|
||||
if health_index != 0:
|
||||
health_index -= hit
|
||||
if health_index < 0:
|
||||
health_index = 0
|
||||
|
||||
hud.update_health(HEALTH_SLICES[health_index])
|
||||
else:
|
||||
if get_tree().change_scene('res://GUI/Level Failed.tscn') != OK:
|
||||
print('ERROR: Player failed to change scene to Level Failed.')
|
||||
queue_free()
|
||||
return
|
||||
hud.update_health(HEALTH_SLICES[health_index])
|
||||
else:
|
||||
if get_tree().change_scene('res://GUI/Level Failed.tscn') != OK:
|
||||
print('ERROR: Player failed to change scene to Level Failed.')
|
||||
queue_free()
|
||||
return
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed('player_attack'):
|
||||
if hud.weapon == 'sword':
|
||||
$'Sword/Sword Animation'.play('swing')
|
||||
elif hud.weapon == 'javelin':
|
||||
$'Javelin/Javelin Animation'.play('swing')
|
||||
if event.is_action_pressed('player_attack'):
|
||||
if hud.weapon == 'sword':
|
||||
$'Sword/Sword Animation'.play('swing')
|
||||
elif hud.weapon == 'javelin':
|
||||
$'Javelin/Javelin Animation'.play('swing')
|
||||
|
||||
elif event.is_action_pressed('screenshot'):
|
||||
var img: Image = get_viewport().get_texture().get_data()
|
||||
yield(get_tree(), 'idle_frame')
|
||||
yield(get_tree(), 'idle_frame')
|
||||
elif event.is_action_pressed('screenshot'):
|
||||
var img: Image = get_viewport().get_texture().get_data()
|
||||
yield(get_tree(), 'idle_frame')
|
||||
yield(get_tree(), 'idle_frame')
|
||||
|
||||
img.flip_y()
|
||||
img.flip_y()
|
||||
|
||||
var time: Dictionary = OS.get_datetime_from_unix_time(OS.get_unix_time())
|
||||
var time_msecs: int = OS.get_system_time_msecs()
|
||||
var time: Dictionary = OS.get_datetime_from_unix_time(OS.get_unix_time())
|
||||
var time_msecs: int = OS.get_system_time_msecs()
|
||||
|
||||
if img.save_png('user://Screenshot_%d%d%d_%d.png' % [time.year, time.month, time.day, time_msecs]) != OK:
|
||||
print('ERROR: Failed saving screenshot.')
|
||||
return
|
||||
if img.save_png('user://Screenshot_%d%d%d_%d.png' % [time.year, time.month, time.day, time_msecs]) != OK:
|
||||
print('ERROR: Failed saving screenshot.')
|
||||
return
|
||||
|
||||
|
||||
func _on_SlowTime_unfreeze() -> void:
|
||||
$Sprite.self_modulate = Color(1, 1, 1)
|
||||
return
|
||||
$Sprite.self_modulate = Color(1, 1, 1)
|
||||
return
|
||||
|
@@ -28,6 +28,7 @@ process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
|
Reference in New Issue
Block a user