Files
survive/elements/laser.go

61 lines
927 B
Go

package elements
import (
"image/color"
"mover/gamedata"
"github.com/hajimehoshi/ebiten/v2"
)
type Laser struct {
Sprite *ebiten.Image
position gamedata.Coordinates
angle float64
cycle int
firing bool
}
func NewLaser(pos gamedata.Coordinates, angle float64) *Laser {
l := &Laser{
Sprite: ebiten.NewImage(200, 20),
angle: angle,
cycle: 0,
position: pos,
firing: false,
}
return l
}
func (l *Laser) Update() error {
l.cycle++
return nil
}
func (l *Laser) Draw() {
l.Sprite.Clear()
l.Sprite.Fill(color.White)
}
func (l *Laser) GetPosition() gamedata.Coordinates {
return l.position
}
func (l *Laser) SetPosition(pos gamedata.Coordinates) {
l.position = pos
}
func (l *Laser) GetAngle() float64 {
return l.angle
}
func (l *Laser) SetAngle(a float64) {
l.angle = a
}
func (l *Laser) SetFiring(b bool) {
l.firing = b
}
func (l *Laser) IsFiring() bool {
return l.firing
}