https://github.com/gonutz/prototype
Simple 2D game prototyping framework targetting Windows, Mac, Linux, WASM.
https://github.com/gonutz/prototype
Last synced: 27 days ago
JSON representation
Simple 2D game prototyping framework targetting Windows, Mac, Linux, WASM.
- Host: GitHub
- URL: https://github.com/gonutz/prototype
- Owner: gonutz
- License: mit
- Created: 2015-03-04T09:24:39.000Z (about 11 years ago)
- Default Branch: main
- Last Pushed: 2025-08-05T12:45:43.000Z (7 months ago)
- Last Synced: 2025-08-15T04:41:32.694Z (7 months ago)
- Language: C
- Homepage: https://pkg.go.dev/github.com/gonutz/prototype/draw
- Size: 4.02 MB
- Stars: 92
- Watchers: 3
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - gonutz/prototype
- awesome-go-plus - prototype - Cross-platform (Windows/Linux/Mac) library for creating desktop games using a minimal API.  (Game Development / Search and Analytic Databases)
- awesome-go-cn - prototype
- awesome-Char - prototype - Cross-platform (Windows/Linux/Mac) library for creating desktop games using a minimal API. (Game Development / Advanced Console UIs)
- awesome-go - prototype - Cross-platform (Windows/Linux/Mac) library for creating desktop games using a minimal API. (Game Development / Search and Analytic Databases)
- go-awesome-with-star-updatetime - prototype - Cross-platform (Windows/Linux/Mac) library for creating desktop games using a minimal API. (Game Development / Advanced Console UIs)
- awesome-go - prototype - Cross-platform (Windows/Linux/Mac) library for creating desktop games using a minimal API. (Game Development / Search and Analytic Databases)
- awesome-go - prototype - Cross-platform (Windows/Linux/Mac) library for creating desktop games using a minimal API. (Game Development / Search and Analytic Databases)
- awesome-go - prototype - Cross-platform (Windows/Linux/Mac) library for creating desktop games using a minimal API. (Game Development / Search and Analytic Databases)
- fucking-awesome-go - prototype - Cross-platform (Windows/Linux/Mac) library for creating desktop games using a minimal API. (Game Development / Search and Analytic Databases)
- awesome-go-extra - prototype - 03-04T09:24:39Z|2021-12-10T17:39:44Z| (Game Development / Advanced Console UIs)
- awesome-go-with-stars - prototype - platform (Windows/Linux/Mac) library for creating desktop games using a minimal API. | 2025-08-05 | (Game Development / Search and Analytic Databases)
- awesome-go-cn - prototype
- awesome-go-cn - prototype
- awesome-go - prototype - Cross-platform (Windows/Linux/Mac) library for creating desktop games using a minimal API. (Game Development / Search and Analytic Databases)
- awesome-go-info - prototype - platform (Windows/Linux/Mac) library for creating desktop games using a minimal API. | (Relational Databases)
- awesome-go - prototype - Cross-platform (Windows/Linux/Mac) library for creating desktop games using a minimal API. (Game Development / Search and Analytic Databases)
README
# prototype
Simply prototype 2D games using an easy, minimal interface that lets you draw
simple primitives and images on the screen, easily handle mouse and keyboard
events, and play sounds.

## Installation
Install the [Go programming language](https://golang.org/dl/). After clicking
the download link you will be referred to the installation instructions for your
specific operating system.
Install [Git](https://git-scm.com/downloads) and make it available in the PATH
so the Go tool can use it.
For Linux and macOS, you need a C compiler installed. On Windows this is not
necessary.
### Supported Targets
The prototype framework supports multiple targets:
#### Windows (default)
- Uses Direct3D 9
- No additional dependencies needed
#### Linux/macOS (GLFW backend)
- Uses OpenGL via GLFW
- Install required packages (example for Ubuntu/Debian):
```sh
sudo apt install libx11-dev libxrandr-dev libgl1-mesa-dev libxcursor-dev libxinerama-dev libxi-dev
```
#### WebAssembly (experimental)
To build and run a WASM version of your game, you can use the `drawsm` tool.
Install it with
go install github.com/gonutz/prototype/cmd/drawsm@latest
It allows you to run your game locally from within your project directory with
drawsm run
or build it into the project directory with
drawsm build
## Installation (Library & Samples)
## Documentation
For a description of all library functions, see [the package doc
page](https://pkg.go.dev/github.com/gonutz/prototype/draw). Most functionality
is in the `Window` interface, and documented via code comments.
## Example
```go
package main
import (
"math"
"github.com/gonutz/prototype/draw"
)
func main() {
draw.RunWindow("Title", 640, 480, update)
}
func update(window draw.Window) {
w, h := window.Size()
centerX, centerY := w/2, h/2
mouseX, mouseY := window.MousePosition()
mouseInCircle := math.Hypot(float64(mouseX-centerX), float64(mouseY-centerY)) < 20
color := draw.DarkRed
if mouseInCircle {
color = draw.Red
}
window.FillEllipse(centerX-20, centerY-20, 40, 40, color)
window.DrawEllipse(centerX-20, centerY-20, 40, 40, draw.White)
if mouseInCircle {
window.DrawScaledText("Close!", centerX-40, centerY+25, 1.6, draw.Green)
}
for _, click := range window.Clicks() {
dx, dy := click.X-centerX, click.Y-centerY
if dx*dx+dy*dy <= 20*20 {
window.Close()
}
}
}
```
This example displays a window with a round button in the middle to close it. It demonstrates basic drawing and event handling.