bunkers

package
v0.0.0-...-8be9ec9 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WIDTH     = 800
	HEIGHT    = 600
	SKY       = 0
	GROUND    = 1
	PLAYER_A  = 2
	PLAYER_B  = 3
	TRAIL     = 4
	EXPLOSION = 5
	PALETTE   = []color.Color{
		color.RGBA{R: 200, G: 200, B: 255, A: 255},
		color.RGBA{R: 100, G: 220, B: 70, A: 255},
		color.RGBA{R: 255, G: 0, B: 0, A: 255},
		color.RGBA{R: 0, G: 0, B: 255, A: 255},
		color.RGBA{R: 255, G: 100, B: 0, A: 255},
		color.RGBA{R: 255, G: 255, B: 200, A: 255},
	}

	EXPLOSION_RADIUS = 25
	GRAVITY          = 10.0
	WIND_FACTOR      = 0.5
)

Functions

func DrawBunker

func DrawBunker(t Terrain, at int, color uint, canvas *image.Paletted)

func NewBunkerGame

func NewBunkerGame() games.Game

func Render

func Render(state BunkersGameState) (string, error)

Render the state into a png file and save it as as media files returns the full url of the file

func RenderAnimation

func RenderAnimation(state BunkersGameState) (string, error)

Types

type BunkersGame

type BunkersGame struct{}

func (*BunkersGame) Example

func (t *BunkersGame) Example() string

Example implements games.Game.

func (BunkersGame) Name

func (BunkersGame) Name() string

Name implements games.Game.

func (*BunkersGame) NewState

func (t *BunkersGame) NewState() interface{}

NewState implements games.Game.

func (*BunkersGame) OnMsg

func (t *BunkersGame) OnMsg(session *models.GameSession, msg games.GameMsg) (interface{}, games.GameReply, error)

func (*BunkersGame) Summary

func (t *BunkersGame) Summary() string

Summary implements games.Game.

type BunkersGameResult

type BunkersGameResult struct {
	Winner int // 0 == None, 1 == PlayerA, 2 == PlayerB
}

type BunkersGameState

type BunkersGameState struct {
	InitTerrain Terrain
	PosA        int
	PosB        int
	PlayerA     string
	PlayerB     string
	WhosTurn    int // 1 = PlayerA, 2 = PlayerB
	Shots       []Shot
	Init        bool
	Wind        int
	Ended       bool
}

func NewBunkersGameState

func NewBunkersGameState(a string, b string) *BunkersGameState

func (*BunkersGameState) Step

func (*BunkersGameState) Terrain

func (s *BunkersGameState) Terrain() Terrain

func (*BunkersGameState) TerrainAtShot

func (s *BunkersGameState) TerrainAtShot(step int) Terrain

get terrain at a given stepp step 0 = before any short step n = after shot n is applied

type BunkersGameStep

type BunkersGameStep struct {
	Player int // 1 == PlayerA, 2 == PlayerB
	Angle  float64
	Vel    float64
}

type Shot

type Shot struct {
	StartX int
	StartY int
	Wind   float64
	Vel    float64
	Angle  float64
}

func (*Shot) DestroyTerrain

func (s *Shot) DestroyTerrain(t Terrain) Terrain

DestroyTerrain returns a new terrain with the effect of the shot

func (*Shot) Draw

func (s *Shot) Draw(state BunkersGameState, canvas *image.Paletted, step int)

type Terrain

type Terrain struct {
	Height []int
}

func NewTerrain

func NewTerrain() Terrain

func (Terrain) At

func (t Terrain) At(x int) int

func (Terrain) Copy

func (t Terrain) Copy() Terrain

func (Terrain) Draw

func (t Terrain) Draw(img *image.Paletted)

func (*Terrain) Set

func (t *Terrain) Set(x int, y int)

Jump to

Keyboard shortcuts

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