Spaces:
Running

FormaLau commited on
Commit
6e1d55b
Β·
verified Β·
1 Parent(s): 5397bb5

Add wordless comic thought bubbles and blue lettering

Browse files

Replace subtitles with emotion and activity pictograms.

app/src/pet/PetPanel.jsx CHANGED
@@ -1,13 +1,13 @@
1
  ο»Ώimport { useEffect, useRef, useState } from 'react';
2
  import { useGame, gameApi, bootLog } from '../store.js';
3
- import { ACTIVITY, happiness } from './engine.js';
4
  import { usePet, advance, care, rename, savePet, resumePet, suspendPet, physicalEvent, configure, resetNeeds } from './store.js';
5
  import { petVoice } from './emotions.js';
6
- import './pet.css';
 
7
 
8
  const NEEDS = [['satiety','Food'],['hydration','Water'],['energy','Energy'],['stimulation','Joy'],['affection','Affection']];
9
  const ACTIONS = [['feed','β—’','Feed','Fresh vegetables'],['drink','β—‰','Drink','Water on the table'],['treat','β™§','Give a treat','A little delight'],['ball','⚽','Throw ball','Chase and kick'],['goal','βš‘','Score a goal','Aim for the net'],['roll','↻','Somersault','A playful tumble'],['cuddle','β™‘','Cuddle','A little love'],['rest','☾','Sleep','Time to recharge']];
