A hand-crafted 2D game library in Go

Overview

Pixel Build Status GoDoc Go Report Card Join the chat at https://gitter.im/pixellib/Lobby Discord Chat

A hand-crafted 2D game library in Go. Take a look into the features to see what it can do.

go get github.com/faiface/pixel

If you are using Modules (Go 1.11 or higher) and want a mutable copy of the source code:

git clone https://github.com/faiface/pixel # clone outside of $GOPATH
cd pixel
go install ./...

See requirements for the list of libraries necessary for compilation.

All significant changes are documented in CHANGELOG.md.

Tutorial

The Wiki of this repo contains an extensive tutorial covering several topics of Pixel. Here's the content of the tutorial parts so far:

Examples

The examples repository contains a few examples demonstrating Pixel's functionality.

To run an example, navigate to it's directory, then go run the main.go file. For example:

$ cd pixel-examples/platformer
$ go run main.go

Here are some screenshots from the examples!

Lights Platformer
Lights Platformer
Smoke Typewriter
Smoke Typewriter
Raycaster Gizmo
Raycaster Gizmo

Features

Here's the list of the main features in Pixel. Although Pixel is still under heavy development, there should be no major breakage in the API. This is not a 100% guarantee, though.

  • Fast 2D graphics
    • Sprites
    • Primitive shapes with immediate mode style IMDraw (circles, rectangles, lines, ...)
    • Optimized drawing with Batch
    • Text drawing with text package
  • Audio through a separate Beep library.
  • Simple and convenient API
    • Drawing a sprite to a window is as simple as sprite.Draw(window, matrix)
    • Wanna know where the center of a window is? window.Bounds().Center()
    • ...
  • Full documentation and tutorial
  • Works on Linux, macOS and Windows
  • Window creation and manipulation (resizing, fullscreen, multiple windows, ...)
  • Keyboard (key presses, text input) and mouse input without events
  • Well integrated with the Go standard library
    • Use "image" package for loading pictures
    • Use "time" package for measuring delta time and FPS
    • Use "image/color" for colors, or use Pixel's own color.Color format, which supports easy multiplication and a few more features
    • Pixel uses float64 throughout the library, compatible with "math" package
  • Geometry transformations with Matrix
    • Moving, scaling, rotating
    • Easy camera implementation
  • Off-screen drawing to Canvas or any other target (Batch, IMDraw, ...)
  • Fully garbage collected, no Close or Dispose methods
  • Full Porter-Duff composition, which enables
    • 2D lighting
    • Cutting holes into objects
    • Much more...
  • Pixel let's you draw stuff and do your job, it doesn't impose any particular style or paradigm
  • Platform and backend independent core
  • Core Target/Triangles/Picture pattern makes it easy to create new drawing targets that do arbitrarily crazy stuff (e.g. graphical effects)
  • Small codebase, ~5K lines of code, including the backend glhf package

Related repositories

Here are some packages which use Pixel:

  • TilePix Makes handling TMX files built with Tiled trivially easy to work with using Pixel.

Missing features

Pixel is in development and still missing few critical features. Here're the most critical ones.

  • Audio
  • Drawing text
  • Antialiasing (filtering is supported, though)
  • Advanced window manipulation (cursor hiding, window icon, ...)
  • Better support for Hi-DPI displays
  • Mobile (and perhaps HTML5?) backend
  • More advanced graphical effects (e.g. blur) (solved with the addition of GLSL effects)
  • Tests and benchmarks
  • Vulkan support

Implementing these features will get us to the 1.0 release. Contribute, so that it's as soon as possible!

Requirements

If you're using Windows and having trouble building Pixel, please check this guide on the wiki.

PixelGL backend uses OpenGL to render graphics. Because of that, OpenGL development libraries are needed for compilation. The dependencies are same as for GLFW.

The OpenGL version used is OpenGL 3.3.

  • On macOS, you need Xcode or Command Line Tools for Xcode (xcode-select --install) for required headers and libraries.
  • On Ubuntu/Debian-like Linux distributions, you need libgl1-mesa-dev and xorg-dev packages.
  • On CentOS/Fedora-like Linux distributions, you need libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel mesa-libGL-devel libXi-devel packages.
  • See here for full details.

The combination of Go 1.8, macOS and latest XCode seems to be problematic as mentioned in issue #7. This issue is probably not related to Pixel. Upgrading to Go 1.8.1 fixes the issue.

Contributing

Join us in the Discord Chat!

Pixel is in, let's say, mid-stage of development. Many of the important features are here, some are missing. That's why contributions are very important and welcome! All alone, I will be able to finish the library, but it'll take a lot of time. With your help, it'll take much less. I encourage everyone to contribute, even with just an idea. Especially welcome are issues and pull requests.

