2017-06-15 18:05:00 -05:00
|
|
|
# Pixel [![Build Status](https://travis-ci.org/faiface/pixel.svg?branch=master)](https://travis-ci.org/faiface/pixel) [![GoDoc](https://godoc.org/github.com/faiface/pixel?status.svg)](https://godoc.org/github.com/faiface/pixel) [![Go Report Card](https://goreportcard.com/badge/github.com/faiface/pixel)](https://goreportcard.com/report/github.com/faiface/pixel) [![Join the chat at https://gitter.im/pixellib/Lobby](https://badges.gitter.im/pixellib/Lobby.svg)](https://gitter.im/pixellib/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
|
|
|
2017-04-24 07:18:51 -05:00
|
|
|
|
2017-04-24 15:51:43 -05:00
|
|
|
A hand-crafted 2D game library in Go. Take a look into the [features](#features) to see what it can
|
|
|
|
do.
|
2017-04-22 16:27:54 -05:00
|
|
|
|
|
|
|
```
|
|
|
|
go get github.com/faiface/pixel
|
|
|
|
```
|
|
|
|
|
2017-04-23 13:35:58 -05:00
|
|
|
See [requirements](#requirements) for the list of libraries necessary for compilation.
|
|
|
|
|
2017-04-22 16:27:54 -05:00
|
|
|
## Tutorial
|
|
|
|
|
|
|
|
The [Wiki of this repo](https://github.com/faiface/pixel/wiki) contains an extensive tutorial
|
|
|
|
covering several topics of Pixel. Here's the content of the tutorial parts so far:
|
|
|
|
|
2017-04-22 16:29:05 -05:00
|
|
|
- [Creating a Window](https://github.com/faiface/pixel/wiki/Creating-a-Window)
|
|
|
|
- [Drawing a Sprite](https://github.com/faiface/pixel/wiki/Drawing-a-Sprite)
|
|
|
|
- [Moving, scaling and rotating with Matrix](https://github.com/faiface/pixel/wiki/Moving,-scaling-and-rotating-with-Matrix)
|
|
|
|
- [Pressing keys and clicking mouse](https://github.com/faiface/pixel/wiki/Pressing-keys-and-clicking-mouse)
|
|
|
|
- [Drawing efficiently with Batch](https://github.com/faiface/pixel/wiki/Drawing-efficiently-with-Batch)
|
|
|
|
- [Drawing shapes with IMDraw](https://github.com/faiface/pixel/wiki/Drawing-shapes-with-IMDraw)
|
2017-05-29 19:53:24 -05:00
|
|
|
- [Typing text on the screen](https://github.com/faiface/pixel/wiki/Typing-text-on-the-screen)
|
2018-10-10 06:48:53 -05:00
|
|
|
- [Using a custom fragment shader](https://github.com/faiface/pixel/wiki/Using-a-custom-fragment-shader)
|
2017-04-22 16:27:54 -05:00
|
|
|
|
2018-09-07 10:51:10 -05:00
|
|
|
## [Examples](https://github.com/faiface/pixel-examples)
|
2017-04-22 16:27:54 -05:00
|
|
|
|
2018-09-07 10:51:10 -05:00
|
|
|
The [examples](https://github.com/faiface/pixel-examples) repository contains a few
|
2017-04-22 16:27:54 -05:00
|
|
|
examples demonstrating Pixel's functionality.
|
|
|
|
|
|
|
|
**To run an example**, navigate to it's directory, then `go run` the `main.go` file. For example:
|
|
|
|
|
|
|
|
```
|
2018-09-07 10:51:10 -05:00
|
|
|
$ cd pixel-examples/platformer
|
2017-04-22 16:27:54 -05:00
|
|
|
$ go run main.go
|
|
|
|
```
|
|
|
|
|
2017-04-23 06:54:53 -05:00
|
|
|
Here are some screenshots from the examples!
|
2017-04-22 16:27:54 -05:00
|
|
|
|
2018-09-07 10:55:20 -05:00
|
|
|
| [Lights](https://github.com/faiface/pixel-examples/blob/master/lights) | [Platformer](https://github.com/faiface/pixel-examples/blob/master/platformer) |
|
2017-04-23 13:57:36 -05:00
|
|
|
| --- | --- |
|
2018-09-07 10:55:20 -05:00
|
|
|
| ![Lights](https://github.com/faiface/pixel-examples/blob/master/lights/screenshot.png) | ![Platformer](https://github.com/faiface/pixel-examples/blob/master/platformer/screenshot.png) |
|
2017-04-22 16:27:54 -05:00
|
|
|
|
2018-09-07 10:55:20 -05:00
|
|
|
| [Smoke](https://github.com/faiface/pixel-examples/blob/master/smoke) | [Typewriter](https://github.com/faiface/pixel-examples/blob/master/typewriter) |
|
2017-04-23 13:57:36 -05:00
|
|
|
| --- | --- |
|
2018-09-07 10:55:20 -05:00
|
|
|
| ![Smoke](https://github.com/faiface/pixel-examples/blob/master/smoke/screenshot.png) | ![Typewriter](https://github.com/faiface/pixel-examples/blob/master/typewriter/screenshot.png) |
|
2017-04-22 16:27:54 -05:00
|
|
|
|
2018-11-23 04:23:38 -06:00
|
|
|
| [Raycaster](https://github.com/faiface/pixel-examples/blob/master/community/raycaster) | [gonutz' No-Brain Jogging](https://github.com/gonutz/no-brain-jogging) |
|
2018-01-11 15:55:26 -06:00
|
|
|
| --- | --- |
|
2018-11-23 04:23:38 -06:00
|
|
|
| ![Raycaster](https://github.com/faiface/pixel-examples/blob/master/community/raycaster/screenshot.png) | ![NoBrainJogging](https://raw.githubusercontent.com/gonutz/no-brain-jogging/master/screenshots/screenshot.png) |
|
2018-11-21 17:44:46 -06:00
|
|
|
|
2017-04-22 16:27:54 -05:00
|
|
|
## Features
|
|
|
|
|
2017-04-23 15:29:23 -05:00
|
|
|
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.
|
2017-04-22 16:27:54 -05:00
|
|
|
|
|
|
|
- Fast 2D graphics
|
|
|
|
- Sprites
|
|
|
|
- Primitive shapes with immediate mode style
|
|
|
|
[IMDraw](https://github.com/faiface/pixel/wiki/Drawing-shapes-with-IMDraw) (circles, rectangles,
|
|
|
|
lines, ...)
|
|
|
|
- Optimized drawing with [Batch](https://github.com/faiface/pixel/wiki/Drawing-efficiently-with-Batch)
|
2017-05-24 07:36:18 -05:00
|
|
|
- Text drawing with [text](https://godoc.org/github.com/faiface/pixel/text) package
|
2018-02-18 13:58:41 -06:00
|
|
|
- Audio through a separate [Beep](https://github.com/faiface/beep) library.
|
2017-04-22 16:27:54 -05:00
|
|
|
- Simple and convenient API
|
2017-05-24 13:39:11 -05:00
|
|
|
- Drawing a sprite to a window is as simple as `sprite.Draw(window, matrix)`
|
2017-04-22 16:27:54 -05:00
|
|
|
- Wanna know where the center of a window is? `window.Bounds().Center()`
|
|
|
|
- [...](https://godoc.org/github.com/faiface/pixel)
|
2017-04-22 16:34:34 -05:00
|
|
|
- Full documentation and tutorial
|
2017-04-22 16:27:54 -05:00
|
|
|
- Works on Linux, macOS and Windows
|
|
|
|
- Window creation and manipulation (resizing, fullscreen, multiple windows, ...)
|
2017-05-24 07:42:00 -05:00
|
|
|
- Keyboard (key presses, text input) and mouse input without events
|
2017-04-22 16:27:54 -05:00
|
|
|
- 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
|
2017-04-23 06:54:53 -05:00
|
|
|
multiplication and a few more features
|
2017-04-22 16:27:54 -05:00
|
|
|
- Pixel uses `float64` throughout the library, compatible with `"math"` package
|
2017-04-22 16:34:06 -05:00
|
|
|
- Geometry transformations with
|
|
|
|
[Matrix](https://github.com/faiface/pixel/wiki/Moving,-scaling-and-rotating-with-Matrix)
|
|
|
|
- Moving, scaling, rotating
|
|
|
|
- Easy camera implementation
|
2017-04-22 18:30:15 -05:00
|
|
|
- Off-screen drawing to Canvas or any other target (Batch, IMDraw, ...)
|
2017-04-22 16:27:54 -05:00
|
|
|
- Fully garbage collected, no `Close` or `Dispose` methods
|
|
|
|
- Full [Porter-Duff](http://ssp.impulsetrain.com/porterduff.html) 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
|
2017-04-22 16:44:17 -05:00
|
|
|
- Platform and backend independent [core](https://godoc.org/github.com/faiface/pixel)
|
2017-04-22 16:27:54 -05:00
|
|
|
- Core Target/Triangles/Picture pattern makes it easy to create new drawing targets that do
|
|
|
|
arbitrarily crazy stuff (e.g. graphical effects)
|
2017-04-24 13:39:18 -05:00
|
|
|
- Small codebase, ~5K lines of code, including the backend [glhf](https://github.com/faiface/glhf)
|
|
|
|
package
|
2017-04-22 16:27:54 -05:00
|
|
|
|
|
|
|
## Missing features
|
|
|
|
|
2017-04-22 16:36:54 -05:00
|
|
|
Pixel is in development and still missing few critical features. Here're the most critical ones.
|
2017-04-22 16:27:54 -05:00
|
|
|
|
2018-02-18 13:58:41 -06:00
|
|
|
- ~~Audio~~
|
2017-05-24 07:36:18 -05:00
|
|
|
- ~~Drawing text~~
|
2017-04-22 16:27:54 -05:00
|
|
|
- Antialiasing (filtering is supported, though)
|
2017-05-01 18:15:33 -05:00
|
|
|
- ~~Advanced window manipulation (cursor hiding, window icon, ...)~~
|
2017-04-22 16:27:54 -05:00
|
|
|
- Better support for Hi-DPI displays
|
2017-04-23 07:32:41 -05:00
|
|
|
- Mobile (and perhaps HTML5?) backend
|
2019-01-28 14:54:37 -06:00
|
|
|
- ~~More advanced graphical effects (e.g. blur)~~ (solved with the addition of GLSL effects)
|
2017-04-23 07:35:56 -05:00
|
|
|
- Tests and benchmarks
|
2019-01-28 14:54:37 -06:00
|
|
|
- Vulkan support
|
2017-04-22 16:27:54 -05:00
|
|
|
|
|
|
|
**Implementing these features will get us to the 1.0 release.** Contribute, so that it's as soon as
|
|
|
|
possible!
|
|
|
|
|
|
|
|
## Requirements
|
|
|
|
|
2017-11-15 14:38:24 -06:00
|
|
|
If you're using Windows and having trouble building Pixel, please check [this
|
|
|
|
guide](https://github.com/faiface/pixel/wiki/Building-Pixel-on-Windows) on the
|
|
|
|
[wiki](https://github.com/faiface/pixel/wiki).
|
|
|
|
|
2017-04-22 16:58:13 -05:00
|
|
|
[PixelGL](https://godoc.org/github.com/faiface/pixel/pixelgl) backend uses OpenGL to render
|
|
|
|
graphics. Because of that, OpenGL development libraries are needed for compilation. The dependencies
|
|
|
|
are same as for [GLFW](https://github.com/go-gl/glfw).
|
2017-04-22 16:27:54 -05:00
|
|
|
|
2017-10-19 14:34:09 -05:00
|
|
|
The OpenGL version used is **OpenGL 3.3**.
|
|
|
|
|
2017-04-22 16:27:54 -05:00
|
|
|
- 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](http://www.glfw.org/docs/latest/compile.html#compile_deps) for full details.
|
|
|
|
|
2017-04-26 16:14:01 -05:00
|
|
|
**The combination of Go 1.8, macOS and latest XCode seems to be problematic** as mentioned in issue
|
2017-04-26 16:15:08 -05:00
|
|
|
[#7](https://github.com/faiface/pixel/issues/7). This issue is probably not related to Pixel.
|
|
|
|
**Upgrading to Go 1.8.1 fixes the issue.**
|
2017-04-26 16:14:01 -05:00
|
|
|
|
2017-04-22 16:27:54 -05:00
|
|
|
## Contributing
|
|
|
|
|
2017-04-24 13:55:18 -05:00
|
|
|
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**.
|
|
|
|
|
2017-04-24 14:00:01 -05:00
|
|
|
**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.
|
2017-04-24 13:55:18 -05:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2018-02-18 13:58:41 -06:00
|
|
|
Take a look at [CONTRIBUTING.md](CONTRIBUTING.md) for further information.
|
2017-04-24 13:55:18 -05:00
|
|
|
|
|
|
|
For any kind of discussion, feel free to use our
|
2018-03-26 03:37:03 -05:00
|
|
|
[Gitter](https://gitter.im/pixellib/Lobby)
|
2017-04-24 13:55:18 -05:00
|
|
|
community.
|
2017-04-22 16:27:54 -05:00
|
|
|
|
|
|
|
## License
|
|
|
|
|
2017-04-24 07:21:09 -05:00
|
|
|
[MIT](LICENSE)
|