A game built with p5.js and TypeScript.
- Install dependencies:
npm install- Build the TypeScript files:
npm run buildOr watch for changes:
npm run watch- Open
index.htmlin your browser or use a local server:
# Using Python
python -m http.server 8000
# Using Node.js http-server
npx http-serversrc/
├── config.ts # Game configuration
├── sketch.ts # Main p5.js sketch
└── utils/
├── eventBus.ts # Event system
└── helpers.ts # Utility functions
dist/ # Compiled JavaScript (generated)
js/ # Old JavaScript files (can be removed)
npm run build- Compile TypeScript oncenpm run watch- Watch for changes and recompile
- TypeScript - Type-safe game development
- Event Bus - Centralized event management
- Helper Functions - 50+ utility functions for:
- Math operations (lerp, clamp, distance)
- Grid/tile operations
- Vector math
- Collision detection
- Color utilities
- Timer and FPS counter classes
- State machine
- Array utilities
import { EventBus, GameEvents } from './utils/eventBus';
// Listen to events
EventBus.on(GameEvents.PLAYER_MOVE, (x, y) => {
console.log(`Moved to ${x}, ${y}`);
});
// Emit events
EventBus.emit(GameEvents.PLAYER_MOVE, 100, 200);See EVENTBUS_EXAMPLES.md for more examples.