Some small visual fixes.

- Smaller font for menus/steps.
- Changed level a bit.
- Updated lava brick texture.
This commit is contained in:
Sander Schobers 2019-12-27 23:16:49 +01:00
parent cc59236689
commit cc58dbd06f
4 changed files with 19 additions and 17 deletions

View File

@ -67,7 +67,7 @@ func (g *game) loadFonts() error {
if err != nil { if err != nil {
return err return err
} }
err = g.ui.Fonts().LoadFonts(alui.FontDescription{Path: openSansPath, Name: "default", Size: 36}) err = g.ui.Fonts().LoadFonts(alui.FontDescription{Path: openSansPath, Name: "default", Size: 32})
if err != nil { if err != nil {
return err return err
} }

View File

@ -88,15 +88,18 @@ func (l *playLevel) Enter(ctx *Context) error {
func (l *playLevel) Leave() {} func (l *playLevel) Leave() {}
func (l *playLevel) posToScreen(p geom.Point) geom.PointF32 { func (l *playLevel) posToScreen(p geom.Point) geom.PointF32 {
return l.posToScreenF32(p.ToF32()) return l.posToScreenF32(p.ToF32(), 0)
} }
func (l *playLevel) posToScreenF32(p geom.PointF32) geom.PointF32 { func (l *playLevel) posToScreenF32(p geom.PointF32, z float32) geom.PointF32 {
pos := p.Add2D(.5, .5) pos := l.posToCabinet(p.Add2D(.5, .5)).Add2D(0, z)
pos = geom.PtF32(pos.X*100-pos.Y*50, pos.Y*40)
return pos.Mul(l.scale).Add(l.offset) return pos.Mul(l.scale).Add(l.offset)
} }
func (l *playLevel) posToCabinet(p geom.PointF32) geom.PointF32 {
return geom.PtF32(p.X*100-p.Y*50, p.Y*40)
}
// <- 150-> // <- 150->
// <-100-> // <-100->
// //
@ -113,11 +116,10 @@ func (l *playLevel) posToScreenF32(p geom.PointF32) geom.PointF32 {
func (l *playLevel) Layout(ctx *alui.Context, bounds geom.RectangleF32) { func (l *playLevel) Layout(ctx *alui.Context, bounds geom.RectangleF32) {
l.scale = bounds.Dy() / 1080 l.scale = bounds.Dy() / 1080
l.offset = geom.PointF32{}
level := l.state.Level() level := l.state.Level()
tilesCenter := geom.PtF32(.5*float32(level.width), .5*float32(level.height)) tilesCenter := l.posToScreenF32(geom.PtF32(.5*float32(level.width), .5*float32(level.height)), 0)
tilesCenter = geom.PtF32(tilesCenter.X*100-tilesCenter.Y*25, tilesCenter.Y*40)
tilesCenter = geom.PtF32(tilesCenter.X*l.scale, tilesCenter.Y*l.scale)
center := bounds.Center() center := bounds.Center()
l.offset = geom.PtF32(center.X-tilesCenter.X, center.Y-tilesCenter.Y) l.offset = geom.PtF32(center.X-tilesCenter.X, center.Y-tilesCenter.Y)
@ -163,10 +165,10 @@ func (l *playLevel) Handle(e allg5.Event) {
} }
func (l *playLevel) drawSpritePart(name, partName string, pos geom.PointF32) { func (l *playLevel) drawSpritePart(name, partName string, pos geom.PointF32) {
l.drawSpritePartOffset(name, partName, pos, geom.PointF32{}) l.drawSpritePartOffset(name, partName, pos, 0)
} }
func (l *playLevel) drawSpritePartOffset(name, partName string, pos, offset geom.PointF32) { func (l *playLevel) drawSpritePartOffset(name, partName string, pos geom.PointF32, z float32) {
sprite, ok := l.ctx.Sprites[name] sprite, ok := l.ctx.Sprites[name]
if !ok { if !ok {
return return
@ -185,7 +187,7 @@ func (l *playLevel) drawSpritePartOffset(name, partName string, pos, offset geom
scale *= 1. / part.scale scale *= 1. / part.scale
} }
anchor := part.sub.Min.Sub(part.anchor).ToF32().Mul(scale) anchor := part.sub.Min.Sub(part.anchor).ToF32().Mul(scale)
scrPos := l.posToScreenF32(pos).Add(anchor).Add(offset.Mul(100 * l.scale)) scrPos := l.posToScreenF32(pos, z).Add(anchor)
left, top := scrPos.X, scrPos.Y left, top := scrPos.X, scrPos.Y
partText.DrawOptions(left, top, allg5.DrawOptions{Scale: allg5.NewUniformScale(scale)}) partText.DrawOptions(left, top, allg5.DrawOptions{Scale: allg5.NewUniformScale(scale)})
} }
@ -204,7 +206,7 @@ func (l *playLevel) Render(ctx *alui.Context, bounds geom.RectangleF32) {
case tileMagma: case tileMagma:
l.drawSpritePart("magma", "magma", pos.ToF32()) l.drawSpritePart("magma", "magma", pos.ToF32())
if l.state.IsFilledUp(pos) { if l.state.IsFilledUp(pos) {
l.drawSpritePartOffset("brick", "brick", pos.ToF32(), geom.PtF32(0, .8)) l.drawSpritePartOffset("brick", "brick", pos.ToF32(), .8)
l.drawSpritePart("magma", "sunken_overlay", pos.ToF32()) l.drawSpritePart("magma", "sunken_overlay", pos.ToF32())
} }
} }

View File

@ -1,11 +1,11 @@
level: level:
._._._._._._._._._._ ._._._._._._._._._._
._#_#_#_#_._._._._._ ._#_#_#_#_~_~_~_#_._
._#_#_._#B._._._._._ ._#_#_._#B~_~_#_#_._
._#_#_#_#_._._._._._ ._#_#_#_#_~_~_~_#_._
._#_#_._#B._._._._._ ._#_#_._#B~_~_#_#_._
._#@#_#_#_~_~_#_#X._ ._#@#_#_#_~_~_#_#X._
._#_#_~_~_~_#_#_#_._ ._#_#_~_~_~_#_#_#_._
._#_#_~_#_#_#_#_#_._ ._#_#_~_~_~_#_#_#_._
._._._._._._._._._._ ._._._._._._._._._._
:level :level

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 KiB

After

Width:  |  Height:  |  Size: 319 KiB