Worlds Help Page
Main World Help Page
๐ง High-Level Overview
Layout / Style:
The page is built using Jekyll (layout: post) and heavily styled with CSS for a dark, immersive, game-like look. A canvas is used for the player and world rendering, and other HTML elements support UI (e.g., point display, modals).
Core Features
- Character movement (WASD)
- Game world rendered via
<canvas> - Game โiconsโ act as portals to minigames
- A Skin Selection Modal opens when the player collides with a designated area
๐ How the World System Works
1. Canvas + Player
A <canvas> element (#gameCanvas) draws:
- The background image (
worldbackground0.png) - The player character (
spriteImage) based on selected skin - Various interactive objects (icons for games)
The player is a JS object with position and speed. Movement is controlled via WASD keys.
const player = {
x: 490,
y: 570,
width: 75,
height: 75,
speed: 4
};
2. Game Objects
Defined in an array objects, where each has x, y, and game key (e.g., 'skin', 'aboutus', etc.).
When the player touches an object, an action is triggered (e.g., go to a game route like /blackjack).
3. Collision Detection
isColliding(player, obj) is used to determine interaction.
If player collides with a game object, it triggers a redirect:
window.location.href = '/GameHub/blackjack';
๐ฎ Moving / Adding / Adjusting Games
โ To Add a Game:
Add a new entry in the objects array with:
x,y,width,heightgame: 'yourgamename'
Add a matching image in the objectImages map:
objectImages.yourgamename = '/GameHub/images/iconNEW.png';
In the update() functionโs collision switch, add:
case 'yourgamename':
window.location.href = '/GameHub/yourgamename';
break;
๐ฆ To Move an Icon:
Just update the x and y of the desired object:
{ x: 820, y: 660, width: 40, height: 40, game: 'format' }
๐จ To Change a Gameโs Icon Image:
Update its entry in objectImages:
objectImages.format = '/GameHub/images/newIcon.png';
๐ Skin System
- When you touch the top-right box (
topRightBox), the modal opens to select a skin. - Skins are clickable
.skin-optiondivs with backgrounds. - Confirming a skin updates
currentSpriteIndexto change the playerโs sprite image.
To add more skins:
- Add a new
.skin-optiondiv with an appropriate background-image. - Push its URL into the
spriteImagesarray. - Handle logic in JS (if needed) to update
currentSpriteIndex.
๐ง Ways to Adjust the System
| Task | What to Modify |
|---|---|
| ๐ฎ Add a game | Add to objects, objectImages, update() redirect |
| ๐ Move a game icon | Change x/y in objects |
| ๐ผ๏ธ Change game icon | Update image URL in objectImages |
| ๐งโโ๏ธ Change player start position | Modify player.x and player.y |
| ๐ Add skins | Update .skin-option, spriteImages[] |
| ๐ต Change music | Replace EARFQUAKE.mp3 path |
| โ Add walls/boundaries | Add entries to walls array |
| ๐จ Change background | Replace worldbackground0.png |
๐ก Ideas for Expansion
- Add animated NPCs or story characters.
- Use
localStorageto save selected skin. (Optional) - Add a points/rewards system for unlocking new games. (Optional)
- Use a minimap to navigate a larger world.
- Make worlds scrollable or paginated if too many icons.