Communitygithub.com

evalix098/tiktoklive

ブラウザゲームやインタラクティブ/キャンバス/3D体験をTanStack Start + Reactアプリで構築します。あらゆるゲーム、シミュレーション、WebGL/Canvas体験(2D/3D、シングルプレイヤー)に対応。ゲームループとタイミング、3D座標系、衝突判定、パフォーマンス、アセット、オーディオ、セーブ、ゲームフィール、ジャンル別プレイブックを網羅。WASD / 車両 / フライトの入力符号とA/D反転については、**`controls`**スキルを参照してください。

tiktoklive とは?

このスキルは、TanStack Start + Reactアプリ上で本格的なブラウザゲームを構築するための包括的なガイドです。ゲームループの正しい実装(デルタタイム計算、フレームレート非依存、固定タイムステップ)、3D座標系とカメラの扱い(three.jsの右手系、メッシュとカメラの向きの違い)、パフォーマンス最適化、アセット管理(3Dモデルは3Dジオメトリで構築、生成画像は2Dのみ)、オーディオ、セーブ、モバイル対応など、ゲーム開発に必須の知識を網羅しています。特に、WASD操作や車両・飛行機の操縦における入力符号の正しい扱いは別スキル`controls`に委譲し、このファイル単独では不十分な点を明示しています。参考資料として、three.js、Phaser、Babylon.jsなどのエンジン固有のリファレンスや、FPS、プラットフォーマー、レーシングなどジャンル別のプレイブックをロード可能です。完成基準として、コンソールエラーなし、controlsスキルの自己テスト合格、モバイル対応、本番ビルド動作が求められます。

対応✓Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/evalix098/tiktoklive/tree/HEAD/.grok/skills/building-games

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

ゲーム構築

プレイ可能で正しいブラウザゲームを構築します — 静的なスクリーンショットではありません。ゲームとは、<canvas>(またはR3Fの場合は<Canvas>)とDOMオーバーレイUIを持つReactルートに過ぎません。オーバーレイ(スタート画面、HUD、メニュー)のスタイリングは**design-ui**スキルに任せ、このスキルはゲームプレイループとワールドを担当します。

コントロール / A/D反転: WASD、ステアリング、フライト入力を書く前に、**.grok/skills/controls/SKILL.md**を開いてください。このファイルや単一ジャンルのプレイブックだけを読むと、車両/フライトのデモでA/Dが反転して出荷されることがよくあります。

適用範囲 — シングルプレイヤー、ボット、または小規模P2P協力:

  • デフォルトではシングルプレイヤーまたはシングルプレイヤー + AI/ボットを出荷します。
  • 2〜8人の協力プレイ / カジュアルリアルタイム(共有カーソル、パーティーゲーム、友人同士のカジュアルアクション)はサポートされています — multiplayer-p2pスキル(WebRTCメッシュ、/api/rtcでシグナリング)を使用してください。最初にその信頼モデルを読んでください。
  • P2Pが現在サポートされている唯一のマルチプレイヤー方式です。接続できないソケットを中途半端に構築しないでください。

