2024-12-10 18:55:23 -05:00
|
|
|
package elements
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"client/gamedata"
|
|
|
|
|
"image/color"
|
|
|
|
|
|
|
|
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Block struct {
|
|
|
|
|
Sprite *ebiten.Image
|
|
|
|
|
cycle int
|
|
|
|
|
position gamedata.Coordinates
|
2024-12-11 12:55:07 -05:00
|
|
|
hit bool
|
2024-12-10 18:55:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewBlock() *Block {
|
|
|
|
|
return &Block{
|
|
|
|
|
Sprite: ebiten.NewImage(20, 20),
|
|
|
|
|
cycle: 0,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *Block) Update() {
|
|
|
|
|
b.cycle++
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *Block) Draw() {
|
|
|
|
|
b.Sprite.Clear()
|
2024-12-11 12:55:07 -05:00
|
|
|
if !b.hit {
|
|
|
|
|
b.Sprite.Fill(color.RGBA{R: 0xff, G: 0x00, B: 0x00, A: 0x00})
|
|
|
|
|
} else {
|
|
|
|
|
b.Sprite.Fill(color.RGBA{R: 0x00, G: 0xff, B: 0x00, A: 0xff})
|
|
|
|
|
}
|
2024-12-10 18:55:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *Block) SetPosition(pos gamedata.Coordinates) {
|
|
|
|
|
b.position = pos
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *Block) GetPosition() gamedata.Coordinates {
|
|
|
|
|
return b.position
|
|
|
|
|
}
|
2024-12-11 12:55:07 -05:00
|
|
|
|
|
|
|
|
func (b *Block) SetHit(hit bool) {
|
|
|
|
|
b.hit = hit
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *Block) GetHit() bool {
|
|
|
|
|
return b.hit
|
|
|
|
|
}
|