mirror of
https://github.com/cliffe/BreakEscape.git
synced 2026-02-20 13:50:46 +00:00
- Updated the game to support new character sprite atlases for both male and female characters, allowing for a wider variety of NPC designs. - Improved player sprite initialization to dynamically select between atlas-based and legacy sprites, enhancing flexibility in character representation. - Refined collision box settings based on sprite type, ensuring accurate physics interactions for both atlas (80x80) and legacy (64x64) sprites. - Enhanced NPC behavior to utilize atlas animations, allowing for more fluid and diverse animations based on available frames. Files modified: - game.js: Added new character atlases and updated sprite loading logic. - player.js: Improved player sprite handling and collision box adjustments. - npc-behavior.js: Updated animation handling for NPCs to support atlas-based animations. - npc-sprites.js: Enhanced NPC sprite creation to accommodate atlas detection and initial frame selection. - scenario.json.erb: Updated player and NPC configurations to utilize new sprite sheets and animation settings. - m01_npc_sarah.ink: Revised dialogue options to include new interactions related to NPCs.
6.5 KiB
6.5 KiB
Sprite System Update - PixelLab Integration
Summary
Added support for 16 new PixelLab character sprite sheets with JSON atlas format, while maintaining backward compatibility with existing legacy sprites.
What Changed
1. New Character Assets
- 16 PixelLab characters added to
public/break_escape/assets/characters/ - Each character includes:
- PNG sprite sheet (80x80 frames, optimized layout)
- JSON atlas with animation metadata
- 8-directional animations (breathing-idle, walk, attack, etc.)
2. Game Loading System (public/break_escape/js/core/game.js)
- Added atlas loading for all 16 new characters
- Legacy sprite loading preserved for backward compatibility
- Female characters: 8 variants (hacker, office worker, security, etc.)
- Male characters: 8 variants (hacker, office worker, security, etc.)
3. NPC Sprite System (public/break_escape/js/systems/npc-sprites.js)
- New:
setupAtlasAnimations()function for atlas-based sprites - Automatic format detection (atlas vs. legacy)
- Direction mapping: atlas directions → game directions
- east/west/north/south → right/left/up/down
- Diagonal directions fully supported
- Animation type mapping: breathing-idle, walk, cross-punch, etc.
- Backward compatible with existing frame-based sprites
4. Scenario Configuration (scenarios/m01_first_contact/scenario.json.erb)
Updated all characters to use new atlas sprites:
- Player (Agent 0x00):
hacker→female_hacker_hood - Agent 0x99:
hacker→male_spy - Sarah Martinez:
hacker-red→female_office_worker - Kevin Park:
hacker→male_nerd - Maya Chen:
hacker-red→female_scientist - Derek Lawson:
hacker→male_security_guard
Configuration format updated:
// Old format
"spriteConfig": {
"idleFrameStart": 20,
"idleFrameEnd": 23
}
// New format
"spriteConfig": {
"idleFrameRate": 8,
"walkFrameRate": 10
}
5. Documentation
docs/SPRITE_SYSTEM.md- Complete sprite system documentationpublic/break_escape/assets/characters/README.md- Character reference guidepublic/break_escape/assets/characters/SPRITE_SHEETS_SUMMARY.md- Detailed character breakdowntools/README_SPRITE_CONVERTER.md- Conversion tool documentation
6. Conversion Tool
tools/convert_pixellab_to_spritesheet.py- Automated sprite sheet generator- Converts PixelLab exports to Phaser-ready atlases
- Generates optimized PNG + JSON for each character
- Updated to skip example JS files
Benefits
Performance
- ✅ 16 HTTP requests instead of 2500+ individual images
- ✅ Single GPU texture per character
- ✅ Faster frame switching (no texture swaps)
- ✅ Optimized memory usage
Features
- ✅ 8-directional movement with smooth animations
- ✅ Multiple animation types per character
- ✅ Easy character variety without custom sprite work
- ✅ Backward compatible with existing sprites
Developer Experience
- ✅ Simple configuration in scenario JSON
- ✅ Automatic animation setup
- ✅ Clear character naming (female_hacker, male_spy, etc.)
- ✅ Comprehensive documentation
Breaking Changes
None - The system is fully backward compatible. Legacy sprites continue to work with the old configuration format.
New Character Variants
Female Characters (8 variants)
female_hacker_hood- Hacker in hoodie (hood up)female_hacker- Hacker in hoodiefemale_office_worker- Office worker (blonde)female_security_guard- Security guardfemale_telecom- Telecom workerfemale_spy- Spy in trench coatfemale_scientist- Scientist in lab coatwoman_bow- Woman with bow
Male Characters (8 variants)
male_hacker_hood- Hacker in hoodie (obscured)male_hacker- Hacker in hoodiemale_office_worker- Office worker (shirt & tie)male_security_guard- Security guardmale_telecom- Telecom workermale_spy- Spy in trench coatmale_scientist- Mad scientistmale_nerd- Nerd (glasses, red shirt)
Animation Support
All atlas characters include:
- breathing-idle - 8 directions, 4 frames each
- walk - 8 directions, 6 frames each
- cross-punch - 8 directions, 6 frames each
- lead-jab - 8 directions, 3 frames each
- falling-back-death - 7 frames (some: 8 directions)
- taking-punch - 6 frames (select characters)
- pull-heavy-object - 6 frames (select characters)
Usage Example
{
"id": "my_npc",
"displayName": "My Character",
"npcType": "person",
"position": { "x": 5, "y": 3 },
"spriteSheet": "female_scientist",
"spriteTalk": "assets/characters/scientist-talk.png",
"spriteConfig": {
"idleFrameRate": 8,
"walkFrameRate": 10
}
}
Migration Path
To update existing NPCs:
- Choose appropriate character from available list
- Update
spriteSheetvalue - Replace
idleFrameStart/EndwithidleFrameRate - Add
walkFrameRateif needed
Testing
Tested with M01 First Contact scenario:
- ✅ All characters load correctly
- ✅ 8-directional movement works
- ✅ Idle animations play properly
- ✅ Walk animations transition smoothly
- ✅ Legacy sprites still functional
- ✅ Performance improved (fewer HTTP requests)
Future Enhancements
Potential improvements:
- Dynamic portrait generation from sprite sheets
- Character customization system
- Animation state transitions (idle → walk → attack)
- More character variants (uniforms, outfits)
- Custom color tinting for sprite variations
Files Modified
Core Game Files
public/break_escape/js/core/game.js- Added atlas loadingpublic/break_escape/js/systems/npc-sprites.js- Added atlas animation support
Scenario Files
scenarios/m01_first_contact/scenario.json.erb- Updated all character sprites
Assets
public/break_escape/assets/characters/- Added 16 characters (32 files: PNG + JSON)
Documentation
docs/SPRITE_SYSTEM.md- New comprehensive guidepublic/break_escape/assets/characters/README.md- Character referencepublic/break_escape/assets/characters/SPRITE_SHEETS_SUMMARY.md- Detailed breakdown
Tools
tools/convert_pixellab_to_spritesheet.py- Updated (removed example JS generation)tools/README_SPRITE_CONVERTER.md- Updated documentation
Notes
- Legacy
hackerandhacker-redsprites remain available spriteTalkimages are separate and work with both formats- Atlas JSON format is Phaser 3 compatible (JSON Hash)
- All frames are 80x80 pixels (vs 64x64 for legacy)
- 2px padding between frames prevents texture bleeding