However, I won't accept everything. Pixel is being developed with thought and care. Each component was designed and re-designed multiple times. Code and API quality is very important here. API is focused on simplicity and expressiveness.

When contributing, keep these goals in mind. It doesn't mean that I'll only accept perfect pull requests. It just means that I might not like your idea. Or that your pull requests could need some rewriting. That's perfectly fine, don't let it put you off. In the end, we'll just end up with a better result.

Take a look at CONTRIBUTING.md for further information.

License

MIT

Comments
  • Audio

    Audio

    Audio is a major missing feature in Pixel. The time has come to fix this. This issue serves as a design and implementation discussion place as well as progress reporting place.

    Requirements

    Here, I will summarize the most important requirements I demand from the implementation of an audio system in Pixel.

    • Playing sound and music files
    • Playing arbitrary generated stream of PCM samples
    • Support and preference of streaming, even from files
    • Ability to stop the playback at any time
    • Easily play arbitrary number of sounds simultaneously
    • Playback must be smooth, without glitches and as precise in timing as possible
    • Ability to create arbitrary stream-based audio effects in the library as well as by the user of the library (= defining 1 or 2 interfaces for this)

    Design

    Let's define two abstract interfaces with no specific definitions yet:

    1. Wave generator - an object of this type is capable of generating a stream of PCM waves
    2. Wave receiver - an object of this type is capable of receiving a stream of PCM waves and acting accordingly

    Examples: A loaded sound file is a wave generator. A speaker is a wave receiver, since it receives the waves and plays them. An audio effect is both receiver and generator: it receives waves, modifies them and generates the modified waves.

    Having defined these interfaces, here are a few example of ways the user would chain them together to create the final audio result. Objects sending to the right are generators and objects receiving from the left are receivers.

    [ clap.mp3 ] -> [ volume adjustment, 0.5x ] -> [ speaker ]
    [ sine wave generator ] -> [ distortion effect ] -> [ phaser effect ] -> [ speaker ]
    [ music.wav ] -> [speaker ]
    

    The "wave generator" and "wave receiver" names can and probably will change.

    Implementation

    This is not decided yet. Here are a few examples of possible implementation, all of which are a bit problematic.

    1.

    type WaveGenerator interface {
        Generate(format Format, p []byte) (n int, err error)
    }
    
    type WaveReceiver interface {
        Receive(format Format, p []byte) (n int, err error)
    }
    

    I don't like this implementation. For a stream of PCM waves, it requires the user to actively feed the speaker with new data each frame. This would be very hard to use, we would probably implement more abstractions on top of this.

    2.

    type WaveGenerator interface {
        Generate(format Format, p []byte) (n int, err error)
    }
    
    type WaveReceiver interface {
        Receive(WaveGenerator)
        Update()
    }
    

    The way you would use this implementation is like this:

    sound := loadSound("hello.mp3") // WaveGenerator
    effect.Receive(sound)
    speaker.Receive(effect)
    
    for !win.Closed() {
        speaker.Update()
    }
    

    This way, it'd be easy to create arbitrary chains of generators/receivers, however, questions and problems arise when we ask: How to play multiple sounds together? How to stop the playback? How to play two sounds one after another?

    What needs to be done

    First, we need to find an actual design that meets all of the requirements. Then we need to implement it.

    Low level stuff

    For the actual audio playback, we'll use the awesome oto package by @hajimehoshi, which supports audio playback on all major platforms.

    feature 
    opened by faiface 29
  • Pixel is looking for a new maintainer

    Pixel is looking for a new maintainer

    Hey guys, thank you all for sticking around!

    In the last few months, it has become increasingly more clear that I am no longer able to maintain this repository. Pixel is and always will be one of my favorite projects and my proudest achievements. It was my first (and biggest) open-source success and brought me immense joy and satisfaction. Despite this, my focus and interests have shifted over time to other things and I can no longer gather enough motivation to sustainably maintain the project.

    That's why we're looking for a new maintainer. It should be someone, who:

    1. Is a good programmer and is experienced with the Go programming language.
    2. Has (or wants to have) a passion for Pixel.
    3. Is willing to spend time responding to issues, merging pull requests, or perhaps sometimes proposing, designing and implementing new features.
    4. Is willing to make new releases and announce them on Reddit, or other platforms.

    In other words, someone who wants to take good care of Pixel ;)

    If you think you could be this new maintainer, write a reply to this issue.

    The new maintainer will become fully responsible for the repository, I will not interfere with their decisions, but I will always be available for discussions, questions, mostly regarding the general direction of the project. If the new maintainer decides to open a Github Sponsors profile, 100% of the money will go to the new maintainer.

    Once a new maintainer is in place, Pixel will enter a new phase, hopefully, a very prosperous one :P

    That's all, hope we find somebody soon enough!

    opened by faiface 28
  • Logo design proposal

    Logo design proposal

    Hi @faiface Good day! I am a graphic designer/open source enthusiast and i would like to contribute by offering you a logo design which I think will add more to the project's visibility. It is free and i would be glad to do it of course with your permission.Thanks and best regards! - Tobaloidee

    opened by Tobaloidee 22
  • Minimizing Windowed/Fullscreen App Causes Panic

    Minimizing Windowed/Fullscreen App Causes Panic

    OS: Win 10 Go: 1.9

    EDIT: This panic is more general than we had imagined, it will occur if you minimize the application in any way (clicking on the minimize icon, Alt+TAB'ing, clicking on the icon on the taskbar), regardless of the windowed/fullscreen state. Comments up until the issue name change imply this is a fullscreen-only issue, which it is not.

    If you (for example) make the Platformer example fullscreen then Alt+TAB, it will panic with the following:

    panic: reflect: slice index out of range
    
    goroutine 1 [running, locked to thread]:
    reflect.Value.Index(0x539120, 0xc0423ecd20, 0x97, 0x0, 0x539120, 0x2, 0xc042c09cf8)
            C:/tools/go/src/reflect/value.go:871 +0x1eb
    PixelBugTest/vendor/github.com/go-gl/gl/v3.3-core/gl.Ptr(0x539120, 0xc0423ecd20, 0x539120)
            C:/Users/username/go/src/PixelBugTest/vendor/github.com/go-gl/gl/v3.3-core/gl/conversions.go:44 +0xe4
    PixelBugTest/vendor/github.com/faiface/glhf.NewTexture(0x0, 0x0, 0x0, 0x691f98, 0x0, 0x0, 0x0)
            C:/Users/username/go/src/PixelBugTest/vendor/github.com/faiface/glhf/texture.go:47 +0x125
    PixelBugTest/vendor/github.com/faiface/glhf.NewFrame(0x0, 0x0, 0x0, 0x0)
            C:/Users/username/go/src/PixelBugTest/vendor/github.com/faiface/glhf/frame.go:37 +0x75
    PixelBugTest/vendor/github.com/faiface/pixel/pixelgl.(*GLFrame).SetBounds.func1()
            C:/Users/username/go/src/PixelBugTest/vendor/github.com/faiface/pixel/pixelgl/glframe.go:35 +0x8b
    PixelBugTest/vendor/github.com/faiface/mainthread.Call.func1()
            C:/Users/username/go/src/PixelBugTest/vendor/github.com/faiface/mainthread/mainthread.go:64 +0x2d
    PixelBugTest/vendor/github.com/faiface/mainthread.Run(0x58dbd0)
            C:/Users/username/go/src/PixelBugTest/vendor/github.com/faiface/mainthread/mainthread.go:46 +0xf8
    PixelBugTest/vendor/github.com/faiface/pixel/pixelgl.Run(0x58dbd0)
            C:/Users/username/go/src/PixelBugTest/vendor/github.com/faiface/pixel/pixelgl/run.go:32 +0x60
    main.main()
            C:/Users/username/go/src/PixelBugTest/vendor/github.com/faiface/pixel/examples/platformer/main.go:394 +0x34
    exit status 2
    

    The error is possibly occurring in the glhf library, and I can confirm that it also happens in my personal project.

    opened by theGeekPirate 21
  • How about adding Reset and Printf methods on *text.Text?

    How about adding Reset and Printf methods on *text.Text?

    1. Adding a Reset method on *text.Text would allow us to not having to do this:
    txt.Clear()
    txt.Dot = txt.Orig
    
    1. Adding a Printf(format string, a ...interface{}) (n int, err error) method on *text.Text would allow users of the github.com/faiface/pixel/text package to not directly import fmt

    2. I'd also like us to consider adding a default atlas (text.BasicAtlas) initialized by:

    var BasicAtlas = NewAtlas(basicfont.Face7x13, ASCII)
    

    I believe that doing these changes to the text package would make it more convenient to use. Do you agree @faiface?

    opened by peterhellberg 20
  • Add text drawing

    Add text drawing

    Currently, Pixel doesn't support drawing text. This needs to be changed. Implementing text drawing in Go is actually way simpler than I thought it would be.

    First of all, there's an awesome package https://godoc.org/golang.org/x/image/font, which implements standard font face interface, which is well designed and very useful. Subpackages implement several font types and https://godoc.org/github.com/golang/freetype/truetype implements TrueType font loading with support of the standard font face interface. So we've got all we need.

    Now, the design of text drawing in Pixel.

    Text drawing should be done in a not-yet-existing "github.com/faiface/pixel/text" package. This package should export (at least) one type: Text. Creating one should be done by text.New(face), where face is a font.Face value. The *Text value returned from New will use that specific font face.

    Text type should implement io.Writer interface, so drawing text to it is as simple as fmt.Sprintf(txt, "hello world"). Printing to Text draws text "to the Text object". To draw the printed text to another target (such as a window, canvas, batch, ...), simply use txt.Draw(target). Clearing needs to be supported too (txt.Clear()).

    Drawing text needs to be fast. There should be no problem drawing a full screen of random text using a tiny font face at 60 FPS without a performance hit. This is something that many other libraries fail to accomplish, but it's actually not very hard. It's easily achievable by caching glyphs.

    So, to recap the interface.

    • "github.com/faiface/pixel/text"
      • New(font.Face) *Text
      • type Text
        • Clear()
        • Draw(pixel.Target)
        • Write(b []byte) (n int, err error)

    This is the basis for the interface. More methods will probably be added, such as WriteString, or SetDot (the position of the text line).

    feature 
    opened by faiface 20
  • GUI support!

    GUI support!

    Hey, first of all really nice game library, I like it how easy it's to work with it and the fact that is based on opengl. I'm interested to find out if this library will be GUI compatible in the near future...currently there isn't a stable gui library for go, but I do believe that this library could make a good one ;)

    feature 
    opened by unreadable 18
  • Add No-Brain Jogging to examples

    Add No-Brain Jogging to examples

    Hello Michal,

    first let me tell you that this is a very cool game library that you have created! In the past I have created a lot of little games and other programs in Go, I even have my own little game library which does a very similar job but has not as many features as yours.

    The next Ludum Dare is coming up and I wanted to try using someone else's engine. Looking through the options I found yours very delightful, especially your little gopher game :-)

    In order to get to know your engine in preparation, I ported my last Ludum Dare entry to it. This pull request is mainly to let you know about it (I know how cool it is to see others use your creations) and to say thank you for your effort to create something cool for the open source and especially the Go community! I would love to see a lot more games and desktops apps written in Go.

    A second reason for this PR is that I am very proud of my little game and I think it is great fun so I want to share it with people. Your examples are basically demos to show one or two features of your library in action. The gopher platformer is the closest to a real game. Even though my game is not large or really sophisticated, it is a complete game with graphics, audio, menus, instructions, fun gameplay and high scores. I think it makes for a great addition to your example list for people to see what is possible and to have a "real-life" example of how to use both your pixel and beep libraries.

    Again, you are doing a great job here, keep up the good work!

    PS: I am also working on a big addition to your library, I will create another pull request when that is done... :-)

    opened by gonutz 17
  • Polygon()

    Polygon()

    When I use .Polygon(0) (e.g. fill) and have a complex figure the fill does not just fill the area but also (on the left side?) it colors outside the lines... When switching to .Polygon(1) I have the correct figure, but the lines are not crisp, it seems the line thickness is perpendicular with the actual line. Now the lines seems "hairy" when I zoom in.

    Is there a way to only fill the designated area defined by a closed set of points?

    opened by xinkiknix 17
  • Added SetCursorMode()

    Added SetCursorMode()

    http://www.glfw.org/docs/3.1/input.html#cursor_mode

    Mainly implemented to allow window-based mouse locking, but should (and does) support all other cursor modes as well.

    opened by theGeekPirate 17
  • Add AnchorPos struct and functions

    Add AnchorPos struct and functions

    This PR adds the concept of anchors to align elements.

    It adds:

    • type Anchor: a vector used to define anchors, such as Center, Top, TopRight, etc.;
    • func (Anchor) String() string: returns the string representation of an anchor.;
    • func (*Rect) AnchorPos(anchor Anchor) Vec: returns the ~~absolute~~ position of the given anchor of the Rect.;
    • ~~edit: func (*Rect) AnchorTo(Anchor): updates the Rect position to align it on the given anchor.~~
    • edit: func (Rect) AlignedTo(Anchor) Rect: returns the rect moved to be aligned on the given anchor.
    • ~~edit: func (Matrix) Aligned(Rect, anchorPos AnchorPos) Matrix: moves everything to align the given rectangle on the given anchor position.~~
    • edit: func (*Text) AlignedTo(pixel.Anchor) *Text: returns the text moved by the given anchor.
    • edit: func (Anchor) Opposite() Anchor: returns the opposite position of the anchor (ie. Top -> Bottom; BottomLeft -> TopRight, etc.).

    Example code

    edit: Update with last modifications.

    package main
    
    import (
    	"image/color"
    	"fmt"
    	"github.com/faiface/pixel"
    	"github.com/faiface/pixel/imdraw"
    	"github.com/faiface/pixel/pixelgl"
    	"golang.org/x/image/colornames"
    	"github.com/faiface/pixel/text"
    	"golang.org/x/image/font/basicfont"
    )
    
    const (
    	winWidth   float64 = 600
    	winHeight  float64 = 450
    	padding    float64 = 170
    	rectWidth, rectHeight float64 = 90, 90
    	minX, minY float64 = padding, padding
    	maxX, maxY float64 = winWidth - padding, winHeight - padding
    	cX, cY     float64 = winWidth/2, winHeight/2
    )
    
    var dotsPos map[pixel.Anchor]pixel.Vec = map[pixel.Anchor]pixel.Vec{
    	pixel.Center: pixel.V(cX, cY),
    	pixel.Top: pixel.V(cX, maxY),
    	pixel.TopRight: pixel.V(maxX, maxY),
    	pixel.Right: pixel.V(maxX, cY),
    	pixel.BottomRight: pixel.V(maxX, minY),
    	pixel.Bottom: pixel.V(cX, minY),
    	pixel.BottomLeft: pixel.V(minX, minY),
    	pixel.Left: pixel.V(minX, cY),
    	pixel.TopLeft: pixel.V(minX, maxY),
    }
    func drawRectanglesAndDots(win *pixelgl.Window) {
    	imd := imdraw.New(nil)
    	for anchor, vect := range dotsPos {
    		rect := pixel.R(vect.X, vect.Y, vect.X + rectWidth, vect.Y + rectHeight).AlignedTo(anchor)
    		drawRect(imd, rect, colornames.Gray)
    		drawDot(imd, vect, colornames.Red)
    	}
    	imd.Draw(win)
    }
    
    func drawLabels(win *pixelgl.Window) {
    	const scale float64 = 2
    	basicAtlas := text.NewAtlas(basicfont.Face7x13, text.ASCII)
    	for anchor, vect := range dotsPos {
    		basicTxt := text.New(vect, basicAtlas)
    		basicTxt.Color = colornames.Yellow
    		fmt.Fprintln(basicTxt, anchor.String())
    		basicTxt.AlignedTo(anchor).Draw(win, pixel.IM.Scaled(basicTxt.Orig, scale))
    	}
    }
    
    func drawRect(imd *imdraw.IMDraw, rect pixel.Rect, color color.Color) {
    	imd.Color = color
    	imd.Push(rect.Min, rect.Max)
    	imd.Rectangle(0)
    }
    
    func drawDot(imd *imdraw.IMDraw, vect pixel.Vec, color color.Color) {
    	imd.Color = color
    	imd.Push(vect)
    	imd.Ellipse(pixel.V(3, 3), 0)
    }
    
    func run() {
    	cfg := pixelgl.WindowConfig{
    		Title:  "AnchorPos examples",
    		Bounds: pixel.R(0, 0, winWidth, winHeight),
    		VSync:  true,
    	}
    	win, err := pixelgl.NewWindow(cfg)
    	if err != nil {
    		panic(err)
    	}
    
    	win.Clear(colornames.Lightgray)
    	drawRectanglesAndDots(win)
    	drawLabels(win)
    
    	for !win.Closed() {
    		win.Update()
    	}
    }
    
    func main() {
    	pixelgl.Run(run)
    }
    

    Result

    image

    More to come

    edit: done!

    ~~The modifications added in this first commit are required for other functions that I plan to add as well in this PR, named AnchorTo:~~

    ~~- func (r *Rect) AnchorTo(anchor AnchorPos): updates the Rect position to align it on the given anchor.~~ ~~- func (r *Text) AnchorTo(anchor AnchorPos): updates the Text position to align it on the given anchor.~~ ~~- etc. At this point it's easy to add implementation for many other objects (Circle, Image, etc.)~~

    ~~Example usage:~~

    basicTxt := text.New(vect, basicAtlas)
    basicTxt.AnchorTo(AnchorPos.Center)
    

    ~~Here, basicTxt will be centered relative to the vect position. With AnchorPos.Left, it will be centered verticaly but not horizontally, etc.~~

    ~~This is helpful to position and align elements.~~

    ~~I would like to get your feedback before to continue. ;)~~

    opened by roipoussiere 15
  • How to set text kerning?

    How to set text kerning?

    Hello. It is possible to set letter spacing? I mean analog letter-spacing.

    Example code

    func main() {
       ttf, err := loadTTF("Mariupol-Regular.ttf", 8) //function from doc
       if err != nil {
    	 log.Fatal(err)
       }
       
       atlas := text.NewAtlas(ttf, text.ASCII, text.RangeTable(unicode.Cyrillic))
       basicTxt := text.New(pixel.V(15, 175), atlas)
       basicTxt.SetKerning(2) //I want to use something similar, but I can't find it in the pixel or freetype/truetype
    }
    
    opened by makarychev13 0
  • animation from tutorial lags sometimes

    animation from tutorial lags sometimes

    when i run final code of this part of tutorial animation lags in places

    video

    https://user-images.githubusercontent.com/33498670/181697592-062e6c7f-7b9f-4334-8e32-eef00fa4ce30.mov

    which led me to think that this behavior would also be in the game that I want to make so I chose to use other game engine

    until I found #304 and ran the command: go get -u -tags=gles3 github.com/go-gl/glfw/v3.3/glfw after that, the problem is solved and the animation is always smooth it turns out it was because I have apple arm cpu


    i think it is important to mention that problem and command to solve it in tutorial or other documentation so that some people don't get wrong impression about the engine when they go through tutorial

    opened by norflin321 0
  • SetMatrix(matrix) + Draw(target) vs Draw(target, matrix)

    SetMatrix(matrix) + Draw(target) vs Draw(target, matrix)

    First, I'd like to just say thank you for this package. I've been using Pixel for a few months now, and I'm very happy with it. It has the perfect balance between simplicity and not trying too hard to isolate me away the underlying logic.

    As my game is growing in size and complexity, I often find it challenging to deal with the fact that SetMatrix (in many components) actually makes the component stateful, which in some situations makes it harder to have clean separate of concerns.

    At the same time, I've met other challenges due to the fact that not all components have the same definition: Sometimes it's Draw(target) and sometimes it's Draw(target, matrix). As go is very strictly typed, there is no convenient solution to make all components compatible with a single Drawer interface.

    Is there a fundamental and purposeful design difference between those two patterns?

    target.SetMatrix(matrix)
    foo.Draw(target)
    
    foo.Draw(target, matrix)
    

    If no, do you think that making everything use the second pattern would be a welcome change to this package?

    opened by Seb-C 0
  • Passthrough Shader in example breaks IMDraw

    Passthrough Shader in example breaks IMDraw

    I added shaders to my game recently and to ease in the new feature I decided to use your passthrough shader from the tutorial here. After adding it, I noticed anything being drawn by an IMDraw was black instead of the color it was supposed to be. Sprites and the Canvas clear color all show up as normal, but my IMDraw borders around buttons and simplistic progress bar appear as black.

    Two causes come to mind.

    1. There is no "texture" for IMDraw things for the shader to reference.
    2. I'm drawing everything to a canvas, and then drawing the canvas to the window.

    Number 1 makes a lot of sense if you look at the source, but I don't think I know enough about shaders yet to know what to do instead. Number 2 is something I read can enable a lot of advanced things but I'm still wrapping my head around the details so I admit this might be a side effect of that.

    I don't think this is a bug in pixel, just in my understanding. How should I write my shaders to work with IMDraw?

    Mac Big Sur x64 Pixel v0.10 Go 1.17.7

    opened by coreyog 1
  • Alllow shader / uniforms to be updated during the game loop

    Alllow shader / uniforms to be updated during the game loop

    Currently, it appears that we're only intended to ever use one fragment shader, and uniforms are only updated once per frame.

    A little reworking should permit multiple shaders to be used / switched between, and for uniforms to be changed between draw calls, which would allow much greater flexibility in applying different effects to different graphical elements in a scene.

    enhancement help wanted 
    opened by JasonMDavey 0
