Character vs Nature - Part 1
An Educational Game with CSP-Compliant Hosting for Secure Environments
🎮 Game Overview
Character vs Nature - Part 1 is an educational game developed in Construct 3 that brings storytelling and learning together. Designed for students, the game immerses players in a world where they explore character vs nature conflicts while learning critical thinking, empathy, and problem-solving.
https://vle.learning.moe.edu.sg/moe-library/module/view/7d77cace-3c63-4bec-9533-42e46606da68
CheckSupportsWorkerMode @ main.js:26Understand this error | appmanifest.json:1 Failed to load resource: the server responded with a status of 403 ()Understand this error |
https://vle.learning.moe.edu.sg/community-gallery/module/view/4158df16-4962-4735-8b10-3aea5935a082/section/95889073/activity/95889075
Key Features
-
Interactive storytelling enhanced with voice narration
-
Character animations and dynamic visual effects
-
Engaging audio feedback and background music
-
Educational modules that explain conflict types and character growth
-
A progressive learning structure with scaffolded practice exercises
🚨 The Challenge: CSP Compliance
When we first deployed the game to secure platforms like SLS (Student Learning Space) or corporate environments, we encountered a significant issue: Content Security Policy (CSP) restrictions.
The Issues We Found
-
Blob Worker Creation
The original script usedURL.createObjectURL(new Blob(...))
, which is blocked in strict CSP environments. -
Web Worker Dependencies
Construct 3’s worker mode—optimized for performance—relies on workers that CSP restrictions frequently disable. -
Runtime Failures
The result? Blank screens, "Unexpected end of input" errors, and frustrated users.
🛠️ The Fix: CSP-Compliant Execution
To make the game compatible with strict security environments, we implemented these changes:
1. Disable Worker Mode
Modified the CheckSupportsWorkerMode
function to always return false:
2. Force DOM Mode
The game now runs entirely in DOM mode, removing reliance on Web Workers but preserving all gameplay features.
3. Maintain Performance
Modern browsers are efficient enough that performance remains smooth, even without worker threads.
🔧 Technical Implementation
Key Files Updated
File | Description | Status |
---|---|---|
scripts/main.js | Removed CSP-violating worker code | ✅ Fixed |
scripts/sls-compatibility.js | Added compatibility layer for static hosting | ✅ New |
scripts/init-check.js | Override worker detection for extra safety | ✅ New |
index-sls.html | CSP-safe entry point for hosting | ✅ New |
Script Loading Order
To ensure compatibility, load the scripts in this exact order:
🚀 How to Run the Game
Local Development
Serve the game with a local server for testing:
Then open:
Production Deployment
The game now runs seamlessly on:
-
Static hosting platforms (GitHub Pages, Netlify, Vercel)
-
Educational LMS platforms with strict CSP rules
-
Corporate environments with locked-down browsers
Console Verification
When running correctly, you’ll see:
📁 Project Structure
🧠 Educational Value
This game isn’t just fun—it’s pedagogically grounded. Students learn:
-
Character Development: How characters evolve over time
-
Conflict Analysis: Understanding "Character vs Nature" dynamics
-
Story Structure: Breaking down beginnings, conflicts, and resolutions
-
Critical Thinking: Making decisions and seeing the consequences
-
Interactive Practice: Reinforcement through engaging exercises
🔒 Security Features
-
CSP-Compliant Execution
-
No Inline Scripts for enhanced security
-
Safe Resource Loading with no dynamic code generation
-
HTTPS Ready for modern hosting environments
🤝 Contributing
To contribute or troubleshoot:
-
Check browser console logs for CSP errors
-
Confirm scripts load in the correct order
-
Test across browsers and platforms
-
Document your fixes for community use
📞 Support
If you encounter issues:
-
Inspect browser console for error messages
-
Confirm proper server setup
-
Ensure all assets are accessible via HTTPS
This approach prioritizes compatibility and security while maintaining full gameplay functionality, making Character vs Nature - Part 1 accessible in a wide range of secure learning environments.
# Character vs Nature - Part 1