-
Notifications
You must be signed in to change notification settings - Fork 2
Using tile sets from images #1
Comments
Hi! You have to provide a mapping from grid cells to any image format satisfying the Image interface in the standard Go library. Using, for example, the gruid-sdl driver, that would be done when defining the GetImage method for the TileManager interface. A grid cell in gruid is a rune, along some other fields, named for what they are typically used for, like to encode some abstract color scheme or miscellaneous attributes (for things that would require special styling, like reverse or italic or any image manipulation), but they can be used to encode more complex meanings: the field names correspond to terminal ascii conventions, because even if you do tiles you usually also want an ascii version so using a compatible encoding comes handy, but the mapping gives you total freedom (if you only want tiles, you could just use some generic constants for the Attrs field encoding all the possible image combinations). For example, Harmonist uses a mapping from grid cells to images that works as follows: a monocolor base64 encoded png image is chosen based on the rune field (and configuration options tiles vs ascii), and then it is colored on the fly depending on the color field of the corresponding grid cell, for example. Also, a custom grid cell attribute |
Yeah, Harmonist's repository may be a bit complex in some aspects: the code is quite old and was started before I made gruid. There is also gruid-rltuto, that is much simpler as a starting example, but only does the basics, with only sdl using textual tiles. And, true, you'll have to write your own parser for loading the tiles from a png, which should be easy enough, as the Go standard library image package provides what's needed for extracting rectangle images from a tileset. |
Really appreciate the responses! I come from a web development background and fell in love with rust and from there starting building rougelikes after following (https://bfnightly.bracketproductions.com/) Somehow i am now learning Go, but I always enjoy learning new languages by attempting to do really complex things. Makes the end result more enjoyable for me. Can't wait to see the progression of Gruid and in the future, I would love to help out if i can |
That rust roguelike tutorial is indeed very interesting and complete: the author often shared about its progress on the roguelikedev sub and clearly put a lot of work into it! Anyway, making roguelikes is indeed a great way to learn a new programming language. Good luck with that! As for the progression of Gruid, I don't expect much evolution in the core library (maybe small additions in ui or rl, but it should be stable overall), but more probably other external modules that build upon it (like after someone implemented some generally useful extension while making a gruid-based roguelike). |
Absolutely love the library you created and makes creating rougelikes a breeze.
My question is how would one go about loading tiles from a png image like most rougelikes use some for of tile set to style their game, (if you don't want just plain ascii)
The text was updated successfully, but these errors were encountered: