From 2f27c416b70019ce787f7d426fe4f6b9e63ea0a1 Mon Sep 17 00:00:00 2001 From: moikheck Date: Tue, 23 Nov 2021 10:23:28 -0500 Subject: [PATCH] Fixed some style guide issues --- project/project.godot | 22 +++++++++---------- project/src/HUD.gd | 3 ++- project/src/Item.gd | 13 +++++------ project/src/Level.gd | 11 +++++----- project/src/Player.gd | 22 +++++++++---------- project/src/TitleScreen.tscn | 42 ++++++++++++++++++------------------ 6 files changed, 57 insertions(+), 56 deletions(-) diff --git a/project/project.godot b/project/project.godot index f277ba4..8b06bab 100644 --- a/project/project.godot +++ b/project/project.godot @@ -36,42 +36,42 @@ window=false move_up={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null) ] } move_left={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"physical_scancode":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null) ] } move_right={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"physical_scancode":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null) ] } move_down={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null) ] } attack={ "deadzone": 0.5, "events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null) ] } open_inventory={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null) ] } change_weapon={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"unicode":0,"echo":false,"script":null) ] } diff --git a/project/src/HUD.gd b/project/src/HUD.gd index 557b87b..4760e01 100644 --- a/project/src/HUD.gd +++ b/project/src/HUD.gd @@ -3,6 +3,7 @@ extends Control const KEY_OUTLINE := "res://assets/Items/key_outline.png" const KEY_TEXTURED := "res://assets/Items/key.png" +const INDEX := 100 func _on_RestartButton_pressed(): @@ -27,5 +28,5 @@ func update_key_count(value): particles.texture = load("res://assets/Items/key_particle.png") particles.position = $KeyLogo.position particles.emitting = true - particles.z_index = 100 + particles.z_index = INDEX get_parent().call_deferred("add_child", particles) diff --git a/project/src/Item.gd b/project/src/Item.gd index a799b6c..57a032e 100644 --- a/project/src/Item.gd +++ b/project/src/Item.gd @@ -1,5 +1,5 @@ -extends Sprite class_name Item +extends Sprite var potion := load("res://assets/Items/potion_full.png") @@ -19,9 +19,15 @@ var rank := "null" export var area_type := "item" + onready var player := get_node("../Player") +func _on_Area2D_area_entered(area): + if area == player.get_current_weapon(): + collect() + + func set_item(new_type, new_rank): type = new_type rank = new_rank @@ -52,11 +58,6 @@ func set_item(new_type, new_rank): texture = gold_longsword -func _on_Area2D_area_entered(area): - if area == player.get_current_weapon(): - collect() - - func collect(): player.collect_item(type, rank) queue_free() diff --git a/project/src/Level.gd b/project/src/Level.gd index 251a9e9..53879c4 100644 --- a/project/src/Level.gd +++ b/project/src/Level.gd @@ -12,12 +12,6 @@ func _process(_delta): $Gate.visible = false $Gate/StaticBody2D/CollisionShape2D.disabled = true $Player/HUD/DoorLabel.show() - - - -func pause_enemies(value): - for enemy in get_tree().get_nodes_in_group("Enemies"): - enemy.pause(value) func _on_Chest_open(chest): @@ -35,3 +29,8 @@ func _on_Dungeon_body_exited(body): $Player/HUD/EndMessage.text = "You Win" $Player/HUD/RestartButton.visible = true $Player/HUD/EndMessage.visible = true + + +func pause_enemies(value): + for enemy in get_tree().get_nodes_in_group("Enemies"): + enemy.pause(value) diff --git a/project/src/Player.gd b/project/src/Player.gd index 6f623f6..769e1d9 100644 --- a/project/src/Player.gd +++ b/project/src/Player.gd @@ -77,6 +77,17 @@ func _on_AnimatedSprite_animation_finished(): _is_hurt = false +func _on_InventoryButton_toggled(button_pressed): + if button_pressed: + pause() + else: + unpause() + + +func _on_WeaponButton_pressed(): + switch_weapon() + + func take_damage(damage): if not _is_hurt: health -= damage @@ -214,14 +225,3 @@ func spawn_particles(par_tex): particles.emitting = true particles.z_index = 100 get_parent().call_deferred("add_child", particles) - - -func _on_InventoryButton_toggled(button_pressed): - if button_pressed: - pause() - else: - unpause() - - -func _on_WeaponButton_pressed(): - switch_weapon() diff --git a/project/src/TitleScreen.tscn b/project/src/TitleScreen.tscn index aeed9fe..82e0550 100644 --- a/project/src/TitleScreen.tscn +++ b/project/src/TitleScreen.tscn @@ -20,35 +20,35 @@ corner_radius_top_right = 5 corner_radius_bottom_right = 5 corner_radius_bottom_left = 5 -[sub_resource type="StyleBoxFlat" id=7] +[sub_resource type="StyleBoxFlat" id=4] bg_color = Color( 0.803922, 0.784314, 0.784314, 1 ) corner_radius_top_left = 20 corner_radius_top_right = 20 corner_radius_bottom_right = 20 corner_radius_bottom_left = 20 -[sub_resource type="DynamicFont" id=4] -size = 28 -font_data = ExtResource( 3 ) - [sub_resource type="StyleBoxFlat" id=5] bg_color = Color( 0, 0, 0, 0.180392 ) [sub_resource type="StyleBoxFlat" id=6] bg_color = Color( 0.6, 0.6, 0.6, 0 ) +[sub_resource type="DynamicFont" id=7] +size = 28 +font_data = ExtResource( 3 ) + [sub_resource type="DynamicFont" id=8] size = 52 font_data = ExtResource( 3 ) -[sub_resource type="DynamicFont" id=9] -font_data = ExtResource( 3 ) +[sub_resource type="StyleBoxFlat" id=9] +bg_color = Color( 0.6, 0.6, 0.6, 0 ) [sub_resource type="StyleBoxFlat" id=10] bg_color = Color( 0.6, 0.6, 0.6, 0 ) -[sub_resource type="StyleBoxFlat" id=11] -bg_color = Color( 0.6, 0.6, 0.6, 0 ) +[sub_resource type="DynamicFont" id=11] +font_data = ExtResource( 3 ) [node name="TitleScreen" type="Node2D"] script = ExtResource( 2 ) @@ -71,10 +71,10 @@ margin_left = 448.0 margin_top = 413.0 margin_right = 573.0 margin_bottom = 447.0 -custom_colors/font_color = Color( 0, 0, 0, 1 ) -custom_colors/font_color_hover = Color( 0, 0, 0, 1 ) custom_styles/hover = SubResource( 2 ) custom_styles/normal = SubResource( 3 ) +custom_colors/font_color = Color( 0, 0, 0, 1 ) +custom_colors/font_color_hover = Color( 0, 0, 0, 1 ) text = "Start Game" __meta__ = { "_edit_use_anchors_": false @@ -85,10 +85,10 @@ margin_left = 448.0 margin_top = 470.0 margin_right = 573.0 margin_bottom = 504.0 -custom_colors/font_color = Color( 0, 0, 0, 1 ) -custom_colors/font_color_hover = Color( 0, 0, 0, 1 ) custom_styles/hover = SubResource( 2 ) custom_styles/normal = SubResource( 3 ) +custom_colors/font_color = Color( 0, 0, 0, 1 ) +custom_colors/font_color_hover = Color( 0, 0, 0, 1 ) text = "How To Play" __meta__ = { "_edit_use_anchors_": false @@ -107,18 +107,18 @@ margin_left = 163.0 margin_top = 38.0 margin_right = 863.0 margin_bottom = 577.0 -custom_styles/panel = SubResource( 7 ) +custom_styles/panel = SubResource( 4 ) [node name="Exit" type="Button" parent="InstructionsPopup"] margin_left = 797.0 margin_top = 72.0 margin_right = 840.0 margin_bottom = 108.0 -custom_colors/font_color = Color( 0, 0, 0, 1 ) -custom_colors/font_color_hover = Color( 1, 1, 1, 1 ) -custom_fonts/font = SubResource( 4 ) custom_styles/hover = SubResource( 5 ) custom_styles/normal = SubResource( 6 ) +custom_fonts/font = SubResource( 7 ) +custom_colors/font_color = Color( 0, 0, 0, 1 ) +custom_colors/font_color_hover = Color( 1, 1, 1, 1 ) text = "X" __meta__ = { "_edit_use_anchors_": false @@ -129,8 +129,8 @@ margin_left = 346.0 margin_top = 64.0 margin_right = 657.0 margin_bottom = 130.0 -custom_colors/default_color = Color( 0, 0, 0, 1 ) custom_fonts/normal_font = SubResource( 8 ) +custom_colors/default_color = Color( 0, 0, 0, 1 ) text = "How To Play" [node name="TextEdit" type="TextEdit" parent="InstructionsPopup"] @@ -138,10 +138,10 @@ margin_left = 227.0 margin_top = 175.0 margin_right = 808.0 margin_bottom = 548.0 +custom_styles/read_only = SubResource( 9 ) +custom_styles/normal = SubResource( 10 ) +custom_fonts/font = SubResource( 11 ) custom_colors/font_color_readonly = Color( 0, 0, 0, 1 ) -custom_fonts/font = SubResource( 9 ) -custom_styles/read_only = SubResource( 10 ) -custom_styles/normal = SubResource( 11 ) text = "Controls Use the arrow keys to move around Use the mouse to attack, collect and interact with enemies and objects