Skip to content

vbeardsley/mk48

 
 

Repository files navigation

Carapace Readme

To build and run the Carapace-using mk48.io:

  1. Clone this repo
  2. cd into the repo
  3. Run "git submodule init"
  4. Run "git submodule update"
  5. Remove the line: “pub mod allowlisted”, and the feature: “return_position_impl_trait_in_trait”, from secret_structs/src/lib.rs
  6. Delete the file: secret_structs/src/allowlisted.rs
  7. Comment out the line: “unsafe { libc::atexit(print_timing_c); }” in secret_structs/src/lib.rs
  8. Run "rustup override set nightly-2022-08-14"
  9. Run "rustup target add wasm32-unknown-unknown"
  10. Run "cargo install --locked [email protected]"
  11. cd into "client"
  12. At this point, you need to install an additional system-specific component, named something similar to "nightly-2022-08-14-x86_64-unknown-linux-gnu". The specific package depends on your computer's architecture, but running "make" inside the "client" directory should give an error message that tells you the specific command required to install that package.
  13. After installing the component, run "make" inside the "client" directory.
  14. cd into "../server"
  15. Run "make"
  16. Navigate to localhost:8081 (or whatever port is printed in the console)

All changes to the application code are marked with a comment beginning: Carapce. Additional comments explaining or noting particular changes we made are marked with a comment beginning: Carapce-details

Carapace Update Notes

The reason for steps 5-7 above is that Mk48.io relies on an older version of Rust, which does not allow impl blocks to contain function definitions of the form "fn a(...) -> impl ... {...}". This form of function definition is required for methods using the dot operator to be used inside of secure blocks.

If Mk48.io is updated to a later version of Rust, a few minor changes need to be made, the largest of which is replacing the obsolete "into_ok_or_err()" with a more modern equivalent. In some way that seems unrelated to these changes, running Mk48.io after updating to a later version of Rust results in the following error: Upgrading to certain types of ships causes the game to freeze, turn completely blue, and refuse to respond to any further input from the player. The simplest demonstration of this issue is to run the game in debug mode, and then click the option to upgrade to a Level 10 Ship, located at the top of the screen. This immediately causes the error. The same error occurs in release mode with what seems to be the same ship upgrades.

Mk48.io Game

Build Mk48.io Discord

Logo

Mk48.io is an online multiplayer naval combat game, in which you take command of a ship and sail your way to victory. Watch out for torpedoes!

Building

Tools

  1. Install rustup (see instructions here)
  2. Install Rust Nightly (rustup override set nightly-2022-08-14)
  3. Add WebAssembly target (rustup target add wasm32-unknown-unknown)
  4. Install trunk (cargo install --locked trunk, install gcc first if it complains about missing cc)
  5. Optionally, install the make command

You may use any version of Rust that works, but only nightly-2022-08-14 is known to be compatible.

Client

  1. Enter /client
  2. make or, equivalently, trunk build --release
  3. Deploy the server to host the client

Server

  1. Enter /server
  2. make to build and run a test server
  3. Navigate to localhost:8081 (or whatever port is printed in the console)

Developing

If you follow the Building steps, you have a fully functioning game (could be used to host a private server). If your goal is to modify the game, you may want to read more :)

Entity data

Entities (ships, weapons, aircraft, collectibles, obstacles, decoys, etc.) are defined at the bottom of common/src/entity/_type.rs.

Entity textures

Each entity type must be accompanied by a texture of the same name in the spritesheet, which comes with the repository. If entity textures need to be changed, see instructions in the sprite_sheet_packer directory.

Engine

Both client and server rely on our custom game engine (which is present in the engine directory).

Admin interface (optional)

One notable feature of the engine is an (optional) admin interface. To build it:

  1. Install NodeJS 14 or higher (here)
  2. Enter /engine/js
  3. make
  4. Deploy the server to host the admin interface
  5. Go to localhost:8081/admin/
  6. Paste the contents of engine/game_server/src/auth.txt, generated randomly by a build script, into the alert dialog

Macros

Many macros are utilized by the codebase. Mk48-specific macros can be found in the macros directory, and game engine macros can be found in the engine/engine_macros directory. A few notable macros are:

  • Mk48 entity loader (generates EntityData for all entity types, used by both client and server)
  • Game engine audio loader (generates Audio enum for client, with a variant per sound)
  • Game engine settings (generates Javascript bindings for settings structs)
  • Game engine renderer layer (for composable rendering layers)

Contributing

See Contributing Wiki page.

Trademark

Mk48.io is a trademark of Softbear, Inc.

About

Mk48.io ship combat game

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 94.9%
  • Svelte 2.0%
  • JavaScript 1.2%
  • GLSL 1.2%
  • HTML 0.5%
  • Makefile 0.2%