Phaser's Revenge is a example game that taking from Phaser.js and adapted for the Fiber network that demonstrates real-time token payment using off-chain solution similar to Lightning Network. The game showcases how traditional gaming mechanics can be seamlessly integrated with blockchain technology for instant micro-payments.
In this Space Invaders-style game:
- Players control a spaceship to shoot a boss enemy ship and dodge attacks
- Each successful hit earns points that are instantly converted to CKB tokens
- When players take damage, they lose points (and tokens)
- All token transfers occur in real-time through Fiber Network channels
This demo leverages Fiber Network to enable:
- Real-time token transfers between player and boss (game host)
- Instant settlement of game points as CKB tokens
- Zero-latency gameplay with blockchain features
- Minimal transaction fees through Layer 2 scaling
Before running the game, you need to set up the Fiber Network environment:
- Set up two local Fiber nodes (one for player, one for boss)
- Open a payment channel between the these two nodes
- Each node must deposit 500 CKB into its channel
Note for Developers: This is a simplified demo. In a production environment, you'll need to implement:
- Channel opening logic with player matching
- Final scores are settled on-chain when the game ends including proper channel close
- Error handling for insufficient channel balance
- Security measures for channel management
- Clone the repository
- Install dependencies:
pnpm install- Configure your Fiber nodes (refer to Fiber Network documentation)
- Update your nodes information in
src/fiber/index.ts - Start the development server:
pnpm run dev- Build for production:
pnpm run build- Game Engine: Phaser.js
- Layer 2 Solution: Fiber Network
- Base Layer: Nervos CKB
- Token: Native CKB
This is a demonstration project to showcase the capabilities of Fiber Network for gaming applications. The implementation is simplified for educational purposes. Production applications should implement proper security measures, error handling, and user management systems.