boxbrawl/system/map.go

55 lines
1.1 KiB
Go

package system
import (
"image"
"image/color"
"code.rocketnine.space/tslocum/boxbrawl/component"
"code.rocketnine.space/tslocum/boxbrawl/world"
"code.rocketnine.space/tslocum/gohan"
"github.com/hajimehoshi/ebiten/v2"
)
type MapSystem struct {
*component.Once
initialized bool
}
func (s *MapSystem) initialize() {
// TODO
}
func (s *MapSystem) Update(e gohan.Entity) error {
if !s.initialized {
s.initialize()
}
if world.ConnectPromptVisible {
return nil
}
return nil
}
func (s *MapSystem) Draw(e gohan.Entity, screen *ebiten.Image) error {
if world.ConnectPromptVisible {
return nil
}
screen.Fill(color.RGBA{0, 100, 100, 255})
groundColor := color.RGBA{50, 50, 50, 255}
r := image.Rect(-world.ScreenWidth*2, -world.ScreenHeight, world.ScreenWidth*2, 0)
screen.SubImage(world.GameRectToScreen(r)).(*ebiten.Image).Fill(groundColor)
const groundTopHeight = 10
groundTopColor := color.RGBA{100, 100, 100, 255}
r = image.Rect(-world.ScreenWidth*2, -groundTopHeight, world.ScreenWidth*2, 0)
screen.SubImage(world.GameRectToScreen(r)).(*ebiten.Image).Fill(groundTopColor)
return nil
}