boxbrawl/system/map.go

56 lines
1.1 KiB
Go
Raw Normal View History

2023-01-13 23:31:17 +00:00
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
}
2023-01-24 06:29:04 +00:00
screen.Fill(color.RGBA{0, 100, 100, 255})
2023-02-01 00:45:20 +00:00
const groundBorderSize = 3
groundBorderColor := color.RGBA{30, 30, 30, 255}
groundColor := color.RGBA{20, 20, 20, 255}
2023-01-27 06:30:53 +00:00
for _, r := range world.PhysicsRects {
2023-02-01 00:45:20 +00:00
groundRect := world.GameRectToScreen(r)
screen.SubImage(groundRect).(*ebiten.Image).Fill(groundBorderColor)
2023-01-27 06:30:53 +00:00
2023-02-01 00:45:20 +00:00
inset := groundRect.Inset(groundBorderSize)
inset.Max.Y += groundBorderSize
screen.SubImage(inset).(*ebiten.Image).Fill(groundColor)
}
2023-01-19 00:41:13 +00:00
2023-01-13 23:31:17 +00:00
return nil
}