Skip to content

Commit

Permalink
-Place HUD at bottom of parallax. WIP #15
Browse files Browse the repository at this point in the history
  • Loading branch information
thebigG committed Dec 14, 2023
1 parent fbe2899 commit 6c4a717
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Gunner/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ settings/stdout/print_fps=true

[display]

window/size/viewport_width=1024
window/size/viewport_height=720
window/size/viewport_width=500
window/size/viewport_height=790
window/size/width=600
window/size/height=850

Expand Down
2 changes: 1 addition & 1 deletion Gunner/scene/EasyStage.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ position = Vector2(0, 184)
motion_mirroring = Vector2(0, 7000)

[node name="Background" type="Sprite2D" parent="ParallaxLayer"]
position = Vector2(-1808, -176)
position = Vector2(0, -176)
scale = Vector2(2.03333, 2.0114)
texture = ExtResource("1")
centered = false
22 changes: 12 additions & 10 deletions Gunner/src/Gunner1.gd
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func _ready():
health_bar.size_flags_horizontal = Control.SIZE_EXPAND_FILL

hud.position = Vector2(
screen_size.size.x - 600,
screen_size.size.x / 2 - (hud.get_size().x / 2),
clamp(
position.y,
get_parent().get_node("EasyStageScene/ParallaxDriver").position.y - 600,
Expand All @@ -77,14 +77,14 @@ func _physics_process(delta):
print(screen_size)
#TODO:Need to find a way to center(relative to window size) the hud and remove
#these hard-coded values
hud.position = Vector2(
screen_size.size.x - 1200,
clamp(
hud.position.y,
get_parent().get_node("EasyStageScene/ParallaxDriver").position.y - 600,
get_parent().get_node("EasyStageScene/ParallaxDriver").position.y
)
)
# hud.position = Vector2(
# screen_size.size.x - 1200,
# clamp(
# hud.position.y,
# get_parent().get_node("EasyStageScene/ParallaxDriver").position.y - 600,
# get_parent().get_node("EasyStageScene/ParallaxDriver").position.y
# )
# )

health_bar.value = self.health
match self.state:
Expand Down Expand Up @@ -149,7 +149,7 @@ func _physics_process(delta):

position.x = clamp(position.x, 0, screen_size.size.x - 0)

print("screen_size.size.x:" + str(screen_size.size.x))
print("screen_size.size.x:" + str(screen_size.size))

print("position.x:" + str(position.x))

Expand All @@ -159,6 +159,8 @@ func _physics_process(delta):
get_parent().get_node("EasyStageScene/ParallaxDriver").position.y
)

hud.position.y = get_parent().get_node("EasyStageScene/ParallaxDriver").position.y - 100


func increment_score():
score += 1
Expand Down

0 comments on commit 6c4a717

Please sign in to comment.