tank

package
v0.0.0-...-934685d Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScreenWidth  = 13 * tankSizeInPix
	ScreenHeight = 13 * tankSizeInPix
)
View Source
const (
	BulletBorderInPix = 15
)

Variables

This section is empty.

Functions

func Abs

func Abs(x int) int

func LowerBound

func LowerBound(x, divisor int) int

func Max

func Max(x, y int) int

func Min

func Min(x, y int) int

func UpperBound

func UpperBound(x, divisor int) int

Types

type Animation

type Animation struct {
	// contains filtered or unexported fields
}

func GetBulletAnimation

func GetBulletAnimation() *Animation

func GetP1TankAnimation

func GetP1TankAnimation(level int, equip tankEquipCondition, status tankStatus) *Animation

func GetP2TankAnimation

func GetP2TankAnimation(level int, equip tankEquipCondition, status tankStatus) *Animation

func NewAnimation

func NewAnimation(interval int) *Animation

func (*Animation) GetImage

func (a *Animation) GetImage() *ebiten.Image

func (*Animation) Pause

func (a *Animation) Pause()

func (*Animation) Resume

func (a *Animation) Resume()

func (*Animation) Update

func (a *Animation) Update(count int)

type Bullet

type Bullet struct {
	GameObject
	// contains filtered or unexported fields
}

func NewBullet

func NewBullet(x, y, level int, dir Direction, owner *Tank) *Bullet

func (*Bullet) Update

func (b *Bullet) Update(count int)

type ControlPanel

type ControlPanel struct {
	// contains filtered or unexported fields
}

func (*ControlPanel) Drive

func (cp *ControlPanel) Drive(dir Direction)

func (*ControlPanel) Hold

func (cp *ControlPanel) Hold()

func (*ControlPanel) PressFire

func (cp *ControlPanel) PressFire()

func (*ControlPanel) UnPressFire

func (cp *ControlPanel) UnPressFire()

type Direction

type Direction int

func (Direction) Vector

func (d Direction) Vector() (x, y int)

type Element

type Element interface {
	Update(count int)
	Draw(screen *ebiten.Image)
	GetType() ObjType
	GetPosition() Position
	GetSpeed() int
	GetCollisionSize() int
	GetDir() Direction
	Destroy()
}

type Game

type Game struct {
	// contains filtered or unexported fields
}

func NewGame

func NewGame() (*Game, error)

func (*Game) Draw

func (g *Game) Draw(screen *ebiten.Image)

func (*Game) Layout

func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int)

func (*Game) Update

func (g *Game) Update() error

type GameObject

type GameObject struct {
	Position
	Dir     Direction
	NextDir Direction

	Speed int

	Moving    bool
	ID        int
	ObjType   ObjType
	Ground    *Ground
	Destroyed bool
	// contains filtered or unexported fields
}

func (*GameObject) Destroy

func (g *GameObject) Destroy()

func (*GameObject) Draw

func (g *GameObject) Draw(screen *ebiten.Image)

func (*GameObject) GetCollisionSize

func (g *GameObject) GetCollisionSize() int

func (*GameObject) GetDir

func (g *GameObject) GetDir() Direction

func (*GameObject) GetPosition

func (g *GameObject) GetPosition() Position

func (*GameObject) GetSpeed

func (g *GameObject) GetSpeed() int

func (*GameObject) GetType

func (g *GameObject) GetType() ObjType

func (*GameObject) Stop

func (g *GameObject) Stop()

func (*GameObject) Update

func (g *GameObject) Update(count int)

type Ground

type Ground struct {
	P1 *Tank
	P2 *Tank
	// contains filtered or unexported fields
}

func NewGround

func NewGround() *Ground

func (*Ground) CollisionDetect

func (g *Ground) CollisionDetect(elm Element) int

func (*Ground) Draw

func (g *Ground) Draw(screen *ebiten.Image)

func (*Ground) NewBullet

func (g *Ground) NewBullet(x, y, level int, dir Direction, owner *Tank)

func (*Ground) NewP1Tank

func (g *Ground) NewP1Tank()

func (*Ground) NewP2Tank

func (g *Ground) NewP2Tank()

func (*Ground) Update

func (g *Ground) Update(count int)

type Input

type Input struct {
	// contains filtered or unexported fields
}

func NewInput

func NewInput() *Input

func (*Input) Register

func (i *Input) Register(key ebiten.Key, press func(), release func())

func (*Input) Update

func (i *Input) Update()

type ObjType

type ObjType int
const (
	P1TankType ObjType = iota
	P2TankType
	EnemyType
	BulletType
)

type Position

type Position struct {
	X, Y int
}

type Tank

type Tank struct {
	GameObject
	// contains filtered or unexported fields
}

func NewP1Tank

func NewP1Tank(x, y int) *Tank

func (*Tank) NotifyHit

func (t *Tank) NotifyHit()

func (*Tank) SetStatus

func (t *Tank) SetStatus(status tankStatus)

func (*Tank) Update

func (t *Tank) Update(count int)

type TimerManager

type TimerManager struct {
	// contains filtered or unexported fields
}
var (
	Timer *TimerManager
)

func NewTimer

func NewTimer() *TimerManager

func (*TimerManager) AddEvent

func (t *TimerManager) AddEvent(countDown int, fn func())

func (*TimerManager) Update

func (t *TimerManager) Update()

Jump to

Keyboard shortcuts

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