10
- const PHASES = {'sleep-approach':'Going to bed','sleeping':'Sleeping peacefully','drink-approach':'Going to the water bowl','drink-sip':'Taking a drink','treat-approach':'Walking to the snack plate','treat-peck':'A delicious treat','meal-approach':'Walking to the table','meal-peck':'Taking a bite','meal-chew':'Yum!','ball-detour':'Chasing the ball','ball-stage':'Chasing the ball','ball-approach':'Getting ready to kick','ball-settle':'Lining up a kick','ball-kick':'Kick!','roll-approach':'Finding room to roll','roll-running':'Somersault!','course-approach':'Following the rings'};
11
  export default function PetPanel() {
12
  const {pet,paused,speed,storageError,scene,soundEnabled,soundError,environment,subtitles}=usePet();
13
  const [games,setGames]=useState(false),[closeup,setCloseup]=useState(false),[profileOpen,setProfileOpen]=useState(true),[details,setDetails]=useState(false);
@@ -27,7 +27,7 @@ export default function PetPanel() {
27
  <header className="pet-header"><a className="pet-brand" href="?">Duck<span>Agochi</span><i>Small moments. Real feelings.</i></a>
28
  <div className="pet-header-actions">
29
  <label className="pet-environment">Environment<select aria-label="Environment" value={environment} onChange={e=>{configure({environment:e.target.value});setCloseup(false);gameApi.petCamera?.();}}><option value="home">Cozy home</option><option value="bedroom">Child's bedroom</option><option value="lake">By the lake</option></select></label>
30
- <button className="pet-top-button" aria-pressed={subtitles} onClick={()=>configure({subtitles:!subtitles})}>{subtitles?'Hide subtitles':'Show subtitles'}</button>
31
  <button className="pet-top-button" onClick={async()=>{if(soundEnabled){petVoice.mute();usePet.setState({soundEnabled:false});}else{petVoice.userMuted=false;await unlockSound();petVoice.start('yes');}}}>{soundEnabled?'Sound on':'Sound off'}</button>
32
  <button className="pet-top-button" onClick={()=>{setCloseup(!closeup);gameApi.petCamera?.(!closeup);}}>{closeup?'Wide view':'Close up'}</button>
33
  </div>
@@ -40,7 +40,7 @@ export default function PetPanel() {
40
  <button className="pet-details-button" onClick={()=>setDetails(!details)}>{details?'Close journal':'Open journal'}</button>
41
  <button className="pet-details-button" onClick={()=>{resetNeeds();setDetails(false);}}>Reset to low needs</button>
42
  </aside>}
43
- {subtitles&&<section className="pet-thought pet-status" aria-live="polite"><span>{paused?'Paused':(environment==='lake' && scene.phase==='drink-approach'?'Going to the lakeshore':PHASES[scene.phase])||ACTIVITY[pet.activity]}</span><p>{pet.reason}</p></section>}
44
  {pet.task&&<button className="pet-cancel pet-top-button" onClick={()=>physicalEvent('finish',false)}>Stop activity Γ—</button>}
45
  {soundError&&<p className="pet-sound-error" role="status">Sound could not start. Try the sound button again.</p>}
46
  {games&&<section className="pet-card pet-games"><div className="pet-eyebrow">TIME TOGETHER</div><h2>What shall we play?</h2><button onClick={()=>action('ball')}><b>⚽ Throw ball</b><span>Chase it and kick Β· {scene.kicks} kicks Β· {scene.goals} goals</span></button><button onClick={()=>action('roll')}><b>↻ Somersault</b><span>A little tumble Β· {scene.rolls} completed</span></button><button onClick={()=>action('course')}><b>β—Ž Ring trail</b><span>Follow three rings Β· {scene.rings} reached</span></button><small>A tired duck needs sleep before playing.</small></section>}
 
1
  ο»Ώimport { useEffect, useRef, useState } from 'react';
2
  import { useGame, gameApi, bootLog } from '../store.js';
3
+ import { happiness } from './engine.js';
4
  import { usePet, advance, care, rename, savePet, resumePet, suspendPet, physicalEvent, configure, resetNeeds } from './store.js';
5
  import { petVoice } from './emotions.js';
6
+ import './pet.css';
7
+ import ThoughtBubble from './ThoughtBubble.jsx';
8
 
9
  const NEEDS = [['satiety','Food'],['hydration','Water'],['energy','Energy'],['stimulation','Joy'],['affection','Affection']];
10
  const ACTIONS = [['feed','β—’','Feed','Fresh vegetables'],['drink','β—‰','Drink','Water on the table'],['treat','β™§','Give a treat','A little delight'],['ball','⚽','Throw ball','Chase and kick'],['goal','βš‘','Score a goal','Aim for the net'],['roll','↻','Somersault','A playful tumble'],['cuddle','β™‘','Cuddle','A little love'],['rest','☾','Sleep','Time to recharge']];
 
11
  export default function PetPanel() {
12
  const {pet,paused,speed,storageError,scene,soundEnabled,soundError,environment,subtitles}=usePet();
13
  const [games,setGames]=useState(false),[closeup,setCloseup]=useState(false),[profileOpen,setProfileOpen]=useState(true),[details,setDetails]=useState(false);
 
27
  <header className="pet-header"><a className="pet-brand" href="?">Duck<span>Agochi</span><i>Small moments. Real feelings.</i></a>
28
  <div className="pet-header-actions">
29
  <label className="pet-environment">Environment<select aria-label="Environment" value={environment} onChange={e=>{configure({environment:e.target.value});setCloseup(false);gameApi.petCamera?.();}}><option value="home">Cozy home</option><option value="bedroom">Child's bedroom</option><option value="lake">By the lake</option></select></label>
30
+ <button className="pet-top-button" aria-pressed={subtitles} onClick={()=>configure({subtitles:!subtitles})}>{subtitles?'Hide thoughts':'Show thoughts'}</button>
31
  <button className="pet-top-button" onClick={async()=>{if(soundEnabled){petVoice.mute();usePet.setState({soundEnabled:false});}else{petVoice.userMuted=false;await unlockSound();petVoice.start('yes');}}}>{soundEnabled?'Sound on':'Sound off'}</button>
32
  <button className="pet-top-button" onClick={()=>{setCloseup(!closeup);gameApi.petCamera?.(!closeup);}}>{closeup?'Wide view':'Close up'}</button>
33
  </div>
 
40
  <button className="pet-details-button" onClick={()=>setDetails(!details)}>{details?'Close journal':'Open journal'}</button>
41
  <button className="pet-details-button" onClick={()=>{resetNeeds();setDetails(false);}}>Reset to low needs</button>
42
  </aside>}
43
+ {subtitles&&<ThoughtBubble pet={pet} paused={paused}/>}
44
  {pet.task&&<button className="pet-cancel pet-top-button" onClick={()=>physicalEvent('finish',false)}>Stop activity Γ—</button>}
45
  {soundError&&<p className="pet-sound-error" role="status">Sound could not start. Try the sound button again.</p>}
46
  {games&&<section className="pet-card pet-games"><div className="pet-eyebrow">TIME TOGETHER</div><h2>What shall we play?</h2><button onClick={()=>action('ball')}><b>⚽ Throw ball</b><span>Chase it and kick Β· {scene.kicks} kicks Β· {scene.goals} goals</span></button><button onClick={()=>action('roll')}><b>↻ Somersault</b><span>A little tumble Β· {scene.rolls} completed</span></button><button onClick={()=>action('course')}><b>β—Ž Ring trail</b><span>Follow three rings Β· {scene.rings} reached</span></button><small>A tired duck needs sleep before playing.</small></section>}
app/src/pet/ThoughtBubble.jsx ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {useEffect, useState} from 'react';
2
+
3
+ const EMOTIONS = {
4
+ sad: ['πŸ₯Ί', 'πŸ’”', 'Missing affection'], devastated: ['😞', 'πŸ’§', 'Feeling down'],
5
+ impatient: ['😣', 'πŸ₯•', 'Hungry'], defiant: ['😀', 'πŸ’€', 'Too tired to play'],
6
+ no: ['πŸ™…', 'πŸ₯•', 'Food before play'], angry: ['😠', 'πŸ’’', 'Upset'],
7
+ excited: ['🀩', '✨', 'Excited'], laugh: ['πŸ˜†', 'πŸŽ‰', 'Delighted'],
8
+ curious: ['πŸ‘€', '❔', 'Curious'], mmh: ['πŸ€”', 'πŸ’­', 'Thinking'],
9
+ yes: ['😊', '✨', 'Happy'], yes_fast: ['😊', '✨', 'Happy'],
10
+ };
11
+ function thought(pet, emotion, paused) {
12
+ if(paused)return ['⏸️', 'πŸ’­', 'Paused'];
13
+ if(pet.sleeping)return ['😴', 'πŸ’€', 'Sleeping'];
14
+ if(emotion && EMOTIONS[emotion])return EMOTIONS[emotion];
15
+ if(pet.activity==='rest')return ['πŸ₯±', 'πŸ›οΈ', 'Time to rest'];
16
+ if(pet.activity==='eat')return ['πŸ˜‹', 'πŸ₯•', 'Eating'];
17
+ if(pet.activity==='drink')return ['πŸ’§', 'πŸ₯€', 'Drinking'];
18
+ if(pet.activity==='treat')return ['πŸ˜‹', 'πŸͺ', 'Enjoying a treat'];
19
+ if(pet.activity==='cuddle')return ['πŸ₯°', 'πŸ’•', 'Enjoying affection'];
20
+ if(pet.activity==='play')return pet.playStyle==='roll'?['🀸', '✨', 'Somersault']:['⚽', '✨', 'Playing'];
21
+ if(pet.activity==='explore')return pet.playStyle==='rollers'?['πŸ›Ό', '✨', 'Skating']:['πŸ‘£', 'πŸ‘€', 'Exploring'];
22
+ const needs=[['affection',40,['πŸ₯Ί','πŸ’•','Needs affection']],['stimulation',35,['😞','⚽','Needs fun']],['energy',30,['πŸ₯±','πŸ’€','Needs rest']],['satiety',45,['πŸ₯•','🍽️','Hungry']],['hydration',30,['πŸ’§','πŸ₯€','Thirsty']]];
23
+ const low=needs.filter(([key,limit])=>pet.needs[key]<limit).sort((a,b)=>pet.needs[a[0]]/a[1]-pet.needs[b[0]]/b[1]);
24
+ return low[0]?.[2] || ['😊','β˜€οΈ','Feeling content'];
25
+ }
26
+ export default function ThoughtBubble({pet, paused}) {
27
+ const [emotion,setEmotion]=useState(pet.emotion);
28
+ useEffect(()=>{
29
+ setEmotion(pet.emotion);
30
+ const timer=setTimeout(()=>setEmotion(null),6500);
31
+ return ()=>clearTimeout(timer);
32
+ },[pet.emotionSeq,pet.emotion]);
33
+ const [face,symbol,label]=thought(pet,emotion,paused);
34
+ return <section className="pet-thought pet-status pet-thought-bubble" role="img" aria-label={label}>
35
+ <svg className="pet-thought-cloud" viewBox="0 0 220 150" aria-hidden="true">
36
+ <path d="M43 104C18 104 8 88 17 71C1 51 16 30 37 32C38 9 65 4 81 19C96 1 127 5 137 20C163 4 189 17 187 36C213 35 224 61 207 77C218 99 193 117 172 109C156 127 128 120 116 111C92 126 66 120 60 108Z"/>
37
+ <ellipse cx="80" cy="132" rx="10" ry="7"/><ellipse cx="60" cy="145" rx="5" ry="4"/>
38
+ </svg>
39
+ <div className="pet-thought-symbols" key={face+symbol} aria-hidden="true"><span>{face}</span><span>{symbol}</span></div>
40
+ </section>;
41
+ }
app/src/pet/pet.css CHANGED
@@ -34,3 +34,16 @@
34
  .pet-profile{width:220px;padding:18px;max-height:calc(100% - 310px)}.pet-profile h1{font-size:30px}.pet-bond{margin-top:12px;padding-top:10px}.pet-need{margin:10px 0}.pet-scores{font-size:11px;color:#536e50;margin-top:15px}.pet-actions{display:grid;grid-template-columns:repeat(9,1fr)}.pet-actions button{min-width:85px;padding:10px 7px}.pet-status{top:105px}.pet-profile~.pet-status{top:105px}.pet-thought p{margin-top:7px}.pet-footer{bottom:12px}.pet-environment select{min-width:125px}
35
  @media(max-width:1050px){.pet-actions{grid-template-columns:repeat(5,1fr)}.pet-actions button{min-width:70px}.pet-actions small{display:none}.pet-footer{width:min(650px,calc(100% - 24px))}}
36
  @media(max-width:540px){.pet-profile{top:145px;width:calc(100% - 32px);padding:10px 14px;max-height:235px}.pet-profile h1{font-size:20px}.pet-needs{display:grid;grid-template-columns:repeat(5,1fr);gap:6px}.pet-need{margin:2px 0}.pet-scores{margin-top:7px}.pet-profile .pet-bond{margin-top:5px;padding-top:5px}.pet-details-button{display:inline-block;width:auto;margin-right:12px}.pet-profile~.pet-status{top:375px}.pet-status>span{font-size:10px}.pet-status p{font-size:10px;padding:7px}.pet-actions{grid-template-columns:repeat(5,1fr)}.pet-actions button{min-width:0;padding:5px 2px}.pet-actions strong{font-size:9px}.pet-summary{top:105px}.pet-cancel{top:110px}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  .pet-profile{width:220px;padding:18px;max-height:calc(100% - 310px)}.pet-profile h1{font-size:30px}.pet-bond{margin-top:12px;padding-top:10px}.pet-need{margin:10px 0}.pet-scores{font-size:11px;color:#536e50;margin-top:15px}.pet-actions{display:grid;grid-template-columns:repeat(9,1fr)}.pet-actions button{min-width:85px;padding:10px 7px}.pet-status{top:105px}.pet-profile~.pet-status{top:105px}.pet-thought p{margin-top:7px}.pet-footer{bottom:12px}.pet-environment select{min-width:125px}
35
  @media(max-width:1050px){.pet-actions{grid-template-columns:repeat(5,1fr)}.pet-actions button{min-width:70px}.pet-actions small{display:none}.pet-footer{width:min(650px,calc(100% - 24px))}}
36
  @media(max-width:540px){.pet-profile{top:145px;width:calc(100% - 32px);padding:10px 14px;max-height:235px}.pet-profile h1{font-size:20px}.pet-needs{display:grid;grid-template-columns:repeat(5,1fr);gap:6px}.pet-need{margin:2px 0}.pet-scores{margin-top:7px}.pet-profile .pet-bond{margin-top:5px;padding-top:5px}.pet-details-button{display:inline-block;width:auto;margin-right:12px}.pet-profile~.pet-status{top:375px}.pet-status>span{font-size:10px}.pet-status p{font-size:10px;padding:7px}.pet-actions{grid-template-columns:repeat(5,1fr)}.pet-actions button{min-width:0;padding:5px 2px}.pet-actions strong{font-size:9px}.pet-summary{top:105px}.pet-cancel{top:110px}}
37
+
38
+ /* Ink-blue comic lettering and wordless thought clouds. */
39
+ .pet-app .pet-brand{font-family:"Trebuchet MS",system-ui,sans-serif;font-weight:900;font-style:italic;color:#243e70;letter-spacing:-1.3px;text-shadow:1px 2px 0 #fff9ee,2px 3px 0 #a9c9ef}
40
+ .pet-app .pet-brand>span{color:#487cbb;background:none;font-size:inherit;padding:0;margin:0;letter-spacing:inherit}
41
+ .pet-brand i{font-family:system-ui,sans-serif;font-style:normal;text-shadow:none;letter-spacing:.3px}
42
+ .pet-thought-bubble.pet-status{width:190px;max-width:190px;height:130px;filter:drop-shadow(0 4px 5px #243e701c);pointer-events:none}
43
+ .pet-thought-cloud{display:block;width:100%;height:100%;overflow:visible;fill:#fffdf7;stroke:#36465f;stroke-width:2.5;stroke-linejoin:round}
44
+ .pet-thought-symbols{position:absolute;inset:18px 18px 36px;display:flex;align-items:center;justify-content:center;gap:13px;animation:pet-thought-appear .25s ease-out}
45
+ .pet-thought-symbols span{font-family:"Apple Color Emoji","Segoe UI Emoji",sans-serif;font-size:36px;line-height:1.2;filter:drop-shadow(0 2px 0 #243e7010)}
46
+ @keyframes pet-thought-appear{from{opacity:0;transform:scale(.85)}to{opacity:1;transform:scale(1)}}
47
+ @media(max-width:540px){.pet-thought-bubble.pet-status{width:145px;max-width:145px;height:100px}.pet-thought-symbols{inset:12px 14px 28px;gap:9px}.pet-thought-symbols span{font-size:28px}}
48
+ @media(max-height:500px) and (orientation:landscape){.pet-thought-bubble.pet-status{width:140px;max-width:140px;height:96px}}
49
+ @media(prefers-reduced-motion:reduce){.pet-thought-symbols{animation:none}}