Skip to content
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
4 changes: 2 additions & 2 deletions export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ architectures/armeabi-v7a=false
architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
version/code=2
version/name="1.1.2"
version/code=3
version/name="1.1.3"
package/unique_name="org.bulwark.game"
package/name="Bulwark"
package/signed=true
Expand Down
2 changes: 1 addition & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ config_version=5

config/name="Bulwark"
config/description="A minimalist tower defense. Hold the line."
config/version="1.1.2"
config/version="1.1.3"
run/main_scene="res://scenes/main_menu.tscn"
config/features=PackedStringArray("4.7", "GL Compatibility")
config/icon="res://assets/icons/icon.png"
Expand Down
16 changes: 11 additions & 5 deletions src/game/enemy.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ signal died(enemy: Enemy)
signal leaked(enemy: Enemy)

const SPRITE_DIR := "res://assets/sprites/enemies/"
const SPRITE_ANGLE_OFFSET := PI * 0.5

var def: Dictionary = {}
var enemy_id: String = ""
Expand Down Expand Up @@ -72,6 +71,10 @@ func setup(p_def: Dictionary, p_hp: float, p_speed: float, p_armor: float,
var path_sprite := SPRITE_DIR + String(p_def.get("sprite", "grunt")) + ".png"
if ResourceLoader.exists(path_sprite):
_sprite.texture = load(path_sprite)
# Centre the sprite on the unit so rotating it spins around its own centre (the pivot is
# the node origin), not around a corner of the texture.
if _sprite.texture != null:
_sprite.offset = -_sprite.texture.get_size() * 0.5
_sprite.scale = Vector2(scale_factor, scale_factor)
_sprite.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS
add_child(_sprite)
Expand Down Expand Up @@ -141,10 +144,13 @@ func _update_transform() -> void:
position += Vector2(0, -6)
else:
position = base + _lane_offset
# Every sprite is drawn facing "up", so a quarter turn aligns it with the direction of
# travel. Ground units used to keep rotation 0 and always faced the top of the screen; they
# now turn at every bend like the fliers already did.
rotation = dir.angle() + SPRITE_ANGLE_OFFSET
# Sprites are drawn facing "right", so aiming the sprite along the direction of travel
# needs no extra offset. Only the sprite child is rotated: the enemy node itself stays
# unrotated so the health bar drawn above it stays horizontal (top of the screen), and
# ground units turn at every bend exactly like the fliers.
rotation = 0.0
if _sprite != null:
_sprite.rotation = dir.angle()


# --- Combat -------------------------------------------------------------------------------------
Expand Down
17 changes: 14 additions & 3 deletions src/game/game_screen.gd
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var lives_max: int = 0
var gold_earned: int = 0

var _board_root: Node2D
var _board_bg: ColorRect
var _board: Board
var _entities: Node2D
var _projectile_layer: Node2D
Expand Down Expand Up @@ -92,6 +93,16 @@ func _build_world() -> void:
ground_path = PathModel.from_cells(level.get("path", []), grid.cell_size)
air_path = _build_air_path(level.get("path", []))

# Full-screen board-toned backdrop. On a phone the board is scaled to fill the screen, so
# this paints the areas outside the grid with the board's own background colour instead of
# the app background — the playfield reads as one continuous field. Hidden on desktop, where
# the board sits inset on the app background.
_board_bg = ColorRect.new()
_board_bg.color = Palette.BOARD_BG
_board_bg.mouse_filter = Control.MOUSE_FILTER_IGNORE
_board_bg.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
add_child(_board_bg)

_board_root = Node2D.new()
add_child(_board_root)

Expand Down Expand Up @@ -175,15 +186,15 @@ func _apply_starting_state() -> void:
## Phones (and small windows) get the board at the full screen with the HUD floating on top of
## it; desktop keeps the inset layout with the HUD living in the reserved margins.
func _compact_viewport() -> bool:
if OS.has_feature("mobile"):
return true
return size.x < 900.0 or size.y < 560.0
return UIKit.is_compact()


func _layout() -> void:
if _board_root == null:
return
var compact := _compact_viewport()
if _board_bg != null:
_board_bg.visible = compact
var margin_side := COMPACT_INSET if compact else BOARD_MARGIN_SIDE
var margin_top := COMPACT_INSET if compact else BOARD_MARGIN_TOP
var margin_bottom := COMPACT_INSET if compact else BOARD_MARGIN_BOTTOM
Expand Down
5 changes: 3 additions & 2 deletions src/ui/ability_button.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ var _cooldown := 0.0
func setup(def: Dictionary) -> void:
ability_id = String(def.get("id", ""))
_cooldown = maxf(0.1, float(def.get("cooldown", 30.0)))
custom_minimum_size = Vector2(64, 64)
var compact := UIKit.is_compact()
custom_minimum_size = Vector2(64, 64) if not compact else Vector2(80, 80)
focus_mode = Control.FOCUS_ALL
theme_type_variation = "IconButton"
_color = Palette.element_color(String(def.get("color", "energy")))
Expand All @@ -30,7 +31,7 @@ func setup(def: Dictionary) -> void:
center.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
center.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(center)
_glyph = Glyph.of(String(def.get("icon", "bolt")), 26, _color)
_glyph = Glyph.of(String(def.get("icon", "bolt")), 26 if not compact else 34, _color)
center.add_child(_glyph)

_mask = CooldownMask.new()
Expand Down
9 changes: 6 additions & 3 deletions src/ui/build_button.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ var _border: StyleBoxFlat
func setup(id: String, def: Dictionary) -> void:
tower_id = id
cost = int(def.get("cost", 0))
custom_minimum_size = Vector2(74, 82)
var compact := UIKit.is_compact()
custom_minimum_size = Vector2(74, 82) if not compact else Vector2(96, 104)
focus_mode = Control.FOCUS_ALL
theme_type_variation = "IconButton"
tooltip_text = "%s\n%s\n%s %d" % [
Expand All @@ -33,7 +34,7 @@ func setup(id: String, def: Dictionary) -> void:
add_child(column)

_sprite = TextureRect.new()
_sprite.custom_minimum_size = Vector2(0, 46)
_sprite.custom_minimum_size = Vector2(0, 46 if not compact else 60)
_sprite.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
_sprite.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
_sprite.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS
Expand All @@ -47,9 +48,11 @@ func setup(id: String, def: Dictionary) -> void:
price_row.alignment = BoxContainer.ALIGNMENT_CENTER
price_row.add_theme_constant_override("separation", 3)
price_row.mouse_filter = Control.MOUSE_FILTER_IGNORE
_coin = Glyph.of("coin", 12, Palette.GOLD)
_coin = Glyph.of("coin", 12 if not compact else 15, Palette.GOLD)
price_row.add_child(_coin)
_cost_label = UIKit.label(str(cost), "SmallLabel")
if compact:
_cost_label.add_theme_font_size_override("font_size", 16)
price_row.add_child(_cost_label)
column.add_child(price_row)

Expand Down
18 changes: 14 additions & 4 deletions src/ui/credits_screen.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const ENTRIES := [

func _build() -> void:
Audio.play_music("calm")
var compact := UIKit.is_compact()

var column := UIKit.vbox(14)
column.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
Expand All @@ -21,7 +22,7 @@ func _build() -> void:
var header := UIKit.hbox(12)
header.add_child(UIKit.icon_button("back", Palette.TEXT, func() -> void:
Audio.play_sfx("ui_back", -6.0)
App.pop_scene(), 44))
App.pop_scene(), 44 if not compact else 52))
header.add_child(UIKit.label(Loc.t("credits.title"), "TitleLabel"))
column.add_child(header)

Expand All @@ -37,11 +38,20 @@ func _build() -> void:
for entry in ENTRIES:
var card := UIKit.panel("InsetPanel")
var inner := UIKit.card_body(card, 2)
inner.add_child(UIKit.label(Loc.t(String(entry["label"])), "TinyLabel"))
inner.add_child(UIKit.wrapped(String(entry["value"]), "SmallLabel", 720))
var label := UIKit.label(Loc.t(String(entry["label"])), "TinyLabel")
if compact:
label.add_theme_font_size_override("font_size", 14)
inner.add_child(label)
var value := UIKit.wrapped(String(entry["value"]), "SmallLabel", 720)
if compact:
value.add_theme_font_size_override("font_size", 16)
inner.add_child(value)
body.add_child(card)

body.add_child(UIKit.label(Loc.t("credits.made_with"), "TinyLabel"))
var made := UIKit.label(Loc.t("credits.made_with"), "TinyLabel")
if compact:
made.add_theme_font_size_override("font_size", 14)
body.add_child(made)


func on_back() -> void:
Expand Down
42 changes: 32 additions & 10 deletions src/ui/hud.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ signal module_pressed(module_id: String)
signal panel_closed()

const CHIP_HEIGHT := 40.0
const CHIP_HEIGHT_COMPACT := 52.0

var _lives_label: Label
var _gold_label: Label
Expand All @@ -46,11 +47,13 @@ var _ability_buttons: Dictionary = {}
var _bottom_slot: HBoxContainer
var _selected_tower_id := ""
var _wave_total: int = 1
var _compact := false


func _ready() -> void:
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
mouse_filter = Control.MOUSE_FILTER_IGNORE
_compact = UIKit.is_compact()
_build()


Expand Down Expand Up @@ -79,16 +82,24 @@ func _build_top_bar() -> Control:
_wave_label = _chip(row, "wave", Palette.ACCENT)
row.add_child(UIKit.spacer(true))
_speed_button = UIKit.button("1×", "ChipButton", func() -> void: speed_pressed.emit())
_speed_button.custom_minimum_size = Vector2(58, CHIP_HEIGHT)
_speed_button.custom_minimum_size = Vector2(58 if not _compact else 70, _chip_height())
row.add_child(_speed_button)
# Visible only while a tower is armed for placement, so the player has an explicit way out
# (a "cancel zone") without tapping the armed build button again.
_cancel_button = UIKit.button(Loc.t("common.cancel"), "ChipButton",
func() -> void: cancel_pressed.emit())
_cancel_button.custom_minimum_size = Vector2(96, CHIP_HEIGHT)
_cancel_button.custom_minimum_size = Vector2(96 if not _compact else 116, _chip_height())
_cancel_button.visible = false
row.add_child(_cancel_button)
row.add_child(UIKit.icon_button("pause", Palette.TEXT, func() -> void: pause_pressed.emit(), CHIP_HEIGHT))
# On a phone the ability bar moves up here: the bottom strip stays narrow so the board
# underneath is as free as possible, and abilities sit with the other always-visible
# controls where the right thumb reaches them easily.
if _compact:
_ability_row = UIKit.hbox(8)
_ability_row.mouse_filter = Control.MOUSE_FILTER_IGNORE
row.add_child(_ability_row)
row.add_child(UIKit.icon_button("pause", Palette.TEXT, func() -> void: pause_pressed.emit(),
_chip_height()))
return row


Expand All @@ -107,6 +118,9 @@ func _build_bottom_bar() -> Control:
text_box.mouse_filter = Control.MOUSE_FILTER_IGNORE
_status_label = UIKit.label("", "HeadingLabel")
_status_hint = UIKit.label("", "TinyLabel")
if _compact:
_status_label.add_theme_font_size_override("font_size", 22)
_status_hint.add_theme_font_size_override("font_size", 14)
text_box.add_child(_status_label)
text_box.add_child(_status_hint)
status_box.add_child(text_box)
Expand All @@ -116,7 +130,8 @@ func _build_bottom_bar() -> Control:
status_box.add_child(_preview_row)
_call_button = UIKit.button(Loc.t("game.call_now"), "PrimaryButton",
func() -> void: call_wave_pressed.emit())
_call_button.custom_minimum_size = Vector2(196, 42)
_call_button.custom_minimum_size = Vector2(196 if not _compact else 240,
42 if not _compact else 54)
status_box.add_child(_call_button)
var status_wrapper := UIKit.hbox(0)
status_wrapper.mouse_filter = Control.MOUSE_FILTER_IGNORE
Expand All @@ -141,14 +156,20 @@ func _build_bottom_bar() -> Control:
_tower_panel.closed.connect(func() -> void: panel_closed.emit())
_bottom_slot.add_child(_tower_panel)

_bottom_slot.add_child(UIKit.spacer(true))
_ability_row = UIKit.hbox(8)
_ability_row.mouse_filter = Control.MOUSE_FILTER_IGNORE
_bottom_slot.add_child(_ability_row)
if not _compact:
_bottom_slot.add_child(UIKit.spacer(true))
_ability_row = UIKit.hbox(8)
_ability_row.mouse_filter = Control.MOUSE_FILTER_IGNORE
_bottom_slot.add_child(_ability_row)
column.add_child(_bottom_slot)
return column


## Height of the status chips; larger on compact screens so they stay finger-tappable.
func _chip_height() -> float:
return CHIP_HEIGHT_COMPACT if _compact else CHIP_HEIGHT


func _build_toast() -> void:
_toast = UIKit.panel("HudPanel")
_toast.set_anchors_preset(Control.PRESET_CENTER_TOP)
Expand All @@ -172,12 +193,13 @@ func _margin(child: Control, left: int, top: int, right: int, bottom: int) -> Ma
func _chip(row: HBoxContainer, glyph: String, color: Color) -> Label:
var panel := UIKit.panel("HudPanel")
panel.mouse_filter = Control.MOUSE_FILTER_IGNORE
panel.custom_minimum_size.y = _chip_height()
var box := UIKit.hbox(6)
box.mouse_filter = Control.MOUSE_FILTER_IGNORE
panel.add_child(box)
box.add_child(Glyph.of(glyph, 17, color))
box.add_child(Glyph.of(glyph, 17 if not _compact else 21, color))
var value := UIKit.label("0", "NumberLabel")
value.add_theme_font_size_override("font_size", 18)
value.add_theme_font_size_override("font_size", 18 if not _compact else 22)
box.add_child(value)
row.add_child(panel)
return value
Expand Down
38 changes: 27 additions & 11 deletions src/ui/level_select.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ extends Screen
## row on a phone — so six missions stay readable without a horizontal scroll.

const CARD_WIDTH := 280.0
const CARD_WIDTH_COMPACT := 340.0
const CARD_HEIGHT := 210.0
const CARD_HEIGHT_COMPACT := 250.0


func _build() -> void:
Audio.play_music("calm")
var compact := UIKit.is_compact()

var column := UIKit.vbox(16)
column.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
add_content(column)

column.add_child(_build_header())
column.add_child(_build_header(compact))

var scroll := ScrollContainer.new()
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
Expand All @@ -32,15 +36,15 @@ func _build() -> void:
row.add_child(_build_card(index))


func _build_header() -> Control:
func _build_header(compact: bool) -> Control:
var row := UIKit.hbox(12)
row.add_child(UIKit.icon_button("back", Palette.TEXT, func() -> void:
Audio.play_sfx("ui_back", -6.0)
App.goto_scene(App.MENU_SCENE), 44))
App.goto_scene(App.MENU_SCENE), 44 if not compact else 52))
row.add_child(UIKit.label(Loc.t("menu.levels"), "TitleLabel"))
row.add_child(UIKit.spacer(true))
var stars := UIKit.hbox(6)
stars.add_child(Glyph.of("star", 18, Palette.GOLD))
stars.add_child(Glyph.of("star", 18 if not compact else 22, Palette.GOLD))
stars.add_child(UIKit.label(str(App.total_stars()), "GoldLabel"))
row.add_child(stars)
return row
Expand All @@ -53,28 +57,40 @@ func _build_card(index: int) -> Control:
var unlocked := App.is_level_unlocked(index)
var cleared := bool(progress.get("cleared", false))
var stars := int(progress.get("stars", 0))
var compact := UIKit.is_compact()
var card_width := CARD_WIDTH_COMPACT if compact else CARD_WIDTH

