origami_map 1.8.0

Maps library for Dojo based games.

Readme

Map

The Origami Map crate is a library that provides map generation and manipulation functionalities for Dojo-based games. It offers efficient implementations of various map-related algorithms and data structures commonly used in game development.

Overview

The Map crate focuses on providing tools for creating, manipulating, and navigating 2D grid-based maps. Its primary scope includes:

  • Map generation algorithms (maze, cave, random walk)
  • Pathfinding
  • Object distribution on maps
  • Hexagonal grid support

The crate is designed to work seamlessly with the Dojo engine and other Origami crates.

Features

Map Generation

Pathfinding

  • A* algorithm for finding the shortest path between two points

Map Manipulation

  • Adding corridors to existing maps
  • Integrating mazes into existing maps

Object Distribution

  • Spreading objects uniformly across walkable areas of the map

Hexagonal Grid Support

  • Basic operations for hexagonal grids

Installation

Add the Origami Map crate from the scarbs.xyz registry:

scarb add origami_map@1.8.0

Or from git, in the [dependencies] section of your Scarb.toml:

[dependencies]
origami_map = { git = "https://github.com/dojoengine/origami" }

Make sure you have dojo installed and configured in your project.

How to use it?

Here are some examples of how to use the Map crate:

Generating a maze

use origami_map::map::MapTrait;

let width = 18;
let height = 14;
let order = 0;
let seed = 'SEED';
let maze_map = MapTrait::new_maze(width, height, order, seed);

Generating a cave

use origami_map::map::MapTrait;

let width = 18;
let height = 14;
let order = 3;
let seed = 'SEED';
let cave_map = MapTrait::new_cave(width, height, order, seed);

Generating a random walk

use origami_map::map::MapTrait;

let width = 18;
let height = 14;
let steps = 500;
let seed = 'SEED';
let random_walk_map = MapTrait::new_random_walk(width, height, steps, seed);

Opening an existing map with a corridor

use origami_map::map::MapTrait;

let mut map = MapTrait::new_maze(width, height, order, seed);
let position = 1;
let order = 0;
map.open_with_corridor(position, order);

Opening an existing map with a maze

use origami_map::map::MapTrait;

let mut map = MapTrait::new_maze(width, height, order, seed);
let position = 1;
let order = 0;
map.open_with_maze(position, order);

Finding a path using A* algorithm

use origami_map::map::MapTrait;

let map = MapTrait::new_maze(width, height, order, seed);
let path = map.search_path(start_position, end_position);

Distributing objects on the map

use origami_map::map::MapTrait;

let map = MapTrait::new_maze(width, height, order, seed);
let distribution = map.compute_distribution(10, seed);

Remember to import the necessary traits and types when using the Map crate in your project.

Metadata

Version 1.8.0

Uploaded 14 hours ago

License MIT

Size 19.0 KB

Installation

Run the following command in your project dir

scarb add origami_map@1.8.0

Or add the following line to your Scarb.toml

origami_map = "1.8.0"

Monthly downloads

Links

Keywords

  • dojo
  • starknet
  • cairo
  • game
  • map
  • pathfinding
  • generation

Owners