diff --git a/src/gameobjects/modal.ts b/src/gameobjects/modal.ts index 254b2f1..16d617e 100644 --- a/src/gameobjects/modal.ts +++ b/src/gameobjects/modal.ts @@ -1,8 +1,4 @@ -interface Options { - hidden?: boolean -} - -export function addModal(options?: Options) { +export function addModal() { const modal = add([ rect(width(), height()), color(0, 0, 0), @@ -10,9 +6,5 @@ export function addModal(options?: Options) { fixed(), ]) - if (typeof options?.hidden === 'boolean') { - modal.hidden = options.hidden - } - return modal } diff --git a/src/gameobjects/pause.ts b/src/gameobjects/pause.ts index 6712924..fadfac3 100644 --- a/src/gameobjects/pause.ts +++ b/src/gameobjects/pause.ts @@ -13,7 +13,8 @@ export function addPause() { } }) - const modal = addModal({ hidden: true }) + const modal = addModal() + modal.hidden = true const pauseMenu = modal.add([ rect(340, 300), @@ -63,10 +64,6 @@ export function addPause() { easings.easeOutElastic, ) - if (game.paused) { - modal.hidden = false - } else { - modal.hidden = true - } + modal.hidden = !game.paused } } diff --git a/src/gameobjects/reward.ts b/src/gameobjects/reward.ts index 1db4709..8d96138 100644 --- a/src/gameobjects/reward.ts +++ b/src/gameobjects/reward.ts @@ -58,16 +58,26 @@ export function addReward() { game.paused = true const modal = addModal() - const container = modal.add([pos(center())]) + const { x, y } = center() + + const rewardMenu = modal.add([ + rect(500, 400), + color(255, 255, 255), + outline(4), + anchor('center'), + pos(x, y + 700), + ]) + + rewardMenu.hidden = true addText({ - width: 550, - height: 80, + width: 0, + height: 0, x: 0, y: -120, text: 'Choose a reward', fontSize: 48, - parent: container, + parent: rewardMenu, }) getRewards().forEach((reward, index) => { @@ -84,17 +94,19 @@ export function addReward() { game.reward = false game.paused = false }, - parent: container, + parent: rewardMenu, }) }) tween( - container.pos, - center(), + rewardMenu.pos, + game.paused ? center() : center().add(0, 700), 1, - (position) => (container.pos = position), + (position) => (rewardMenu.pos = position), easings.easeOutElastic, ) + + rewardMenu.hidden = false } function getRewards(total = 2) {