#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

#507 in Visualization

Download history 89/week @ 2024-07-23 53/week @ 2024-07-30 11/week @ 2024-09-10 9/week @ 2024-09-17 21/week @ 2024-09-24 24/week @ 2024-10-01 4/week @ 2024-10-08

165 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
~300K SLoC