Releases(v0.11.0-beta)
  • v0.11.0-beta(Aug 31, 2021)

  • v0.10.0(Aug 22, 2020)

    The big changes from upgrading GLFW have been played with for a sufficient time to tag a non-beta v0.10.0. So here it is!

    Rather busy right now, but hope to get some of the new proposed functionality into the next release.

    Have a peek at the CHANGELOG to see what else is new with this release.

    Source code(tar.gz)
    Source code(zip)
  • v0.10.0-beta(May 10, 2020)

    All changes are now documented in the Changelog so please have a look to see what's new.

    Hello loyal Pixelers!

    This release brings support for GLFW 3.3 and I know you've been excited for it. Some new features from the update are already in, and after a little bit more testing, proper gamepad support should be in the next release. (If you can test gamepads on a Mac, or with a PS controller, please take a look at https://github.com/faiface/pixel/pull/233 !!)

    In just the brief few weeks that I've worked on this project as the new maintainer, I've been very impressed with the strong community support, and I feel this really distinguishes Pixel. Thanks to everyone who's contributed to this library, and especially thank you to its many users.

    Please stay tuned, we hope to have lots more for you soon.

    Source code(tar.gz)
    Source code(zip)
  • v0.8.0(Oct 10, 2018)

    ... shaders ...

    Wavy gopher

    Less than a year ago I released Pixel 0.7. In the announcement, I declared that I will no longer be working on Pixel so much and instead leave the big things to contributors.

    I am very happy to announce that despite this, Pixel is thriving. And it's not thanks to me but thanks to the great community and new contributors.

    Stats

    • Pixel 0.7 was released on Feb 20, 2018
    • Reached over 1600 stars
    • Closed 70 issues in total
    • Closed 49 pull request, the majority of which got merged

    Changes / new features

    There are two big changes in this release. The first one is boring, the second one is extremely exciting.

    1. Examples were moved to a separate pixel-examples repository as per #135, which shrunk the main repo from ~90MB to <1MB in size.
    2. pixelgl.Canvas got a support for custom fragment shaders. This is a huge and exciting change that happened thanks to @thegtproject. Thank you a lot for that!

    Accompanying the shader support comes a new tutorial so you know how to use them.

    This has been a great time for Pixel and I hope it continues to be. New contributors and users are always warmly welcomed. Just join the chat at https://gitter.im/pixellib/Lobby.

    Source code(tar.gz)
    Source code(zip)
  • v0.7(Feb 20, 2018)

    Almost a year ago, Pixel 0.6 was released. It's time for a new release!

    So, let me introduce to you, the one and only Pixel 0.7.

    This version is mostly an iterative update, an evolution upon Pixel 0.6, not a revolution. However, quite a few changes accumulated since 0.6. One big thing is audio. It's been around for a while, but only now we are announcing it officially. Let's get to the changes!

    Stats

    • Pixel 0.6 was released on May 30, 2017
    • Since then we added 2474 LOC and deleted 168 LOC in 170 commits
    • Reached 1k stars! (became the most starred game library for Go)
    • Closed 51 issues in total
    • Got 13 contributors participating

    Looking for contributors!

    I made the original Pixel with though and care and I think we ended up with a decent library. Since then, I've moved on to other things and Pixel is no longer my main focus. But, there's still a lot of room for improvements. That's why I invite anyone who's interested to help Pixel thrive! Your contributions will be highly appreciated by me as well as many users of Pixel all around the world every day. Check out the short CONTRIBUTING guide to get started!

    New features

    Breaking changes

    Improvements

    • Significant optimizations in IMDraw
    • Partial benchmarks
    • Partial tests
    • Many small optimizations
    • Fixed a number of bugs

    Thank you

    Huge thank you to everyone who contributed to or supported Pixel in any way! Special thanks go to:

    • @seebs, for investing so much time into optimizing IMDraw
    • @PlainSight, for a number of small improvements and tests
    • @svera, for many community examples
    • @peterhellberg, for yet more great community examples and a few useful improvements
    • @mewmew, for helping with the Beep library
    Source code(tar.gz)
    Source code(zip)
  • v0.6(May 30, 2017)

    Finally, approximately a month since the first public Pixel release, we're releasing Pixel 0.6.

    Big thanks to everyone who contributed by sharing ideas, opening issues, or sending pull requests.

    Stats

    • Pixel 0.5 was released on April 25
    • Since then we added 1981 LOC and deleted 469 LOC in 105 commits
    • Gained 478 GitHub stars
    • Closed 19 issues

    New features

    The main goal of 0.6 was text drawing. This goal was quickly accomplished and perfected over the last month. Few more features landed too.

    Breaking changes

    Unfortunately, there are a few very important breaking changes in this release too. I decided to included them, because the old ways were starting to annoy me and I felt like these were the right changes to do. Hopefully, there will be no more breaking changes after this.

    All tutorials and examples were updated according to the breaking changes.

    • Changed Vec implementation from complex128 to a simple struct. This choice was made because although the complex128 implementation allowed for a very nice addition and subtraction using + and - operators, it complicated pretty much every other operation.
    • Removed SetMatrix and SetColorMask from Sprite and replaced the simple sprite.Draw(target) signature with sprite.Draw(target, matrix) and sprite.DrawColorMask(target, matrix, mask) methods. This choice was made, because it avoids a lot of typing and eliminates some state. The same change was done for Canvas, although SetMatrix and SetColorMask methods were kept there, because they serve a different purpose.
    • IMDraw properties were changed from methods to fields. So now, instead of imd.Color(colornames.Red) you write imd.Color = colornames.Red. This is more convenient and allows for retrieving the value easily.

    Improvements

    • Added examples/community directory, for community examples: right now, there's a maze generator by Stephen Chavez
    • Improved documentation in several places
    • Fixed numerous bugs
    Source code(tar.gz)
    Source code(zip)
  • v0.5.1(Apr 28, 2017)

  • v0.5(Apr 25, 2017)

