Skip to content

Commit f2cf203

Browse files
committed
Improve Bug Hunt on mobile and make the game easier to find
Mobile: non-stop auto-fire (shots pass through firewalls), relative drag anywhere on the stage, taller field in portrait, pause button, no accidental restart on the game over screen, light haptics on Android. Discovery: yellow launcher that opens into "Play" on hover, plus a "Squash some bugs?" link in the home hero.
1 parent 9f95a29 commit f2cf203

6 files changed

Lines changed: 144 additions & 59 deletions

File tree

‎_data/game.yml‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ pt:
1010
theme_dark: "Jogar no modo escuro"
1111
theme_light: "Jogar no modo claro"
1212
launcher: "Jogar?"
13+
launcher_label: "Jogar"
14+
hero_link: "Matar uns bugs? 🐞"
1315
title: "Bug Hunt"
1416
subtitle: "Os bugs estão invadindo o produto. Defenda o deploy!"
1517
move: "mover"
1618
shoot: "atirar"
1719
pause: "pausar"
1820
quit: "sair"
19-
touch: "No celular: arraste o dedo para mover. O tiro é automático."
21+
touch: "No celular: arraste o dedo em qualquer parte da tela para mover. O tiro é automático e atravessa os firewalls."
22+
pause_button: "Pausar"
2023
start_key: "Pressione Espaço ou Enter para começar"
2124
start_touch: "Toque para começar"
2225
start_button: "Começar"
@@ -45,13 +48,16 @@ en:
4548
theme_dark: "Play in dark mode"
4649
theme_light: "Play in light mode"
4750
launcher: "Play?"
51+
launcher_label: "Play"
52+
hero_link: "Squash some bugs? 🐞"
4853
title: "Bug Hunt"
4954
subtitle: "Bugs are invading the product. Defend the deploy!"
5055
move: "move"
5156
shoot: "shoot"
5257
pause: "pause"
5358
quit: "quit"
54-
touch: "On mobile: drag your finger to move. Shooting is automatic."
59+
touch: "On mobile: drag your finger anywhere on the screen to move. Shooting is automatic and goes through the firewalls."
60+
pause_button: "Pause"
5561
start_key: "Press Space or Enter to start"
5662
start_touch: "Tap to start"
5763
start_button: "Start"
@@ -80,13 +86,16 @@ es:
8086
theme_dark: "Jugar en modo oscuro"
8187
theme_light: "Jugar en modo claro"
8288
launcher: "¿Jugamos?"
89+
launcher_label: "Jugar"
90+
hero_link: "¿Aplastamos unos bugs? 🐞"
8391
title: "Bug Hunt"
8492
subtitle: "Los bugs están invadiendo el producto. ¡Defiende el deploy!"
8593
move: "mover"
8694
shoot: "disparar"
8795
pause: "pausar"
8896
quit: "salir"
89-
touch: "En el celular: arrastra el dedo para moverte. El disparo es automático."
97+
touch: "En el celular: arrastra el dedo en cualquier parte de la pantalla para moverte. El disparo es automático y atraviesa los firewalls."
98+
pause_button: "Pausar"
9099
start_key: "Presiona Espacio o Enter para empezar"
91100
start_touch: "Toca para empezar"
92101
start_button: "Empezar"

‎_includes/game.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{%- assign g = site.data.game[lang] | default: site.data.game.pt -%}
33
{%- assign t = site.data.i18n[lang] -%}
44
{%- capture wa_url -%}https://wa.me/{{ site.data.seo.whatsapp }}?text={{ t.whatsapp_message | uri_escape }}{%- endcapture -%}
5-
<button class="game-launcher" type="button" aria-label="{{ g.title }}: {{ g.launcher }}" aria-haspopup="dialog"
5+
<button class="game-launcher" type="button" aria-label="{{ g.title }}: {{ g.launcher_label }}" aria-haspopup="dialog"
66
data-game='{{ g | jsonify | replace: "'", "&#39;" }}' data-whatsapp="{{ wa_url }}" data-cv="/CV_Vagner_Ribas.pdf"
77
data-src="/assets/js/bughunt.js?v={{ site.time | date: '%s' }}">
88
<span class="game-launcher__btn" aria-hidden="true">
@@ -12,5 +12,5 @@
1212
<circle cx="15.6" cy="10.8" r=".6" fill="currentColor"/><circle cx="17.4" cy="12.8" r=".6" fill="currentColor"/>
1313
</svg>
1414
</span>
15-
<span class="game-launcher__tip" aria-hidden="true">{{ g.launcher }}</span>
15+
<span class="game-launcher__label" aria-hidden="true"><span>{{ g.launcher_label }}</span></span>
1616
</button>

