#screeps #image #terrain #game #mmo #room

screeps-local-visuals

A library for the programmable MMO Screeps that allows tools to produce images of game data without relying on the game engine for rendering

3 releases

0.1.2 Jul 29, 2024
0.1.1 Jun 3, 2024
0.1.0 Mar 3, 2024

#512 in Visualization

Download history 15/week @ 2024-09-14 20/week @ 2024-09-21 29/week @ 2024-09-28 2/week @ 2024-10-05 3/week @ 2024-10-12 39/week @ 2024-11-30 69/week @ 2024-12-07

108 downloads per month

MIT license

1.5MB
503 lines

Screeps Local Visuals

This library provides helper methods for creating room images for the programmable MMO Screeps, without relying on the in-game renderer.

Example Usage

The following example code produces an image simple.png that represents an empty room with an Extension, a Source, a Catalyst Mineral, a Swamp, and 3 Walls.

use screeps_local_visuals::render;
use render::{ Terrain, Resource, BuildableStructure, OutputImage, DEFAULT_ROOM_MAX_ROWS, DEFAULT_ROOM_MAX_COLUMNS };


fn main()   {
  make_map_image("simple.png");
}


fn make_map_image(filename: &str) {

  let mut imgbuf = render::create_image();

  draw_terrain(&mut imgbuf);

  draw_test_terrain(&mut imgbuf);
  draw_test_resource(&mut imgbuf);
  draw_test_structure(&mut imgbuf);

  render::draw_grid(&mut imgbuf);

  imgbuf.save(filename).unwrap();
}

fn draw_terrain(imgbuf: &mut OutputImage) {
  for col in 0..DEFAULT_ROOM_MAX_COLUMNS {
    for row in 0..DEFAULT_ROOM_MAX_ROWS {
      render::draw_terrain_tile_xy(imgbuf, col, row, &Terrain::Plain);
    }
  }
}

fn draw_test_terrain(imgbuf: &mut OutputImage)  {
  render::draw_terrain_tile_xy(imgbuf, 20, 20, &Terrain::Swamp);
  render::draw_terrain_tile_xy(imgbuf, 21, 20, &Terrain::Wall);
  render::draw_terrain_tile_xy(imgbuf, 21, 21, &Terrain::Wall);
  render::draw_terrain_tile_xy(imgbuf, 20, 21, &Terrain::Wall);
}

fn draw_test_resource(imgbuf: &mut OutputImage)  {
  render::draw_resource_tile_xy(imgbuf, 10, 20, &Resource::Source);
  render::draw_resource_tile_xy(imgbuf, 20, 10, &Resource::Catalyst);
}

fn draw_test_structure(imgbuf: &mut OutputImage)  {
  render::draw_buildablestructure_tile_xy(imgbuf, 10, 10, &BuildableStructure::Extension);
}

Dependencies

~17MB
~301K SLoC