Owner
Michal Štrba
Infinity is smaller than 380012893427665492.
Michal Štrba
Arkanoid game in Go using Ebiten game engine with ECS.

Arkanoid-go Arkanoid game in Go using Ebiten game engine with ECS. You must have Git LFS installed when cloning the repository to download assets. See

null 55 Oct 9, 2022
AircraftWar - a game powered by Go+ spx game engine

AircraftWar - a game powered by Go+ spx game engine How to run Download Go+ and build it. See https://github.com/goplus/gop#how-to-build. Download thi

GoPlus 1 Jan 5, 2022
FlappyCalf - a game powered by Go+ spx game engine

FlappyCalf - a game powered by Go+ spx game engine How to run Download Go+ and build it. See https://github.com/goplus/gop#how-to-build. Download this

GoPlus 3 Nov 6, 2022
FlappyCalf - a game powered by Go+ spx game engine

FlappyCalf - a game powered by Go+ spx game engine How to run Download Go+ and build it. See https://github.com/goplus/gop#how-to-build. Download this

GoPlus 3 Nov 6, 2022
MazePlay - a game powered by Go+ spx game engine

MazePlay - a game powered by Go+ spx game engine How to run Download Go+ and build it. See https://github.com/goplus/gop#how-to-build. Download this g

GoPlus 1 Dec 16, 2021
RundQuiz-Game - This is a Go exercise that implements and builds a quiz game from a list of math questions in a CSV file.

