Files
LilGuy/internal/maps/map.go

52 lines
1.1 KiB
Go

package maps
import (
"image/color"
"github.com/atridad/LilGuy/internal/portal"
"github.com/atridad/LilGuy/internal/world"
)
type Map struct {
ID string
Number int
DisplayName string
Width float64
Height float64
World *world.World
Portals []*portal.Portal
BackgroundColor color.NRGBA
}
func NewMap(id string, number int, displayName string, width, height float64) *Map {
return &Map{
ID: id,
Number: number,
DisplayName: displayName,
Width: width,
Height: height,
World: world.NewWorld(),
Portals: make([]*portal.Portal, 0),
BackgroundColor: color.NRGBA{R: 135, G: 206, B: 235, A: 255},
}
}
func (m *Map) AddPortal(p *portal.Portal) {
m.Portals = append(m.Portals, p)
}
func (m *Map) GetPortalByID(id string) *portal.Portal {
for _, p := range m.Portals {
if p.ID == id {
return p
}
}
return nil
}
func CreateDefaultMaps(screenWidth, screenHeight float64) (*Map, *Map) {
plains := CreatePlains(screenWidth, screenHeight)
desert := CreateDesert(screenWidth, screenHeight)
return plains, desert
}