carotidartillery/tile.go

35 lines
813 B
Go
Raw Normal View History

2021-10-05 03:47:29 +00:00
package main
import (
"github.com/hajimehoshi/ebiten/v2"
)
// Tile represents a space with an x,y coordinate within a Level. Any number of
// sprites may be added to a Tile.
type Tile struct {
2021-10-27 02:21:26 +00:00
sprites []*ebiten.Image
floor bool
wall bool
colorScale float64 // Minimum color scale (brightness)
2021-10-05 03:47:29 +00:00
}
// AddSprite adds a sprite to the Tile.
func (t *Tile) AddSprite(s *ebiten.Image) {
t.sprites = append(t.sprites, s)
}
// ClearSprites removes all sprites from the Tile.
func (t *Tile) ClearSprites() {
for i := range t.sprites {
t.sprites[i] = nil
}
t.sprites = t.sprites[:0]
}
// Draw draws the Tile on the screen using the provided options.
func (t *Tile) Draw(screen *ebiten.Image, options *ebiten.DrawImageOptions) {
for _, s := range t.sprites {
screen.DrawImage(s, options)
}
}