Skip to content

michaelduerrwhiteduck/MassInertia

Repository files navigation

MassInertia

A 2D action game built with Blazor WebAssembly. Control a rocket-shaped spaceship connected to a massive sphere and navigate through space.

Play the Game

  • Arrow Keys: Rotate the spaceship left/right
  • Space Bar: Fire the engine for thrust
  • Physics: The game features realistic air resistance, gravity effects, and a rigid connection between the spaceship and a massive sphere

Game Mechanics

The spaceship is connected to a massive sphere with a rigid connection. When you apply thrust, the force is split between:

  • Force components parallel to the connection (affecting both objects based on their mass ratio)
  • Force components perpendicular to the connection (affecting only the spaceship)

This creates interesting movement dynamics where the spaceship and sphere influence each other's motion.

Pages

  • Game: The main game with full physics simulation
  • Simple Game: A simplified version that uses direct JavaScript rendering without complex interop
  • Debug Test: A test page for troubleshooting JavaScript interop issues

Troubleshooting JavaScript Interop Issues

If you encounter the "Could not find 'drawGame'" error:

  1. Try the Simple Game version: This uses direct JavaScript eval calls which are more reliable
  2. Check browser console: Look for JavaScript errors
  3. Verify JavaScript files are loaded: Both game.js and game-interop.js should be loaded
  4. Fallback mechanisms: The game includes multiple rendering fallbacks:
    • Primary: gameInterop.drawGame function
    • Secondary: drawTest function
    • Last resort: Direct JavaScript eval with simplified rendering

Technology

  • Built with C# and Blazor WebAssembly
  • Renders on HTML Canvas
  • Runs entirely in the browser (no server-side logic required)
  • Implements a realistic physics model including momentum, gravity, and air resistance

Development

Prerequisites

  • .NET 8 SDK or newer

Running Locally

  1. Clone the repository

    git clone https://github.com/yourusername/MassInertia.git
    cd MassInertia
  2. Build and run the project

    dotnet build
    dotnet run
  3. Navigate to the provided URL in your browser (typically http://localhost:5000)

License

This project is intended for educational and demonstration purposes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors