stg

package module
v0.0.0-...-2a6a35c Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: MIT Imports: 10 Imported by: 0

README

stg-engine

一个golang版的弹幕射击游戏引擎

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPic

func GetPic(s string) *ebiten.Image

func InitPic

func InitPic(s string, img image.Image)

func InitPicReader

func InitPicReader(s string, reader io.Reader) error

Types

type BaseSelf

type BaseSelf struct {
}

func (*BaseSelf) GetPosition

func (s *BaseSelf) GetPosition() utils.Point

func (*BaseSelf) SetPosition

func (s *BaseSelf) SetPosition(point utils.Point)

type Bullet

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

func NewBullet

func NewBullet(id int, point utils.Point, move movement.Movement, duration int) *Bullet

func (*Bullet) CanClean

func (b *Bullet) CanClean() bool

func (*Bullet) CheckCollide

func (b *Bullet) CheckCollide(selfPosition utils.Point, selfRadius float64) bool

func (*Bullet) CheckGraze

func (b *Bullet) CheckGraze(selfPosition utils.Point, selfRadius float64) bool

func (*Bullet) Draw

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

func (*Bullet) GetPosition

func (b *Bullet) GetPosition() utils.Point

func (*Bullet) IsAlive

func (b *Bullet) IsAlive() bool

func (*Bullet) SetPosition

func (b *Bullet) SetPosition(point utils.Point)

func (*Bullet) Update

func (b *Bullet) Update() error

type Enemy

type Enemy struct {
	HP int
	// contains filtered or unexported fields
}

func NewEnemies

func NewEnemies(frame int) []*Enemy

func (*Enemy) CheckCollide

func (r *Enemy) CheckCollide(selfPosition utils.Point, selfRadius float64) bool

func (*Enemy) Draw

func (r *Enemy) Draw(screen *ebiten.Image)

func (*Enemy) GetPosition

func (r *Enemy) GetPosition() utils.Point

func (*Enemy) IsAlive

func (r *Enemy) IsAlive() bool

func (*Enemy) SetPosition

func (r *Enemy) SetPosition(point utils.Point)

func (*Enemy) Update

func (r *Enemy) Update() (bullets []*Bullet, err error)

type Generator

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

type PicCache

type PicCache map[string]*ebiten.Image

func (PicCache) Init

func (cache PicCache) Init(s string, img image.Image)

func (PicCache) InitReader

func (cache PicCache) InitReader(s string, reader io.Reader) error

type Self

type Self interface {
	Radius() float64
	Pic() *ebiten.Image
	Opt() *ebiten.DrawImageOptions
	PicImg() *ebiten.Image
	OptImg() *ebiten.DrawImageOptions
	IsInvincible() bool
	SetInvincibleFrame(frame int)
	ResetPosition()
	SetPosition(point utils.Point)
	GetPosition() utils.Point
	NextTick() (selfBullets []SelfBullet)
	GetLife() int8
	GetBomb() int8
	DecreaseLife() bool
	DecreaseBomb() bool
}

type SelfBullet

type SelfBullet interface {
	// IsAlive 例如超出屏幕应该消失时,为了回收内存,应该返回false。如果在屏幕内不该消失,则返回true
	IsAlive() bool
	// Pic 返回图片
	Pic() *ebiten.Image
	// Opt 返回*ebiten.DrawImageOptions
	Opt() *ebiten.DrawImageOptions
	// NextTick 每一帧时应该做什么
	NextTick(bullets []*Bullet, enemy []*Enemy) ([]*Bullet, []*Enemy)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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