gamekit

module
v0.0.1-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2022 License: MIT

README

gamekit

A collection of utility packages for making games in the awesome Go programming language.

I've created this library to help develop my pet game using ebiten graphics library. And I'm sharing this in hope it can be useful.

  • sprite package contains implemenation of sprite collection. Sprite can consist of several frames and contain properties for animation. Anim is another structure that tracks changing of sprite frames. Collection is initialized from the yaml configuration file (see below). This is pure logical package without dependency on any specific graphics library;
  • ebitenkit package contains ebiten specific collection of sprites that stores images and can draw them on an ebiten image;
  • geo package contains structures and function for float64 geometry calculations;
  • sheetmaker package implements a tool that produces sprite sheet (both png file and yaml config file) from a number of png files; configuration file is used to describe files and desired sheet properties. Run go run ./sheetmaker to get help.

Configuration file example

This file can be created automatically (along with sprite sheets) by sheetmaker by combining multiple png files containing sprites, which are the horizontal stripes of sprite frames, as exported from the sprite editor, such as Aseprite.

Run go run ./sheetmaker for the usage help. Run go install ./sheetmaker to install sheetmaker binary to your $GOBIN path.

files:
  - name: sprites/character.png  # sprite sheet image file name (relative to the executable)
    sprites:
      player-idle:     # sprite name
        width: 32      # width and height of the sprite
        height: 32
        xOffset: 0     # offset of the sprite in the image
        yOffset: 0
        xOrigin: 16    # origin of the sprite is at the
        yOrigin: 32    #   foot level
        frameCount: 2  # animation consists of 2 frames represented by a horizontal stripe 
        animLoop: true # animation loops
        frameMS: 500   # uniform number of milliseconds for each frame
      player-walk:
        width: 32
        height: 32
        xOffset: 0
        yOffset: 32    # note the offset: this sprite frames are on the second row in the image
        xOrigin: 16
        yOrigin: 32
        frameCount: 8
        animNext: player-idle # after animation ends, switch to the different animation
        frameMS: 100
  - name: sprites/terrain.png
    sprites:
      grass:
        width: 32
        height: 32
        xoffset: 0
        yoffset: 0
        frameCount: 8 # grass variations instead of animation frames

Contribution

Ideas, contributions and criticisms are welcome.

Please open an issue for an idea/criticism or a pull request for a contribution.

Directories

Path Synopsis
Package ebitenkit contains utilities specific to github.com/hajimehoshi/ebiten/v2 library
Package ebitenkit contains utilities specific to github.com/hajimehoshi/ebiten/v2 library
examples
Package sprite implements sprite collection loading from config file.
Package sprite implements sprite collection loading from config file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL