Skip to content

hyperpolymath/idaptik

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

134 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

IDApixiTIK

IDApixiTIK is a browser-based hacking/network simulator game built with ReScript and PixiJS. It combines platformer gameplay with realistic network simulation, featuring multiplayer co-op support via Elixir/Phoenix WebSocket server.

Features

Game Systems

  • Combat System: Guard encounters, dog handlers, drone surveillance, assassin AI
  • Companion System: Moletaire (controllable mole character) with hunger mechanics
  • Training Screens: 8 training scenarios including combat, stealth, and puzzle mechanics
  • Network Simulation: Realistic device interaction, SSH, terminal commands, network topology
  • Multiplayer: Real-time co-op via Phoenix Channels (WebSocket)

New in This Version (Merged from idaptik)

  • ✅ Enhanced combat with body collision, knockdown mechanics, assassin dodge
  • ✅ Companion system (Moletaire) with building navigation and hunger
  • ✅ New training screens: Drone encounters, Highway crossing (Frogger-style)
  • ✅ New devices: Firewall, PBX phone system, Coprocessor bridge
  • ✅ Multiplayer infrastructure with Phoenix WebSocket channels
  • ✅ SafeJson utility for safe JSON parsing
  • ✅ Deno runtime support

Prerequisites

Required

  • Deno - Runtime and package manager
  • Elixir - For multiplayer sync server (optional for single-player)

Installation

Deno:

curl -fsSL https://deno.land/install.sh | sh

Elixir (for multiplayer):

Quick Start

Single-Player Mode (Game Only)

./start-game-only.sh

This starts only the Vite dev server on port 8080. Open http://localhost:8080 in your browser.

Multiplayer Mode (Game + Sync Server)

./start-dev.sh

This starts:

  • Elixir sync server on port 4000
  • Vite dev server on port 8080

Open http://localhost:8080 in your browser.

Development Commands

Manual Control

# ReScript compilation
deno task res:build       # Compile ReScript once
deno task res:clean       # Clean ReScript build artifacts
deno task res:dev         # Watch mode (recompile on changes)

# Vite dev server
deno task dev:vite        # Start Vite dev server only
deno task dev             # ReScript watch + Vite (game only, no sync server)

# Production build
deno task build           # ReScript compile + Vite production build

# Multiplayer sync server
deno task sync-server     # Start Elixir sync server only
deno task dev:all         # Start everything (sync server + game)

Architecture

Directory Structure

IDApixiTIK/
├── src/
│   ├── Main.res                 # Entry point
│   ├── manifest.json            # AssetPack generated (don't edit)
│   ├── app/
│   │   ├── combat/              # Combat system (guards, knockdown, hitboxes)
│   │   ├── companions/          # Moletaire AI and mechanics
│   │   ├── devices/             # Network devices (laptops, routers, firewalls)
│   │   ├── enemies/             # Guard, dog, drone, assassin AI
│   │   ├── multiplayer/         # Phoenix WebSocket client, VMNetwork
│   │   ├── narrative/           # Mission briefings, data files
│   │   ├── player/              # Player character (physics, input, graphics)
│   │   ├── popups/              # Modal overlays (settings, network view)
│   │   ├── proven/              # SafeJson and utility modules
│   │   ├── screens/             # Game screens
│   │   │   ├── training/        # 8 training scenarios
│   │   │   └── locations/       # Game locations
│   │   └── ui/                  # UI components
│   ├── engine/                  # Core game engine
│   │   ├── Engine.res           # Main orchestrator
│   │   ├── navigation/          # Screen/popup management
│   │   ├── audio/               # BGM & SFX
│   │   └── resize/              # Responsive canvas
│   └── bindings/                # JavaScript FFI bindings (PixiJS, Motion)
├── sync-server/                 # Elixir/Phoenix multiplayer server
│   ├── lib/                     # Phoenix channels, game sessions
│   ├── config/                  # Server configuration
│   └── mix.exs                  # Elixir dependencies
├── public/                      # Static assets
├── raw-assets/                  # Source assets (processed by AssetPack)
├── scripts/                     # Build scripts
├── deno.json                    # Deno configuration and tasks
├── rescript.json                # ReScript compiler configuration
├── vite.config.js               # Vite build configuration
├── start-dev.sh                 # Launch script (game + multiplayer)
└── start-game-only.sh           # Launch script (game only)