Go RundQuiz Game Exercise details This exercise is broken into two parts to help simplify the process of explaining it as well as to make it easier to

IkehAkinyemi 0 Jan 5, 2022
Simple 2D game to teach myself various things about game development and ECS, etc

2d-grass-game I really don't know what to name this game. Its a big grass field, and its in 2d so....2D Grass game This is a simple 2D game to teach m

James Wynne III 1 Jan 17, 2022
A dead simple 2D game library for Go

Ebiten (v2) A dead simple 2D game library for Go Ebiten is an open source game library for the Go programming language. Ebiten's simple API allows you

Hajime Hoshi 7.6k Dec 28, 2022
Rock-paper-scissors game library

jankensheep Rock-paper-scissors game library Examples Play with two players:

Genta Kamitani 6 May 13, 2022
Golang writen 3D render library and some game-relative concepts

Golang writen 3D render library and some game-relative concepts.

null 2 Jun 6, 2022
Battleblips - Work in progress multiplayer terminal base battleship game written in Go (with mouse support!) using tcell library

battleblips Work in progress multiplayer terminal base battleship game written in Go (with mouse support!) using tcell library (see https://github.com

null 1 Apr 26, 2022
Spaceshooter - A port to go of the pygame Space Shooter game using the ebiten library

Space Shooter This is a port to go of the pygame Space Shooter (https://github.c

Jesús Espino 5 Sep 29, 2022
Engo is an open-source 2D game engine written in Go.

Engo A cross-platform game engine written in Go following an interpretation of the Entity Component System paradigm. Engo is currently compilable for

Engo 1.6k Dec 26, 2022
Go 3D Game Engine

G3N - Go 3D Game Engine G3N (pronounced "gen") is an OpenGL 3D Game Engine written in Go. It can be used to write cross-platform Go applications that

G3N - Go 3D Game Engine Repositories 2.2k Jan 9, 2023
A Game Server Skeleton in golang.

A game server skeleton implemented with golang. 注意(NOTICE) 欢迎加入QQ群: 459420581 (Gopher成都,讨论一切与go有关的话题) gonet/2 gonet1已停止维护(I no longer maintain this, p

xtaci 1.2k Dec 26, 2022
Scalable Distributed Game Server Engine with Hot Swapping in Golang

GoWorld Scalable Distributed Game Server Engine with Hot Reload in Golang Features Architecture Introduction Get GoWorld Manage GoWorld Servers Demos

Nan Lin 2.3k Dec 25, 2022
A game server framework in Go (golang)

Leaf A pragmatic game server framework in Go (golang). Features Extremely easy to use Reliable Multicore support Modularity Community QQ 群:376389675 D

Name5566 4.7k Jan 2, 2023
Lightweight, facility, high performance golang based game server framework

Nano Nano is an easy to use, fast, lightweight game server networking library for Go. It provides a core network architecture and a series of tools an

Lonng 2.2k Jan 1, 2023
A pure Go game engine

Oak A pure Go game engine Table of Contents Installation Motivation Features Support Quick Start Implementation and Examples Finished Games Installati

Oakmound Studio 1.3k Jan 8, 2023