tetris

package module
v0.0.0-...-b970b79 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 13 Imported by: 0

README

Introduction

A Tetris game written in Go, GUI drived by gtk3.

Build

go build -o bin/tetris  ./main

Screenshot

A screenshot

Requirements for macOS

sudo port install glib2
sudo port install cairo
sudo port install gtk3

sudo port install xorg-server
# Re-login 
echo $DISPLAY
# /private/tmp/com.apple.launchd.dyPCGZeHCc/org.macports:0

See https://www.macports.org/install.php#source for MacPorts

Documentation

Index

Constants

View Source
const (
	SIGNAL_ACTIVATE        = "activate"
	SIGNAL_DRAW            = "draw"
	SIGNAL_KEY_PRESS_EVENT = "key-press-event"

	KEY_LEFT  uint = 65361
	KEY_UP    uint = 65362
	KEY_RIGHT uint = 65363
	KEY_DOWN  uint = 65364

	ACTION_QUIT    = "app.quit"
	ACTION_PAUSE   = "win.pause"
	ACTION_RESUME  = "win.resume"
	ACTION_NEWGAME = "win.start"

	ACTION_ROTATE = "win.rotate"
	ACTION_LEFT   = "win.left"
	ACTION_RIGHT  = "win.right"
	ACTION_DOWN   = "win.down"

	LABEL_PAUSE     = "Pause"
	LABEL_RESUME    = "Resume"
	LABEL_STARTGAME = "Start Game"

	LABEL_SCORE = "SCORE"

	UNIT_SIZE = 32
	SPAN_SIZE = UNIT_SIZE - 2
)
View Source
const (
	ROW = 19
	COL = 11

	LEVELS = 6
)
View Source
const (
	STATE_ZERO = iota
	SATE_GAMEOVER
	STATE_GAMING
	STATE_PAUSED
)
View Source
const SHAPE_SIZE = 4

Variables

View Source
var (
	RGB_COLOR_GRAY  = Rgb{231 / 255.0, 231 / 255.0, 231 / 255.0}
	RGB_COLOR_BLUE  = Rgb{168 / 255.0, 202 / 255.0, 1}
	RGB_COLOR_GREEN = Rgb{132 / 255.0, 212 / 255.0, 129 / 255.0}
)
View Source
var ErrorMoving = errors.New("error moving")
View Source
var InvalidPoint = Point{0, -SHAPE_SIZE}

Functions

func GUI

func GUI()

Types

type Area

type Area struct {
	// contains filtered or unexported fields
}

type Game

type Game struct {
	// contains filtered or unexported fields
}

func NewGame

func NewGame() *Game

type Moving

type Moving struct {
	// contains filtered or unexported fields
}

{from, to Point}

type Point

type Point struct {
	// contains filtered or unexported fields
}

type Rgb

type Rgb [3]float64

type Shape

type Shape struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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