Technology Stack

  • ReScript - Primary language for game logic, compiles to .res.mjs files
  • PixiJS 8 - 2D WebGL rendering engine
  • Vite - Build tool and dev server
  • Deno - Runtime and package manager
  • Elixir/Phoenix - Multiplayer sync server (WebSocket channels)
  • @pixi/sound - Audio (BGM/SFX)
  • @pixi/ui - UI components
  • motion - Tweening/animation library
  • AssetPack - Asset pipeline (raw-assets/ → public/assets/)

Key Patterns

Screen Navigation: Screens define lifecycle methods (prepare, show, hide, pause, resume, update, resize). Navigation.t manages a stack of screens/popups with asset preloading.

Device System: DeviceTypes.device interface with getInfo() and openGUI(). Factory pattern via DeviceFactory.res. Security levels: Open, Weak, Medium, Strong.

Network Topology: Star topology with central router. Features DNS resolution, traceroute, SSH between devices, zone-based layout (LAN, VLAN, External).

Multiplayer: Phoenix Channels over WebSocket. Pure ReScript client (PhoenixSocket.res) with reconnect, heartbeat, and multiplexing. VMNetwork handles cross-VM messaging.

State Management: Functional with immutable records; mutable fields only where necessary. LocalStorage for persistence via Storage.res.

Multiplayer Sync Server

The Elixir sync server provides:

  • WebSocket-based Phoenix Channels for real-time multiplayer
  • Game session management and registry
  • Co-op event broadcasting
  • VM network synchronization
  • In-memory caching via ETS (no external dependencies)

Configuration

Sync server configuration is in sync-server/config/:

  • config.exs - Base configuration
  • dev.exs - Development settings
  • prod.exs - Production settings

Key environment variables:

  • SECRET_KEY_BASE - Phoenix secret key (auto-generated for dev)
  • PHX_HOST - Hostname (default: localhost)
  • PORT - Server port (default: 4000)

Building for Production

# Build the game
deno task build

# Output will be in dist/
# Serve dist/ with any static file server

# Build Elixir sync server release
cd sync-server
MIX_ENV=prod mix release
# Output will be in _build/prod/rel/

Troubleshooting

ReScript compilation errors

deno task res:clean
deno task res:build

Vite module resolution errors

Delete node_modules and rebuild:

rm -rf node_modules
deno task res:build
deno task dev

Sync server connection issues

Check that the sync server is running on port 4000:

curl http://localhost:4000/health

Should return JSON with server status.

Migration Notes

This version integrates features from the newer idaptik monorepo:

  • Removed: Podman/container infrastructure, PWA support
  • Added: Deno runtime, standalone Elixir sync server, new game features
  • Updated: ReScript 11 → 12, improved vite config, health endpoint plugin

License

See LICENSE file for details.

Development

Asset Pipeline

Raw assets in raw-assets/ are processed by AssetPack into public/assets/ with manifest at src/manifest.json. Assets are loaded by bundle name.

ReScript Conventions

  • Files compile to .res.mjs alongside source
  • Module namespaces pattern: module ModuleName = { ... }
  • FFI bindings in src/bindings/ wrap external JS libraries
  • Use @rescript/core for standard library

Testing

After any changes:

  1. Run deno task res:build - verify ReScript compilation
  2. Run deno task dev or ./start-game-only.sh - test in browser
  3. Check console for errors
  4. Test new features according to handoff documentation

Credits

Originally created by Joshua B. Jewell, developed under hyperpolymath.

About

Asymmetric camera multiplayer game system (Elixir + Rust)

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors