pong

package
v0.0.0-...-77e18a0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomColor

func RandomColor() color.Color

func RandomPlusOrMinusOne

func RandomPlusOrMinusOne() int

func Sign

func Sign(f float32) float32

Types

type Ball

type Ball struct {
	Cx     float32     `json:"cx"`
	Cy     float32     `json:"cy"`
	Radius float32     `json:"radius"`
	Vx     float32     `json:"vx"`
	Vy     float32     `json:"vy"`
	Color  color.Color `json:"color"`
}

func (*Ball) Update

func (b *Ball) Update(leftPaddle *Paddle, rightPaddle *Paddle, screen *Screen)

type Paddle

type Paddle struct {
	X      float32     `json:"x"`
	Y      float32     `json:"y"`
	Speed  float32     `json:"-"`
	Width  int         `json:"width"`
	Height int         `json:"height"`
	Color  color.Color `json:"color"`
	Score  int         `json:"score"`
	Up     input.Key   `json:"-"`
	Down   input.Key   `json:"-"`
	IsAI   bool        `json:"isAI"`
	// contains filtered or unexported fields
}

func (*Paddle) AiUpdate

func (p *Paddle) AiUpdate(screen *Screen, b *Ball)

func (*Paddle) Update

func (p *Paddle) Update(screen *Screen, b *Ball)

type Screen

type Screen struct {
	W float32 `json:"width"`
	H float32 `json:"height"`
}

func (Screen) Size

func (s Screen) Size() (float32, float32)

Jump to

Keyboard shortcuts

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