リファレンス(オンデマンドでロード):

  • controlsスキル(../controls/) — 移動/操縦/フライトに必須: プレイヤーから見たA/D、反転操縦アンチパターン、フライト補助翼、必須の自己テスト + window.__controlsTest。車両/飛行機では必須です。
  • references/threejs-foundational.md — 詳細な3D/ループ/パフォーマンスリファレンス。3Dの場合はこちらを読んでください。
  • references/3d-libs.md — three.js + @react-three/fiber + drei + rapierの使用方法。
  • threejsスキル(../threejs/) — 公式の完全なThree.js + TSL APIダンプ(llms-full.txt)。高度なマテリアル/シェーダー/WebGPU/ローダーに使用します。単純な2Dキャンバスゲームには使用しません。
  • references/babylon.md — Babylon.js、バッテリー同梱の3Dエンジンの代替。
  • references/phaser.md — Phaser 3、2Dゲームのデフォルトエンジン。
  • references/ecs-architecture.md — 大規模ゲーム向けエンティティ・コンポーネント・システム構造。
  • references/genres/*.md — ジャンル別プレイブック(FPS、platformer-2d、racing-kart、puzzle-match3-tetris、voxel-minecraft、endless-runner、topdown-twin-stick、tower-defense、board-card-chess)。ジャルファイルは**controls**の代わりにはなりません。
  • references/game-feel-juice.md、input.md、audio.md、collision-physics.md、save-persistence.md、procedural-generation.md、ai-pathfinding.md。
  • game-asset-core(+ game-animation-frames / game-tilesets / game-character-consistency / game-ui-icons) — スプライト、シート、タイル、UIを生成する際の、エンジン対応2Dアートのデフォルト設定と検証(§6参照)。

構築する特定のジャンル/トピックのリファレンスを選択してください。このファイルはループ/ワールドのためのユニバーサルコアです。入力符号 → controls。 2Dゲームアート → game-asset-core。


1. ゲームループとタイミング(最も重要な正確性の問題)

  • エンジンのRAFループ(renderer.setAnimationLoop、R3FのuseFrame、または2DキャンバスのrequestAnimationFrame)でループを駆動します。ゲームタイミングに決してsetInterval/setTimeout/Date.now()を使用しないでください。
  • すべての移動/アニメーションをデルタタイム(秒)でスケーリングし、速度をフレームレート非依存(60Hz vs 144Hz)にします。デルタはフレームごとに1回計算し、再利用します。
    • three.js: THREE.Timerを使用します(Clockは使用しないでください — Clock.getDelta()は同じフレーム内で2回目に呼び出すと〜0を返し、古典的なフリーズバグの原因になります)。
  • デルタをキャップします(min(delta, 0.1))。バックグラウンドタブでオブジェクトが瞬間移動するのを防ぎます。
  • 物理/ゲームプレイには固定タイムステップ: デルタを蓄積し、ディスプレイレートでレンダリングしながら、シミュレーションを固定レート(例:1/60)でステップ実行します — トンネリングと非決定性を防ぎます。

2. コントロール(controlsスキルに委任)

WASD / 操縦 / フライトコードを実装する前に、.grok/skills/controls/SKILL.mdを開いてください。 そのスキルが以下の真実の情報源です:

  • プレイヤーから見える A = 左 / D = 右(チェイスカメラ、前進中)
  • なぜ KeyA → steer− + yaw += steer * +rateが反転するのか(最も一般的なバグ)
  • 車両 vs FPS(ストレイフ ≠ 操縦)、固定翼補助翼、ヘリ/ドローンの注意点
  • 必須の自己テスト + window.__controlsTestプローブ

genres/racing-kart.mdを操縦符号の唯一の場所として扱わないでください — 飛行機、ジェットスキー、メカはそれを開くことはありません。

簡単なリマインダー(詳細はcontrols内):

// 車両のヨー本体(チェイスカメラ): Aはこの基底でヨーを増加させる必要があります
forward = (-sin(yaw), 0, -cos(yaw))
// KeyA → steer = +1;  yaw += steer * turnRate * speedFactor * dt
// 間違い(反転して出荷): KeyA → steer = -1; yaw += steer * turnRate * dt
  • ポインターロック: マウスルックのみ — WASDは自分で実装。クリックしてプレイするオーバーレイ。ロック時に解除。
  • キーの押下状態とdtを追跡。references/input.mdを介してデバイスを統合。
  • 完了: controlsスキルのチェックリストを実行。スクリーンショットのみでは車両/飛行機には不十分です。

3. 3D座標系とワールドオブジェクト(「横向き/後ろ向き」バグ)

  • three.jsは右手系、+Y上: +X右、+Y上、+Zビューア方向。メッシュは+Zを向き、カメラは−Zを見ます(古典的な「カメラが後ろ向き」の落とし穴)。
  • Cone/Cylinderのようなプリミティブはデフォルトで**+Y**を指します → 先端を前方に合わせるために回転します(geo.rotateX(Math.PI/2))。
  • メッシュをforwardに向ける(メッシュは**+Zを向く): 最も簡単な正しい方法はmesh.lookAt(mesh.position.clone().add(forward))です。手動で基底を構築するには、+Z列をforwardに設定し、それが適切な右手回転(det = +1)を維持するようにx軸を選択します: xAxis = normalize(cross(up, forward))、次にmakeBasis(xAxis, up, forward)。 これは cross(up, forward) であることに注意してください — §2の移動用right = cross(forward, up)とは異なります。メッシュはカメラの−Zではなく+Zをターゲットにするため、x軸の符号が反転し、xAxis × up = forwardとなります。フレームは右手系を維持します(ミラーリングなし)。メッシュにmakeBasis(xAxis, up, -forward)を使用しないでください** — それは−forward(カメラの慣例)をターゲットにするため、メッシュが後ろ向きになります。
  • カメラをforwardに沿って向ける(カメラは**−Z**を見る): +Z列を-forwardに設定 — xAxis = normalize(cross(forward, up))、次にmakeBasis(xAxis, up, -forward)(または単にcamera.lookAt(target))。
  • 一貫したワールドupを維持してオブジェクトを直立させます。平らなプリミティブだけを回転させて立てます。
  • glTFインポートの向きを検証。AxesHelper/ArrowHelperでデバッグ。直立自己テスト: キャラクターが地面に立っており、横たわったり沈み込んだりしていないことを確認。

4. カメラは移動と一致する必要があります

  • 専用の**moveForward/moveRight**を移動用に保持し、一度計算してカメラコードで決して変更しないでください(共有テンポラリベクトルをエイリアスするとカメラと移動が不一致になります — 実際の再現バグです)。
  • 三人称追従: desired = playerPos + up*height + moveForward*(-followDist)。カメラをそれに向かってlerpします(指数ベースのスムージング、デルタスケールを使用)、lookAt(player)。
  • レイヤー分離デバッグ順序: (1) キーが登録される → (2) 移動符号が正しい → (3) カメラが一致する。この順序で修正します。

5. パフォーマンス

  • 描画呼び出しを最小化(renderer.info.render.calls、目標<100): マテリアルを共有、InstancedMesh/BatchedMeshを繰り返しオブジェクトに、アトラスを使用。
  • GPUリソースを自分で破棄(geometry/material/texture.dispose())レベルチェンジ時 — three.jsはそれらをGCしません。弾丸/敵/パーティクルをプールします。
  • フレームごとのアロケーションなし(テンポラリベクトルを再利用)。テクスチャを圧縮。距離に応じてLOD。

6. アセット(生成写真の罠を避ける)

  • インタラクティブな3D要素(武器ビューモデル、キャラクター、小道具、発射物) → 3Dジオメトリ / glTFから構築し、生成画像からは構築しません。手に持った銃の写真のようにリアルなJPGをFPSビューモデルとして使用すると、見た目がおかしく、アニメーションできず、(JPGにはアルファがないため)黒い箱としてレンダリングされます。実際の3Dビューモデルをオーバーレイレンダーレイヤーとしてカメラにペアレントします。
  • 画像生成はフラットな2Dアセットのみに予約します(テクスチャ、空/メニュー背景、2Dスプライト、UIアート)。生成された写真を3Dメッシュ、ビューモデル、またはキャラクターの代わりとして決して使用しないでください — これらは3Dジオメトリ / glTFで構築してください。キャンバス/テクスチャに描画される画像にはcrossOrigin="anonymous"を設定します。**imagine-grok-build**スキル(2Dのみ — 画像ツールは実際の3Dを生成できません)を参照してください。
  • エンジン対応ゲームアートの原則 → デフォルト設定 + ブラインド検証 + リトライの規律については**game-asset-core(../game-asset-core/)を開き、次に対応する専門家: game-animation-frames(ループ/モーション則)、game-tilesets、game-character-consistency、game-ui-icons。これらはQC/原則**であり、エクスポートパイプラインではありません。実際のアートが期待される場合に棒人間のプレースホルダーを出荷しないでください。
  • 2Dゲームスプライト / アニメーションシート → generate2dsprite(.grok/skills/generate2dsprite/SKILL.md)を実行: 純色の**#FF00FFマゼンタimagine_text_to_imageシート + クロマ後処理スクリプト(プロセッサにはマゼンタが必要です)。透明なPNG/GIFをCanvas/Phaserに配線します。該当する場合はgame-asset-core**(+ アニメーション/キャラクター専門家)を適用します。
  • 2Dマップ / レベル / プロップパック → generate2dmap(.grok/skills/generate2dmap/SKILL.md)を開きます。プレイ可能なマップには、基礎のみのベース + 別個のプロップ/衝突判定を推奨します。ブラウザデフォルト: raw_canvas / Phaser。タイル可能な地面/壁 → 2×2シームチェックには**game-tilesets**も。
  • オプションの高密度移動 → video2dsprite(Grok imagine_image_to_video + サンドボックススクリプト; マゼンタベース)を実行。鮮明なプロダクションヒーローにはgenerate2dspriteを推奨します。ループ/反転テスト則には**game-animation-framesを使用。このサンドボックスでは、アドホックなffmpegのみの収穫よりもvideo2dsprite**を推奨します。

7. オーディオ、セーブ、フィール

  • オーディオ: 最初のユーザージェスチャー(タップして開始)でAudioContextのロックを解除しないと、iOSでは無音になります。visibilitychangeで再開します。(references/audio.md)
  • セーブ: localStorage/IndexedDBをversionフィールド+マイグレーションとともに使用。
  • フィール: 画面シェイク、ヒットストップ、イーズドトゥイーン、パーティクル — 低コストで知覚品質が大幅に向上。プレゼンテーションとシミュレーションは分離してください。

8. モバイル

  • キャンバスのバッファサイズとCSSサイズを区別。devicePixelRatioを尊重。
  • touch-action: none、レターボックスフィットでベース解像度に合わせ、向きを処理。
  • タッチコントロール(バーチャルジョイスティック + アクションボタン)、44px以上のターゲット。

スタック / エンジンの選択

  • 3D → three.js、理想的には**@react-three/fiber + drei**(Reactアプリに適合。dreiはポインターロック/コントロール/ローダーを提供)+ @react-three/rapier(物理/キャラクターコントローラー用)。references/3d-libs.mdを参照。
  • 2D → ネイティブCanvas 2Dはスネーク/テトリス/フラッピー/プラットフォーマーに十分。Phaserはジャンルが必要な場合にのみ使用。
  • これらのゲーム依存関係はプリインストールされていません — npm installしてください(そしてVercelビルドが持つようにpackage.jsonに確実に含めてください)。

完了基準(「完了」と見なす前に)

  • コンソールエラーなしで読み込まれ、可視のゲームプレイがある(空のキャンバスではない)。
  • controlsスキルの自己テスト合格(チェイスカメラから前進中にA = 左 / D = 右。反転している場合は1つの符号を反転)。スクリーンショットのみではない。
  • 3D直立 & カメラ一致自己テスト合格(§3、§4)。
  • タッチコントロールでモバイルビューポートで動作。
  • 本番ビルド(npm run build)が開発時だけでなくビルド出力をレンダリング。
  • 共有 / Xカード: **og**スキルを開く — カスタムpublic/og.jpg および src/lib/og/site.json内の"type": "x:game"。Xはog:type="x:game"を使用してアンファールをゲームカードとして表示します。これにはtwitter:cardや独自のx:typeを使用しないでください。browser-smoke / brand-checkは、キャンバスアプリがsite.jsonフィールドを省略した場合に警告します。

Individual skills in this repo

This repo contains 17 individual skills — each has its own dedicated page.

evalix098/tiktoklive

Add user accounts and sign-in to this TanStack Start app. Use when the app needs authentication, sign-in, user accounts, protected routes, or per-user data. Triggers on "auth", "login", "log in", "sign in", "sign up", "account", "users", "authentication", "protected", "who is logged in", "current user", "per-user".

evalix098/tiktoklive

Player-facing input signs for browser games: WASD, vehicles, flight, FPS mouse-look, and the #1 failure mode (inverted A/D). Mandatory control self-tests and a tiny test interface so you can verify A turns left before shipping. Load for ANY game with movement, steering, flying, driving, tanks, boats, mechs, drones, planes, karts, third-person follow cams — not only racing. Triggers on "controls", "WASD", "inverted", "steer", "flight", "airplane", "kart", "vehicle", "yaw", "roll", "pitch", "mouse look", "A/D".

evalix098/tiktoklive

Design and build polished, non-generic UI for this TanStack Start + React + Tailwind v4 + shadcn/Radix app. Use whenever you create or restyle any interface surface — pages, landing pages, dashboards, forms, modals, nav, and game overlays (start screens, HUD, menus). Covers design tokens, layout, typography, color, spacing, motion, and the anti-"AI-slop" rules that keep output from looking generic. Triggers on "design", "UI", "make it look good", "polish", "landing page", "theme", "style", "redesign", "ugly", "clean up".

evalix098/tiktoklive

Deep guide for game ANIMATION assets: motion cycles, action keyframes, effect sequences, and animation sprite sheets — built around a video-first pipeline. In this app-builder sandbox, execute via the video2dsprite / generate2dsprite skills (magenta + scripts), not ad-hoc ffmpeg. Use whenever generating anything that moves: walk/run cycles, attacks, idles, FX, flags, fire, animation sheets. Complements game-asset-core.

evalix098/tiktoklive

Core discipline for ANY game-asset generation with Imagine tools: the engine-ready defaults users don't state, spec checklists, style anchoring, read-back verification, honest defect flagging. Use whenever generating any game art (sprites, sheets, animations, tiles, UI, FX) — then ALSO load the matching specialist skill: game-animation-frames for anything that moves, game-tilesets for tiles/terrain, game-character-consistency for recurring characters, game-ui-icons for UI and icons.

evalix098/tiktoklive

Deep guide for CHARACTER IDENTITY across images: turnarounds (front/side/ back), state and damage variants, palette swaps, equipment changes, and same-character-in-context sets. Use whenever generating character turnarounds, character sheets, variants of an existing sprite, or any same-subject multi-image set. Complements game-asset-core.

evalix098/tiktoklive

Deep guide for game TILE assets: seamless tileable textures, terrain transition tilesets, autotiles, and ground/platform tiles. Use whenever generating tileable textures, tilesets, terrain transitions, or seamless patterns. Complements game-asset-core.

evalix098/tiktoklive

Deep guide for game UI assets: buttons with interaction states, panels, bars, wordmark logos, and icon sets. Use whenever generating game UI elements, HUD assets, inventory icons, icon sets, buttons, or title logos. Complements game-asset-core.

evalix098/tiktoklive

Generate production-oriented 2D game maps with `imagine_text_to_image`: RPG/top-down maps, side-scroller parallax stages, tilemaps, layered raster maps, prop packs, collision zones, and walkable areas. Use when building browser games that need real map art (not pure code-drawn tiles), layered props, or map collision metadata. Triggers on "map", "level", "stage", "tilemap", "overworld", "dungeon", "side scroller background", "prop pack", "2D map".

evalix098/tiktoklive

Generate and postprocess 2D game sprites and animation sheets: pixel-art characters, NPCs, creatures, spells, projectiles, impacts, props, summons, and transparent PNG/GIF exports. Use when building browser games that need real sprite sheets (not code-drawn placeholders), matching a map art style, or producing magenta-background sheets for chroma-key cleanup. Triggers on "sprite", "sprite sheet", "animation sheet", "pixel art character", "walk cycle", "attack animation", "projectile sprite", "2D game asset".

evalix098/tiktoklive

How to use the Imagine tools in Grok Build: imagine_text_to_image, imagine_image_to_image, imagine_reference_to_image, imagine_text_to_video, imagine_image_to_video, imagine_reference_to_video, and render_file for chat previews. When to build a visual with code instead of generating it, prompt-craft, reference-first handling of real people, factual grounding, and asset-consistency. Load this whenever generating or editing an image or video is on the table. Tool-usage-driven, not triggered by a user merely mentioning images.

evalix098/tiktoklive

Peer-to-peer realtime multiplayer over WebRTC data channels: every user of the deployed app connects directly to every other user (full mesh), the server only brokers the handshake at /api/rtc. Lowest possible latency, zero per-message server cost. Use for 2-8 player co-op/casual realtime: shared cursors, drawing, party games, casual action. Triggers: p2p, peer to peer, webrtc, low latency multiplayer, direct connection.

evalix098/tiktoklive

Use Neon Postgres (the database) in this TanStack Start app. Use when the app needs to store or query data, persist state, or keep per-user data. Triggers on "database", "Postgres", "Neon", "save data", "store data", "persist", "tables", "SQL", "query", "migrations".

evalix098/tiktoklive

Share-link previews and app identity for apps on *.grok.me: the injector-owned og:image card, the SVG favicon, and PWA icons for installable apps. Use when scaffolding, renaming, or restyling the app — and for share / unfurl / OG / Twitter card questions. A custom 1200×630 card from the app's own art is the default — games of every kind (DOM board/word games included), whimsical apps, creative tools, and brand-forward pages; only plain utilities keep the placeholder. Always run the brand-asset pass as a `task` subagent and never wait for it. Triggers on "share", "rename", "app name", "OG", "Open Graph", "twitter card", "unfurl", "og:image", "og:type", "x:game:image", "x-banner", "link preview", "social card", "thumbnail", "preview image", "favicon", "app icon", "PWA", "manifest", "installable", "home screen", "SEO", "meta description".

evalix098/tiktoklive

Official Three.js API and TSL (Three.js Shading Language) reference for LLM code generation. Load when writing or debugging three.js / WebGL / WebGPU / custom materials / shaders / GLTF / advanced three APIs beyond basic game loop/controls. Prefer building-games for game correctness (loop, WASD, camera, orientation); use this skill for full API/TSL depth. Triggers on "three.js", "threejs", "WebGPU", "TSL", "NodeMaterial", "shader", "GLTF", "MeshStandard", "OrbitControls", "WebGLRenderer".

evalix098/tiktoklive

Grok Build only. Turn a 2D character still into denser animation sprites via imagine_text_to_image base → imagine_image_to_video (6s/10s run-in-place) → ffmpeg frames → magenta chroma-key → dense sampled strips/grids/GIFs. Use when the user wants video-to-sprite, smoother run/walk cycles, or denser intermediate poses. Prefer generate2dsprite for crisp production pixel sheets. Triggers on "video to sprite", "imagine_image_to_video sprite", "dense walk cycle", "smooth run animation from video".

evalix098/tiktoklive

Call the xAI API (Grok) from this app's server code using the injected XAI_API_KEY: chat/LLM features, image and video generation (Imagine), and voice (text-to-speech). Use when the app needs any "AI" / "assistant" / "chatbot" / "Grok" functionality, runtime image/video generation, or speech. Triggers on "AI", "LLM", "chatbot", "assistant", "Grok", "xAI", "generate text", "summarize", "generate image", "AI video", "voice", "text to speech", "TTS", "OpenAI" (use xAI instead).

関連スキル