Your first game
View as MarkdownYour first game is Zoom Out, the sample game: a photo starts zoomed in six times, pulls back over 15 seconds, and the faster a viewer names it, the more they score. The whole game is about 30 lines, and it runs as-is in the lab.
Playcade.game({ id: 'zoom-out', title: 'Zoom Out', tagline: 'A photo starts zoomed all the way in. Name it before it pulls back.', inputs: ['guess'], rounds: 2, content: [ { answer: 'pizza', also: ['pizza slice', 'a pizza'], photo: 'photos/zoom-pizza.jpg' }, { answer: 'pineapple', also: ['ananas'], photo: 'photos/zoom-pineapple.jpg' }, ],
async round({ item, show, chat, phone, house, reveal }) { const pic = show.image(Playcade.asset(item.photo), { zoom: 6 }) phone.prompt({ text: 'What is it?' }) house.answer(item.answer, { wrong: ['cake', 'flower', 'a planet', 'cheese'] })
chat.onAnswer((player, text, { at }) => { if (text.matches([item.answer, ...item.also])) player.correct(1000 - at * 40) })
await pic.zoomOut({ seconds: 15 }) await reveal("It's a " + item.answer) },})What each part does
Section titled “What each part does”-
The definition.
id,titleandinputsare required.contentholds one item per round; the runtime shuffles it, androundscaps how many are played. -
The picture.
show.image()puts the photo in the game area, zoomed in six times, and returns a handle you animate later. -
Phones and the house.
phone.prompt()sets what phone players see.house.answer()lets the house player guess on quiet rounds, using the wrong answers you give it. -
Scoring.
chat.onAnswer()gets every guess from chat and phones.text.matches()checks it loosely, andplayer.correct()scores it once, here 1000 points minus 40 for every second that passed. -
The reveal.
zoomOut()runs the timer while the picture pulls back, andreveal()closes the round and shows who got it.
When the SDK ships as a package
Section titled “When the SDK ships as a package”Today the runtime is a plain script, so the object goes to Playcade.game(). Once the SDK ships as a package, the same object goes to game(), and nothing else changes:
import { game } from '@playcade/sdk'export default game({ /* the same definition */ })