#screeps #graphics #game-engine

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

2 releases

0.1.1 Jun 3, 2024
0.1.0 Mar 3, 2024

#336 in Images

Download history 6/week @ 2024-03-12 13/week @ 2024-03-19 1/week @ 2024-03-26 14/week @ 2024-04-02 50/week @ 2024-05-28 132/week @ 2024-06-04 4/week @ 2024-06-11

186 downloads per month

MIT license

1.5MB
465 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

~24MB
~282K SLoC