Loading...
Loading...
Unlock smooth, efficient Pixi.js games in TypeScript with these optimized rules. Covering project structure, naming conventions, performance tweaks, mobile adaptations, and Pixi.js-specific techniques for seamless web and mobile experiences.
### Code Principles
**Do:** Prioritize concise, performant TypeScript using functional and declarative styles; reserve classes for Pixi.js necessities.
*Example:*
```typescript
const updatePosition = (sprite: PIXI.Sprite, delta: number) => {
sprite.x += delta * speed;
};
```
**Don't:** Rely on classes for simple logic or create objects excessively during loops.
*Example (Avoid):*
```typescript
class PositionUpdater {
update(sprite: PIXI.Sprite, delta: number) { /* ... */ }
}
```
### Project Organization
**Do:** Group code into feature-based folders like scenes/, entities/, systems/, and assets/.
*Example:*
```
src/
scenes/
game-scene.ts
entities/
player-entity.ts
systems/
physics-system.ts
```
**Don't:** Scatter files randomly or mix concerns in single files.
*Example (Avoid):* Dumping all game logic into one massive app.ts.
### Naming Conventions
**Do:** Apply camelCase for functions/variables, kebab-case for files, PascalCase for classes/Pixi objects, and prefixes like 'is', 'has' for booleans; UPPERCASE for constants.
*Example:*
```typescript
const createPlayerSprite = (): PlayerSprite => { /* ... */ };
const isGamePaused = false;
const MAX_LIVES = 3;
// File: player-entity.ts
```
**Don't:** Use inconsistent casing or vague names like 'x' or 'tmp'.
*Example (Avoid):* `let p = new Sprite();`
### TypeScript & Pixi.js Practices
**Do:** Enforce strong typing everywhere, use Pixi Ticker for loops, WebGPU with WebGL fallback, and object pooling.
*Example:*
```typescript
const app = new PIXI.Application({ preferWebGpu: true });
app.ticker.add((delta) => updateGame(delta));
interface GameEntity { x: number; y: number; }
```
**Don't:** Skip types or use raw DOM events instead of Pixi interaction manager.
*Example (Avoid):* Untyped `any` for sprites.
### Pixi.js Optimizations
**Do:** Batch sprites, use texture atlases, ParticleContainer for particles, culling, and caching.
*Example:*
```typescript
const particles = new PIXI.ParticleContainer(10000, { scale: true, alpha: true });
// Atlas: load single texture sheet
```
**Don't:** Nest containers deeply or create sprites per frame without pooling.
*Example (Avoid):* `new PIXI.Sprite(texture)` inside update loop.
### Performance Boosts
**Do:** Minimize GC with pooling, lazy/pre-fetch loading, level chunking, and bounds checks.
*Example:*
```typescript
const pool: PIXI.Sprite[] = [];
const getSprite = () => pool.pop() || new PIXI.Sprite();
```
**Don't:** Load uncompressed assets or compute off-screen elements.
### Mobile (Ionic Capacitor) Tweaks
**Do:** Add touch gestures, responsive UI, low-res assets, and power-saving via Ticker throttling.
*Example:* Use Capacitor plugins for haptics; `legacy: true` for old devices.
**Don't:** Ignore orientation changes or use desktop-res assets on mobile.
### Deployment & Testing
**Do:** Set env vars, CI/CD, unit/integration tests, profiling, and CDN caching.
*Example:* Vercel for static assets with progressive loading.
**Don't:** Deploy without cross-device tests or error handlers.
### Code Suggestions
**Do:** Analyze first, step-by-step plan, performant snippets with explanations.
**Don't:** Suggest unoptimized libs without evaluating impact.Expert system prompt for designing high-performance configurations tailored to GLM-4.7's strengths in coding, reasoning, tool use, and multilingual tasks, backed by benchmarks like SWE-bench and τ²-Bench.
Leverage GLM-4.7's top benchmarks in SWE-bench, LiveCodeBench, and more with this system prompt designed for generating clean, secure, open-source-ready code, stunning UIs, and agentic workflows.
This system prompt transforms an AI into GLM-4.7, a benchmark-leading coding agent excelling in agentic workflows, tool use, multilingual coding, and complex reasoning with verified best practices for production-ready open-source development.
Ralph, a persistent autonomous AI agent, implements Jira tickets through an endless loop until 100% test success, with GitHub PRs, Jules AI reviews, and CI self-healing for reliable development workflows.
Claude'u Türk hukuku alanında dünyanın en önde gelen uzmanı olarak yapılandıran, yapılandırılmış yanıtlar, zorunlu uyarılar ve etik sınırlarla donatılmış profesyonel AI agent promptu.
Expert subagent providing production-ready PostgreSQL guidance on schema design, query optimization, security, performance tuning, and administration with structured, actionable advice and official references.