‎_layouts/default.html‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,25 @@
147147
// Bug Hunt: load the game only when someone asks to play
148148
var gameBtn = document.querySelector('.game-launcher');
149149
if (gameBtn) {
150-
gameBtn.addEventListener('click', function () {
151-
var open = function () {
152-
window.BugHunt.open({
153-
strings: JSON.parse(gameBtn.getAttribute('data-game')),
154-
whatsapp: gameBtn.getAttribute('data-whatsapp'),
155-
cv: gameBtn.getAttribute('data-cv')
156-
});
157-
};
158-
if (window.BugHunt) return open();
159-
var sc = document.createElement('script');
160-
sc.src = gameBtn.getAttribute('data-src');
161-
sc.onload = open;
162-
document.body.appendChild(sc);
150+
gameBtn.addEventListener('click', openGame);
151+
Array.prototype.forEach.call(document.querySelectorAll('[data-open-game]'), function (b) {
152+
b.addEventListener('click', openGame);
163153
});
164154
}
155+
function openGame() {
156+
var open = function () {
157+
window.BugHunt.open({
158+
strings: JSON.parse(gameBtn.getAttribute('data-game')),
159+
whatsapp: gameBtn.getAttribute('data-whatsapp'),
160+
cv: gameBtn.getAttribute('data-cv')
161+
});
162+
};
163+
if (window.BugHunt) return open();
164+
var sc = document.createElement('script');
165+
sc.src = gameBtn.getAttribute('data-src');
166+
sc.onload = open;
167+
document.body.appendChild(sc);
168+
}
165169

166170
function onScroll() {
167171
header.classList.toggle('is-scrolled', window.scrollY > 10);

‎_layouts/home.html‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
{%- assign base_items = site.work | where: "lang", "pt" | sort: "order" -%}
66
{%- assign local_items = site.work | where: "lang", page.lang -%}
77
{%- assign t = site.data.i18n[page.lang] -%}
8+
{%- assign g = site.data.game[page.lang] | default: site.data.game.pt -%}
89
<section class="hero">
910
<h1 class="hero__title">{{ t.hero_title }}</h1>
1011
<p class="hero__text">{{ t.hero_text }}</p>
1112
<p class="hero__links">
1213
<a href="{{ t.prefix }}/about/">{{ t.hero_about }} &rarr;</a>
1314
<a href="/CV_Vagner_Ribas.pdf" download>{{ t.download_cv }}</a>
1415
<a href="https://www.linkedin.com/in/vagneribas/" target="_blank" rel="noopener noreferrer">LinkedIn</a>
16+
<button type="button" class="hero__game" data-open-game aria-haspopup="dialog">{{ g.hero_link }}</button>
1517
</p>
1618
</section>
1719

‎assets/css/master.css‎

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,11 @@ article.list p { margin: 0; }
791791
.hero__links { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 0; font-weight: 700; }
792792
.hero__links a { text-decoration: none; border-bottom: 2px solid var(--heading); padding-bottom: 2px; }
793793
.hero__links a:hover { border-color: var(--accent); }
794+
.hero__game {
795+
padding: 0 0 2px; border: 0; border-bottom: 2px dashed #e8618c; background: none;
796+
color: var(--heading); font: inherit; font-weight: 700; cursor: pointer;
797+
}
798+
.hero__game:hover { color: #e8618c; }
794799
@media (max-width: 767px) {
795800
.hero { padding: 10px 0 36px; }
796801
.hero__title { font-size: 28px; }
@@ -892,64 +897,67 @@ body.menu-open .wa-float { opacity: 0; pointer-events: none; }
892897
}
893898
@media (prefers-reduced-motion: reduce) {
894899
.wa-float__btn, .wa-float__tip { transition: none; }
900+
.game-launcher, .game-launcher__btn, .game-launcher__label { transition: none; }
895901
}
896902

897903
/* ==========================================================
898904
Bug Hunt mini game
899905
========================================================== */
906+
/* Floating launcher: a yellow round button that opens into a "Play" pill on hover/focus */
900907
.game-launcher {
901908
position: fixed;
902909
left: 24px;
903910
bottom: calc(24px + var(--float-lift, 0px));
904911
z-index: 8;
905912
display: flex;
906913
align-items: center;
907-
gap: 10px;
914+
height: 48px;
908915
padding: 0;
909916
border: 0;
910-
background: none;
917+
border-radius: 100px;
918+
background: #f6c453;
919+
color: #232323;
920+
box-shadow: 0 6px 18px rgba(0, 0, 0, .16);
911921
cursor: pointer;
912922
font: inherit;
923+
transition: transform .2s ease, box-shadow .2s ease;
913924
}
914925
.game-launcher__btn {
915926
display: inline-flex;
916927
align-items: center;
917928
justify-content: center;
918929
width: 48px;
919930
height: 48px;
920-
border-radius: 50%;
921-
background: var(--surface);
922-
color: var(--heading);
923-
box-shadow: 0 0 0 1px var(--line-strong), 0 6px 18px rgba(0, 0, 0, .12);
924-
opacity: .9;
925-
transition: opacity .2s ease, transform .2s ease, color .2s ease;
931+
flex: none;
932+
transition: transform .2s ease;
926933
}
927-
.game-launcher__tip {
928-
padding: 7px 14px;
929-
border-radius: 100px;
930-
background: var(--surface);
931-
color: var(--heading);
934+
.game-launcher__label {
935+
display: grid;
936+
grid-template-columns: 1fr;
937+
overflow: hidden;
932938
font-size: 14px;
933-
font-weight: 600;
939+
font-weight: 700;
934940
white-space: nowrap;
935-
box-shadow: 0 0 0 1px var(--line-strong), 0 6px 18px rgba(0, 0, 0, .1);
941+
grid-template-columns: 0fr;
942+
padding-right: 0;
936943
opacity: 0;
937-
transform: translateX(-8px);
938-
pointer-events: none;
939-
transition: opacity .2s ease, transform .2s ease;
944+
transition: grid-template-columns .3s ease, padding .3s ease, opacity .2s ease;
940945
}
946+
.game-launcher__label > span { min-width: 0; }
947+
.game-launcher:hover,
948+
.game-launcher:focus-visible { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, .2); }
941949
.game-launcher:hover .game-launcher__btn,
942-
.game-launcher:focus-visible .game-launcher__btn { opacity: 1; transform: translateY(-2px) rotate(-8deg); color: var(--accent); }
943-
.game-launcher:hover .game-launcher__tip,
944-
.game-launcher:focus-visible .game-launcher__tip { opacity: 1; transform: translateX(0); }
945-
.game-launcher:focus-visible { outline: none; }
946-
.game-launcher:focus-visible .game-launcher__btn { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
950+
.game-launcher:focus-visible .game-launcher__btn { transform: rotate(-10deg); }
951+
.game-launcher:hover .game-launcher__label,
952+
.game-launcher:focus-visible .game-launcher__label { grid-template-columns: 1fr; padding-right: 18px; opacity: 1; }
953+
.game-launcher:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
947954
body.menu-open .game-launcher,
948955
.bh-open .game-launcher,
949956
.bh-open .wa-float { opacity: 0; pointer-events: none; }
950957
@media (max-width: 767px) {
951-
.game-launcher { left: 16px; bottom: calc(16px + var(--float-lift, 0px)); }
958+
.game-launcher { left: 16px; bottom: calc(16px + var(--float-lift, 0px)); height: 44px; }
952959
.game-launcher__btn { width: 44px; height: 44px; }
960+
.game-launcher__label { font-size: 13px; }
953961
}
954962

955963
/* Overlay: the site stays visible behind a translucent, blurred layer */
@@ -993,7 +1001,7 @@ body.menu-open .game-launcher,
9931001
}
9941002
.bh-close:hover { background: var(--chip-bg); }
9951003

996-
.bh-stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; touch-action: none; user-select: none; -webkit-user-select: none; }
1004+
.bh-stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
9971005
.bh-stage > .bh-screen { left: 50%; top: 50%; right: auto; bottom: auto; transform: translate(-50%, -50%); width: var(--bh-w, 100%); height: var(--bh-h, 100%); }
9981006
.bh-canvas {
9991007
display: block;
@@ -1080,3 +1088,9 @@ kbd.bh-wide { min-width: 64px; }
10801088
.bh-hint--touch { display: block; }
10811089
}
10821090
.bh-tools { display: flex; gap: 8px; flex: none; }
1091+
.bh-close[hidden] { display: none; }
1092+
@media (max-width: 420px) {
1093+
.bh-best { display: none; }
1094+
.bh-tools { gap: 6px; }
1095+
.bh-close { width: 38px; height: 38px; }
1096+
}

0 commit comments

Comments
 (0)