Coder Social home page Coder Social logo

anaseto / gruid Goto Github PK

View Code? Open in Web Editor NEW
81.0 3.0 2.0 556 KB

Cross-platform grid-based UI and game framework.

Home Page: https://codeberg.org/anaseto/gruid

License: ISC License

Go 100.00%
go golang ui roguelikedev pathfinding elm-architecture gruid

gruid's Introduction

Migrated to https://codeberg.org/anaseto/gruid because of new 2FA requirement (you'll need to update your imports)

Gruid

pkg.go.dev godocs.io

The gruid module provides packages for easily building grid-based applications in Go. The library abstracts rendering and input for different platforms. There are drivers available for terminal apps (gruid-tcell), native graphical apps (gruid-sdl) and browser apps (gruid-js). The original application for the library was creating grid-based games, but it's also well-suited for any grid-based application.

The core gruid package uses a convenient and flexible architecture of updating a model in response to messages strongly inspired from the bubbletea module for building terminal apps, which in turn is based on the functional Elm Architecture. The architecture has been adapted to be more idiomatic in Go in the context of grid-based applications: less functional and more efficient.

You can find examples below in the Examples section.

Overview of packages

The full documentation is linked at the top of this README. We provide here a quick overview.

The gruid package defines the Model and Driver interfaces and allows to start the “update on message then draw” main loop of an application. It also defines a convenient and efficient slice grid structure to represent the logical contents of the screen and manipulate them.

The ui package defines common UI widgets and utilities: menu/table widget, pager, text input, label, styled text drawing facilities and replay functionality.

The tiles package contains helpers for drawing fonts on images, which can be used to manage character tiles using a Driver from either gruid-sdl or gruid-js.

The paths package provides efficient implementations of some common pathfinding algorithms that are often used in grid-based games, such as roguelikes. You will find implementations of the A* and JPS algorithms, as well as Dijkstra, breadth first, and connected components maps computations. See move.go in the movement example in gruid-examples for an annotated example using JPS and the mouse.

The rl package provides some additional utilities commonly needed in grid-based games such as roguelikes. The package provides an event priority queue, two complementary field of view algorithms, map generation algorithms, as well as vault parsing and manipulation utilities.

Drivers

The tcell, sdl, and js packages in the (gruid-tcell), (gruid-sdl) and (gruid-js) modules provide specific rendering and input implementations satisfying gruid's package Driver interface. The provided terminal driver only handles full-window applications. See the README.md files in the respective repositories for specific build and deployment instructions (gruid-sdl will require SDL2, and gruid-js will require a bit of HTML and js).

Examples

The gruid-examples module offers some simple annotated examples of gruid usage.

You may want to look also into some real world examples of gruid programs:

See also

If you need to handle wide-characters, that is characters that take two cells in the terminal, you may want to look into go-runewidth.

The clipboard module may be of interest for some applications too, as copying and pasting is not handled by gruid. Note that, at this time, the clipboard module does not support the js platform, but there's at least one fork that does.

As gruid only provides a few map generation algorithms, you may be interested in the dngn module, which provides map generation algorithms too, though its representation of maps is different.

gruid's People

Contributors

anaseto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

grafoo bsmr

gruid's Issues

Using tile sets from images

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.