You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.1 KiB
56 lines
1.1 KiB
package system
|
|
|
|
import (
|
|
"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})
|
|
|
|
const groundBorderSize = 3
|
|
groundBorderColor := color.RGBA{30, 30, 30, 255}
|
|
groundColor := color.RGBA{20, 20, 20, 255}
|
|
|
|
for _, r := range world.PhysicsRects {
|
|
groundRect := world.GameRectToScreen(r)
|
|
screen.SubImage(groundRect).(*ebiten.Image).Fill(groundBorderColor)
|
|
|
|
inset := groundRect.Inset(groundBorderSize)
|
|
inset.Max.Y += groundBorderSize
|
|
screen.SubImage(inset).(*ebiten.Image).Fill(groundColor)
|
|
}
|
|
|
|
return nil
|
|
}
|