• Stars
    star
    82
  • Rank 382,689 (Top 8 %)
  • Language
    Go
  • License
    MIT License
  • Created about 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple 2D game prototyping framework.

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.

Games

Installation

Install the Go programming language. After clicking the download link you will be referred to the installation instructions for your specific operating system.

Install Git and make it available in the PATH so the go tool can use it.

For Linux and OS X you need a C compiler installed. On Windows this is not necessary.

On Linux there are two backends available, GLFW and SDL2. For GLFW you need these libraries installed (tested on Linux Mint, other distros might be slightly different):

libx11-dev libxrandr-dev libgl1-mesa-dev libxcursor-dev libxinerama-dev libxi-dev

GLFW is used by default. To use SDL2 you need to add -tags sdl2 to your Go builds, e.g. go run -tags sdl2 main.go. Also you need the SDL2 libraries installed:

libsdl2-dev libsdl2-mixer-dev libsdl2-image-dev

Install the library and samples by running the following on your command line:

go get github.com/gonutz/prototype/...

Documentation

For a description of all library functions, see the godoc page for this project. Note that most of the functionality is in the Window interface and hence the descriptions are listed as code comments in the source for that type.

Example

package main

import (
	"math"

	"github.com/gonutz/prototype/draw"
)

func main() {
	draw.RunWindow("Title", 640, 480, update)
}

func update(window draw.Window) {
	// find the screen center
	w, h := window.Size()
	centerX, centerY := w/2, h/2

	// draw a button in the center of the screen
	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)
	}

	// check all mouse clicks that happened during this frame
	for _, click := range window.Clicks() {
		dx, dy := click.X-centerX, click.Y-centerY
		squareDist := dx*dx + dy*dy
		if squareDist <= 20*20 {
			// close the window and end the application
			window.Close()
		}
	}
}

This example displays a window with a round button in the middle to close it. It demonstrates some basic drawing and event handling code.

More Repositories

1

wui

Windows GUI library for Go (Golang). Comes with a graphical UI designer.
Go
167
star
2

d3d9

Direct3D9 wrapper for Go.
Go
150
star
3

framebuffer

Go library for accessing the framebuffer under Raspbian as a Go Image.
Go
37
star
4

ide

Go IDE written in Go; currently Windows-only desktop application
Go
11
star
5

no-brain-jogging

Game written in Go, shoot Zombies with Mathematics
Go
7
star
6

go-sdl2-dll

Go wrapper for SDL2 - this is for Windows only and uses the DLL, no need for CGo
Go
5
star
7

dsp

Digital signal processing functions in Go
Go
3
star
8

ftp-client

Go implementation of the FTP protocol (RFC 959)
Go
3
star
9

auto

Go library for Windows automation
Go
3
star
10

graphics32

Graphics32 is a graphics library for Delphi and Lazarus. Optimized for 32-bit pixel formats, it provides fast operations with pixels and graphic primitives. In most cases Graphics32 considerably outperforms the standard TBitmap/TCanvas methods.
Pascal
2
star
11

dfm

Go library to parse/modify/generate Delphi DFM files
Go
2
star
12

tic

Simple timing output for Go functions
Go
2
star
13

aoc22

https://adventofcode.com/2022
Go
2
star
14

payload

Append a data file to your executable and read it back in at runtime.
Go
2
star
15

pas

Delphi parser written in Go, work in progress
Go
2
star
16

ds

DirectSound wrapper for Go.
Go
1
star
17

mbw

Monospaced black and white fonts
Go
1
star
18

cgo

Obsolete Go wrappers that use CGo on Windows but now have pure Go counterparts
Go
1
star
19

jolina

A little two-day game created with my friend Jolina
Go
1
star
20

fontstash.go

A dynamic font glyph cache for OpenGL ported to golang.
Go
1
star
21

blob

Go library for building binary blob files, mapping string IDs to byte data.
Go
1
star
22

expr

Arithmetic expression parser
Go
1
star
23

ld41

Ludum Dare 41 Entry - Combine Two Incompatible Genres
Go
1
star
24

zoom_thumbs_up

Windows tool to click the thumbs up reaction in the Zoom client.
Go
1
star
25

gif2pngs

Convert a GIF image to PNG frames
Go
1
star
26

checkmark

Windows tool that copies a checkmark character ✓ into the clipboard
Go
1
star
27

work

Work time tracking GUI tool for Windows, written in Go
Go
1
star
28

usbreset

Go tool that does what the C version of usbreset does - reset USB devices
Go
1
star
29

dfm_clear_explicit_zeros

Go tool to remove unnecessary Explicit properties from Delphi DFM files.
Go
1
star
30

getmp3

Linux script to load Youtube videos as mp3s into your Music folder
Shell
1
star
31

volume

Windows tools for volume up/down/mute written in Go
Go
1
star
32

sdl2

Pure Go SDL2 wrapper for Windows, no CGo
Go
1
star
33

ico

Go library and command line tool to generate .ico files from image
Go
1
star
34

sdl2-dll-issue

This is an issue on 32 bit Windows when calling the SDL2.dll
Go
1
star
35

tile_screen

Windows program to move a window on a tiled screen
Go
1
star
36

zoom_emote

Windows program to click Zoom emojis with keyboard shortcuts
Go
1
star