pong

package
v0.0.0-...-c06bead Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2018 License: GPL-3.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyMatrixToWindow

func ApplyMatrixToWindow(win *pixelgl.Window)

func BallPlayerCollision

func BallPlayerCollision(ball *Ball, player *Player)

func GetCamera

func GetCamera() *camera

func GetConfig

func GetConfig() *config

Types

type Ball

type Ball struct {
	X int
	Y int

	PredictedX int
	PredictedY int

	VectorX int
	VectorY int

	Board *Board
}

func NewBall

func NewBall(b *Board) *Ball

func (*Ball) Draw

func (b *Ball) Draw(imd *imdraw.IMDraw)

func (*Ball) GetPosition

func (b *Ball) GetPosition() (int, int)

func (*Ball) Move

func (b *Ball) Move(game *Game)

func (*Ball) SetPosition

func (b *Ball) SetPosition(x, y int)

type Board

type Board struct {
	SizeX int
	SizeY int
}

func NewBoard

func NewBoard() *Board

func (*Board) Draw

func (b *Board) Draw(imd *imdraw.IMDraw)

type Game

type Game struct {
	Score map[int]int

	Players [2]*Player
	Ball    *Ball
}

func NewGame

func NewGame() *Game

func (*Game) AddPoint

func (g *Game) AddPoint(playerId int)

func (*Game) DrawPlayers

func (g *Game) DrawPlayers(imd *imdraw.IMDraw)

func (*Game) DrawScore

func (g *Game) DrawScore(win *pixelgl.Window)

type Player

type Player struct {
	Number int

	X    int
	Y    int
	Size int

	ButtonUp    pixelgl.Button
	ButtonDown  pixelgl.Button
	ButtonLeft  pixelgl.Button
	ButtonRight pixelgl.Button

	Board *Board
}

func NewPlayer

func NewPlayer(playerNumber int, b *Board) *Player

func (*Player) Draw

func (p *Player) Draw(imd *imdraw.IMDraw)

func (*Player) GetPosition

func (p *Player) GetPosition() (int, int)

func (*Player) HandleWindowEvents

func (p *Player) HandleWindowEvents(win *pixelgl.Window)

func (*Player) Move

func (p *Player) Move(offsetX, offsetY int)

func (*Player) SetPosition

func (p *Player) SetPosition(x, y int)

Jump to

Keyboard shortcuts

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