invaders

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: MIT Imports: 3 Imported by: 3

README

invaders

A tiny library for generating unique Space Invader-like avatars given a source of randomness.

Documentation

Index

Constants

View Source
const Height = 11
View Source
const Middle = Width / 2
View Source
const Width = 11

Variables

View Source
var Antennas = []Mask{
	{
		{},
		{},
		{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
	},
	{
		{},
		{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
		{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
	},
	{
		{},
		{},
		{0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0},
	},
	{
		{},
		{0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0},
		{0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0},
	},
	{
		{},
		{},
		{0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
	},
	{
		{},
		{0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0},
		{0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
	},
	{
		{},
		{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
		{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
	},
}
View Source
var Arms = []Mask{
	{},
	{},
	{},
	{},
	{
		{},
		{},
		{},
		{},
		{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
		{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
		{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
		{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
		{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
	},
	{
		{},
		{},
		{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
		{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
		{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
		{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
	},
}
View Source
var Bodies = []Mask{
	{
		{},
		{},
		{},
		{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
		{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
		{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
	},
	{
		{},
		{},
		{},
		{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
		{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
		{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
	},
	{
		{},
		{},
		{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},
		{-1, 0, 1, 1, 1, 1, 1, 1, 1, 0, -1},
		{-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1},
		{-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1},
		{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},
		{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1},
	},
}
View Source
var Eyes = []Mask{
	{
		{},
		{},
		{},
		{0, 0, 0, +1, 0, 0, 0, +1, 0, 0, 0},
		{0, 0, 1, -1, 1, 1, 1, -1, 1, 0, 0},
		{0, 0, 0, +1, 0, 0, 0, +1, 0, 0, 0},
	},
	{
		{},
		{},
		{},
		{0, 0, 0, 0, +1, 0, +1, 0, 0, 0, 0},
		{0, 0, 0, 1, -1, 1, -1, 1, 0, 0, 0},
		{0, 0, 0, 0, +1, 0, +1, 0, 0, 0, 0},
	},
	{
		{},
		{},
		{},
		{0, 0, 0, +1, 0, 0, 0, +1, 0, 0, 0},
		{0, 0, 1, -1, 1, 1, 1, -1, 1, 0, 0},
		{0, 0, 1, -1, 1, 1, 1, -1, 1, 0, 0},
		{0, 0, 0, +1, 1, 1, 1, +1, 0, 0, 0},
	},
	{
		{},
		{},
		{},
		{0, 0, 0, +1, +1, 0, +1, +1, 0, 0, 0},
		{0, 0, 1, -1, -1, 1, -1, -1, 1, 0, 0},
		{0, 0, 0, +1, +1, 0, +1, +1, 0, 0, 0},
	},
}
View Source
var Legs = []Mask{
	{
		{},
		{},
		{},
		{},
		{},
		{},
		{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
		{0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0},
		{0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0},
	},
	{
		{},
		{},
		{},
		{},
		{},
		{},
		{0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0},
		{0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0},
		{0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0},
	},
	{
		{},
		{},
		{},
		{},
		{},
		{},
		{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
		{0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0},
		{0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0},
	},
	{
		{},
		{},
		{},
		{},
		{},
		{},
		{0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0},
		{0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0},
		{0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0},
	},
	{
		{},
		{},
		{},
		{},
		{},
		{},
		{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
		{0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0},
		{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
	},
	{
		{},
		{},
		{},
		{},
		{},
		{},
		{0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0},
		{0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0},
		{0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0},
	},
	{
		{},
		{},
		{},
		{},
		{},
		{},
		{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
		{0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0},
		{0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0},
	},
	{
		{},
		{},
		{},
		{},
		{},
		{},
		{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
		{0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0},
		{0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0},
	},
	{
		{},
		{},
		{},
		{},
		{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
		{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
		{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
		{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1},
	},
}

Functions

This section is empty.

Types

type Invader

type Invader [Height]Row

func (*Invader) Set

func (invader *Invader) Set(r *rand.Rand)

func (Invader) String

func (invader Invader) String() string

type Mask

type Mask [Height][Width]int

func (*Mask) Overlay

func (mask *Mask) Overlay(other Mask, shade int)

type Row

type Row [Width]Shade

func (Row) IsEmpty

func (row Row) IsEmpty() bool

type Shade

type Shade int
const (
	Background Shade = iota
	Shade1
	Shade2
	Shade3
	Shade4
	Shade5
	Shade6
	Shade7
)

func (Shade) String

func (shade Shade) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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