Optimizations and debug options
This commit is contained in:
42
internal/maps/desert.go
Normal file
42
internal/maps/desert.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package maps
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"github.com/atridad/LilGuy/internal/config"
|
||||
"github.com/atridad/LilGuy/internal/portal"
|
||||
"github.com/atridad/LilGuy/internal/world"
|
||||
)
|
||||
|
||||
func CreateDesert(screenWidth, screenHeight float64) *Map {
|
||||
m := NewMap("desert", 2, "Desert", screenWidth, screenHeight)
|
||||
m.BackgroundColor = color.NRGBA{R: 155, G: 196, B: 215, A: 255}
|
||||
|
||||
// ground surface
|
||||
m.World.AddSurface(&world.Surface{
|
||||
X: 0,
|
||||
Y: screenHeight - config.GroundHeight,
|
||||
Width: screenWidth,
|
||||
Height: config.GroundHeight,
|
||||
Tag: world.TagGround,
|
||||
Color: color.NRGBA{R: 139, G: 69, B: 19, A: 255},
|
||||
})
|
||||
|
||||
// left portal to plains
|
||||
leftPortal := portal.CreateSidePortal("desert_left", portal.SideLeft, screenWidth, screenHeight)
|
||||
leftPortal.DestinationMap = "plains"
|
||||
leftPortal.DestinationPortal = "plains_right"
|
||||
leftPortal.Color = color.NRGBA{R: 100, G: 255, B: 100, A: 180}
|
||||
leftPortal.GlowColor = color.NRGBA{R: 150, G: 255, B: 150, A: 100}
|
||||
m.AddPortal(leftPortal)
|
||||
|
||||
// right portal to plains
|
||||
rightPortal := portal.CreateSidePortal("desert_right", portal.SideRight, screenWidth, screenHeight)
|
||||
rightPortal.DestinationMap = "plains"
|
||||
rightPortal.DestinationPortal = "plains_left"
|
||||
rightPortal.Color = color.NRGBA{R: 255, G: 100, B: 100, A: 180}
|
||||
rightPortal.GlowColor = color.NRGBA{R: 255, G: 150, B: 150, A: 100}
|
||||
m.AddPortal(rightPortal)
|
||||
|
||||
return m
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package maps
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"github.com/atridad/LilGuy/internal/config"
|
||||
"github.com/atridad/LilGuy/internal/portal"
|
||||
"github.com/atridad/LilGuy/internal/world"
|
||||
)
|
||||
@@ -11,6 +10,7 @@ import (
|
||||
type Map struct {
|
||||
ID string
|
||||
Number int
|
||||
DisplayName string
|
||||
Width float64
|
||||
Height float64
|
||||
World *world.World
|
||||
@@ -18,10 +18,11 @@ type Map struct {
|
||||
BackgroundColor color.NRGBA
|
||||
}
|
||||
|
||||
func NewMap(id string, number int, width, height float64) *Map {
|
||||
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(),
|
||||
@@ -44,36 +45,7 @@ func (m *Map) GetPortalByID(id string) *portal.Portal {
|
||||
}
|
||||
|
||||
func CreateDefaultMaps(screenWidth, screenHeight float64) (*Map, *Map) {
|
||||
map1 := createMapFromConfig(config.DefaultMap1(), screenWidth, screenHeight)
|
||||
map2 := createMapFromConfig(config.DefaultMap2(), screenWidth, screenHeight)
|
||||
|
||||
addPortalFromConfig(map1, config.LeftPortalMap1(), portal.SideLeft, screenWidth, screenHeight)
|
||||
addPortalFromConfig(map1, config.RightPortalMap1(), portal.SideRight, screenWidth, screenHeight)
|
||||
addPortalFromConfig(map2, config.LeftPortalMap2(), portal.SideLeft, screenWidth, screenHeight)
|
||||
addPortalFromConfig(map2, config.RightPortalMap2(), portal.SideRight, screenWidth, screenHeight)
|
||||
|
||||
return map1, map2
|
||||
}
|
||||
|
||||
func createMapFromConfig(cfg config.MapConfig, width, height float64) *Map {
|
||||
m := NewMap(cfg.ID, cfg.Number, width, height)
|
||||
m.BackgroundColor = cfg.BackgroundColor
|
||||
m.World.AddSurface(&world.Surface{
|
||||
X: 0,
|
||||
Y: height - config.GroundHeight,
|
||||
Width: width,
|
||||
Height: config.GroundHeight,
|
||||
Tag: world.TagGround,
|
||||
Color: cfg.GroundColor,
|
||||
})
|
||||
return m
|
||||
}
|
||||
|
||||
func addPortalFromConfig(m *Map, cfg config.PortalConfig, side portal.PortalSide, screenWidth, screenHeight float64) {
|
||||
p := portal.CreateSidePortal(cfg.ID, side, screenWidth, screenHeight)
|
||||
p.DestinationMap = cfg.DestinationMap
|
||||
p.DestinationPortal = cfg.DestinationPortal
|
||||
p.Color = cfg.Color
|
||||
p.GlowColor = cfg.GlowColor
|
||||
m.AddPortal(p)
|
||||
plains := CreatePlains(screenWidth, screenHeight)
|
||||
desert := CreateDesert(screenWidth, screenHeight)
|
||||
return plains, desert
|
||||
}
|
||||
|
||||
42
internal/maps/plains.go
Normal file
42
internal/maps/plains.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package maps
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"github.com/atridad/LilGuy/internal/config"
|
||||
"github.com/atridad/LilGuy/internal/portal"
|
||||
"github.com/atridad/LilGuy/internal/world"
|
||||
)
|
||||
|
||||
func CreatePlains(screenWidth, screenHeight float64) *Map {
|
||||
m := NewMap("plains", 1, "Plains", screenWidth, screenHeight)
|
||||
m.BackgroundColor = color.NRGBA{R: 135, G: 206, B: 235, A: 255}
|
||||
|
||||
// ground surface
|
||||
m.World.AddSurface(&world.Surface{
|
||||
X: 0,
|
||||
Y: screenHeight - config.GroundHeight,
|
||||
Width: screenWidth,
|
||||
Height: config.GroundHeight,
|
||||
Tag: world.TagGround,
|
||||
Color: color.NRGBA{R: 34, G: 139, B: 34, A: 255},
|
||||
})
|
||||
|
||||
// left portal to desert
|
||||
leftPortal := portal.CreateSidePortal("plains_left", portal.SideLeft, screenWidth, screenHeight)
|
||||
leftPortal.DestinationMap = "desert"
|
||||
leftPortal.DestinationPortal = "desert_right"
|
||||
leftPortal.Color = color.NRGBA{R: 255, G: 100, B: 100, A: 180}
|
||||
leftPortal.GlowColor = color.NRGBA{R: 255, G: 150, B: 150, A: 100}
|
||||
m.AddPortal(leftPortal)
|
||||
|
||||
// right portal to desert
|
||||
rightPortal := portal.CreateSidePortal("plains_right", portal.SideRight, screenWidth, screenHeight)
|
||||
rightPortal.DestinationMap = "desert"
|
||||
rightPortal.DestinationPortal = "desert_left"
|
||||
rightPortal.Color = color.NRGBA{R: 100, G: 255, B: 100, A: 180}
|
||||
rightPortal.GlowColor = color.NRGBA{R: 150, G: 255, B: 150, A: 100}
|
||||
m.AddPortal(rightPortal)
|
||||
|
||||
return m
|
||||
}
|
||||
Reference in New Issue
Block a user