pong

package
v0.0.0-...-a4dabfa Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InitPaddleWidth  = 20
	InitPaddleHeight = 100
	InitPaddleShift  = 50
)
View Source
const (
	InitBallRadius = 10.0
)

Variables

View Source
var (
	ArcadeFont      font.Face
	SmallArcadeFont font.Face
)
View Source
var (
	BgColor  = color.Black
	ObjColor = color.RGBA{120, 226, 160, 255}
)

Functions

func DrawBigText

func DrawBigText(state GameState, color color.Color, screen *ebiten.Image)

func DrawCaption

func DrawCaption(state GameState, color color.Color, screen *ebiten.Image)

func InitFonts

func InitFonts()

Types

type Ball

type Ball struct {
	Position
	Radius    float32
	XVelocity float32
	YVelocity float32
	Color     color.Color
	Img       *ebiten.Image
}

Ball is a pong ball

func (*Ball) Draw

func (b *Ball) Draw(screen *ebiten.Image)

func (*Ball) Update

func (b *Ball) Update(leftPaddle *Paddle, rightPaddle *Paddle, screen *ebiten.Image)

type GameState

type GameState byte

GameState is an enum that represents all possible game states

const (
	StartState GameState = iota
	ControlsState
	PlayState
	InterState
	PauseState
	GameOverState
)

type Paddle

type Paddle struct {
	Position
	Score  int
	Speed  float32
	Width  int
	Height int
	Color  color.Color
	Up     ebiten.Key
	Down   ebiten.Key
	Img    *ebiten.Image
	// contains filtered or unexported fields
}

Paddle is a pong paddle

func (*Paddle) AiUpdate

func (p *Paddle) AiUpdate(b *Ball)

func (*Paddle) Draw

func (p *Paddle) Draw(screen *ebiten.Image, scoreFont font.Face, ai bool)

func (*Paddle) Update

func (p *Paddle) Update(screen *ebiten.Image)

type Position

type Position struct {
	X, Y float32
}

Position is a set of coordinates in 2-D plan

func GetCenter

func GetCenter(screen *ebiten.Image) Position

GetCenter returns the center position on screen

Jump to

Keyboard shortcuts

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