var card := UIKit.panel("CardPanel")
card.custom_minimum_size = Vector2(CARD_WIDTH, 210)
card.custom_minimum_size = Vector2(card_width, CARD_HEIGHT_COMPACT if compact else CARD_HEIGHT)
card.size_flags_vertical = Control.SIZE_SHRINK_CENTER
var body := UIKit.card_body(card, 10)

var title_row := UIKit.hbox(8)
title_row.add_child(UIKit.label(Loc.t(String(level.get("name_key", ""))), "HeadingLabel"))
var title := UIKit.label(Loc.t(String(level.get("name_key", ""))), "HeadingLabel")
if compact:
title.add_theme_font_size_override("font_size", 22)
title_row.add_child(title)
title_row.add_child(UIKit.spacer(true))
title_row.add_child(UIKit.label("%d" % (index + 1), "NumberLabel"))
body.add_child(title_row)

body.add_child(UIKit.wrapped(Loc.t(String(level.get("desc_key", ""))), "SmallLabel",
CARD_WIDTH - 40))
var desc := UIKit.wrapped(Loc.t(String(level.get("desc_key", ""))), "SmallLabel",
card_width - 40)
if compact:
desc.add_theme_font_size_override("font_size", 16)
body.add_child(desc)

var star_row := UIKit.hbox(4)
for i in range(3):
star_row.add_child(Glyph.of("star", 18, Palette.GOLD if i < stars else Palette.TEXT_DIM))
star_row.add_child(Glyph.of("star", 18 if not compact else 22,
Palette.GOLD if i < stars else Palette.TEXT_DIM))
body.add_child(star_row)

body.add_child(UIKit.label(
Loc.tf("level.progress", [int(progress.get("best_wave", 0))]), "TinyLabel"))
var progress_label := UIKit.label(
Loc.tf("level.progress", [int(progress.get("best_wave", 0))]), "TinyLabel")
if compact:
progress_label.add_theme_font_size_override("font_size", 14)
body.add_child(progress_label)
body.add_child(UIKit.spacer(false, true))

if not unlocked:
Expand Down
Loading
Loading