Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boost icon in the bottom right #62

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/menu/boost.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/boost_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 9 additions & 3 deletions scenes/game_object/player/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var can_boost = true
@onready var tank_body: Sprite2D = $TankBody/Sprite2D
@onready var barrel_color: Sprite2D = $Barrel/Sprite2D
@onready var boost_timer: Timer = $BoostTimer
@export var boost_icons: Array[TextureRect]

@onready var previous_movement: Vector2 = Vector2.ZERO

Expand Down Expand Up @@ -54,9 +55,8 @@ func _process(delta):
apply_boost(direction)
can_boost = false
boost_timer.start()

if boost_timer.is_stopped() and can_boost == false:
can_boost = true
boost_icons[0].visible = false # available icon
boost_icons[1].visible = true # unavailable icon

move_and_slide()

Expand All @@ -79,3 +79,9 @@ func update_health_display():

func on_health_changed():
update_health_display.rpc()

func _on_boost_timer_timeout():
if can_boost == false:
can_boost = true
boost_icons[0].visible = true
boost_icons[1].visible = false
55 changes: 47 additions & 8 deletions scenes/game_object/player/player.tscn
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
[gd_scene load_steps=17 format=3 uid="uid://bam04hog13mtt"]
[gd_scene load_steps=20 format=3 uid="uid://bam04hog13mtt"]

[ext_resource type="Script" path="res://scenes/game_object/player/player.gd" id="1_hkal2"]
[ext_resource type="PackedScene" uid="uid://73lr8fqud4" path="res://scenes/component/health_component.tscn" id="2_gt4m0"]
[ext_resource type="Texture2D" uid="uid://bev0i3hblaggj" path="res://assets/menu/boost.png" id="2_mn8cc"]
[ext_resource type="PackedScene" uid="uid://drybknwrows3o" path="res://scenes/game_object/player/tank_body.tscn" id="3_1e010"]
[ext_resource type="Texture2D" uid="uid://cphdqa08uuq8a" path="res://scenes/game_object/player/tankGreen_barrel3_outline.png" id="3_vvwhs"]
[ext_resource type="Texture2D" uid="uid://cjgsa7jtfnoms" path="res://assets/menu/boost_dark.png" id="3_ciky0"]
[ext_resource type="Texture2D" uid="uid://8ip3d3virahl" path="res://scenes/game_object/player/tankGreen_barrel3_outline.png" id="3_vvwhs"]
[ext_resource type="Script" path="res://scenes/game_object/player/Barrel.gd" id="4_yiyg3"]
[ext_resource type="PackedScene" uid="uid://dp7s6opobih82" path="res://scenes/component/hurtbox_component.tscn" id="5_fvhfs"]
[ext_resource type="PackedScene" uid="uid://mbsht4dt5quk" path="res://scenes/game_object/player/health_bar.tscn" id="7_p6dmh"]
[ext_resource type="Texture2D" uid="uid://bh74bxar0ghpn" path="res://assets/sprites/Effects/Explosion1/explosion1.png" id="8_xuf46"]
[ext_resource type="Texture2D" uid="uid://cfdfosrj6jftq" path="res://assets/sprites/Effects/Explosion1/explosion2.png" id="9_n372a"]
[ext_resource type="Texture2D" uid="uid://civngppv5n2ow" path="res://assets/sprites/Effects/Explosion1/explosion3.png" id="10_ytrhg"]
[ext_resource type="Texture2D" uid="uid://c3ujarddh4c3j" path="res://assets/sprites/Effects/Explosion1/explosion4.png" id="11_cxpyl"]
[ext_resource type="Texture2D" uid="uid://bdw12ylwud1yh" path="res://assets/sprites/Effects/Explosion1/explosion5.png" id="12_pogg6"]
[ext_resource type="Texture2D" uid="uid://qy1axfax8jfx" path="res://assets/sprites/Effects/Explosion1/explosion1.png" id="8_xuf46"]
[ext_resource type="Texture2D" uid="uid://ct43tpf4bhlam" path="res://assets/sprites/Effects/Explosion1/explosion2.png" id="9_n372a"]
[ext_resource type="Texture2D" uid="uid://1bj57cp5m24g" path="res://assets/sprites/Effects/Explosion1/explosion3.png" id="10_ytrhg"]
[ext_resource type="Texture2D" uid="uid://dh70asex6npw2" path="res://assets/sprites/Effects/Explosion1/explosion4.png" id="11_cxpyl"]
[ext_resource type="Texture2D" uid="uid://ctmtx3mrofxqa" path="res://assets/sprites/Effects/Explosion1/explosion5.png" id="12_pogg6"]

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_bk8ck"]

[sub_resource type="CircleShape2D" id="CircleShape2D_e32xm"]
radius = 16.0312
Expand Down Expand Up @@ -56,10 +60,11 @@ animations = [{
"speed": 5.0
}]

[node name="Player" type="CharacterBody2D" groups=["player"]]
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("boost_icons") groups=["player"]]
collision_layer = 2
collision_mask = 126
script = ExtResource("1_hkal2")
boost_icons = [NodePath("HUD/PanelContainer/MarginContainer/BoostAvailableIcon"), NodePath("HUD/PanelContainer/MarginContainer/BoostUnavailableIcon")]

[node name="Camera2D" type="Camera2D" parent="."]
limit_left = 0
Expand All @@ -68,6 +73,38 @@ limit_right = 4480
limit_bottom = 4480
position_smoothing_enabled = true

[node name="HUD" type="CanvasLayer" parent="."]

[node name="PanelContainer" type="PanelContainer" parent="HUD"]
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -715.0
offset_top = -71.0
offset_right = -24.0
offset_bottom = -22.0
grow_horizontal = 0
grow_vertical = 0
theme_override_styles/panel = SubResource("StyleBoxEmpty_bk8ck")

[node name="MarginContainer" type="MarginContainer" parent="HUD/PanelContainer"]
layout_mode = 2
theme_override_constants/margin_left = 630
theme_override_constants/margin_top = 20

[node name="BoostAvailableIcon" type="TextureRect" parent="HUD/PanelContainer/MarginContainer"]
layout_mode = 2
texture = ExtResource("2_mn8cc")
stretch_mode = 2

[node name="BoostUnavailableIcon" type="TextureRect" parent="HUD/PanelContainer/MarginContainer"]
visible = false
layout_mode = 2
texture = ExtResource("3_ciky0")
stretch_mode = 2

[node name="HealthComponent" parent="." instance=ExtResource("2_gt4m0")]
max_health = 50.0

Expand Down Expand Up @@ -143,4 +180,6 @@ visible = false
sprite_frames = SubResource("SpriteFrames_qctma")
frame_progress = 0.217273

[connection signal="timeout" from="BoostTimer" to="." method="_on_boost_timer_timeout"]

[editable path="TankBody"]