Got a bunch of examples working

This commit is contained in:
Sasha Koshka 2023-04-15 22:23:08 -04:00
parent e16195d274
commit ed6de3a36f
20 changed files with 166 additions and 234 deletions

View File

@ -48,7 +48,7 @@ type TextBox struct {
// a value. When the value is empty, the placeholder will be displayed in gray
// text.
func NewTextBox (placeholder, value string) (element *TextBox) {
element = &TextBox { }
element = &TextBox { enabled: true }
element.theme.Case = tomo.C("tomo", "textBox")
element.entity = tomo.NewEntity(element).(textBoxEntity)
element.placeholder = placeholder

View File

@ -8,7 +8,6 @@ import _ "image/jpeg"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/data"
import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
@ -27,9 +26,9 @@ func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 256, 0))
window.SetTitle("Clipboard")
container := containers.NewContainer(layouts.Vertical { true, true })
container := containers.NewVBox(true, true)
textInput := elements.NewTextBox("", "")
controlRow := containers.NewContainer(layouts.Horizontal { true, false })
controlRow := containers.NewHBox(false, true)
copyButton := elements.NewButton("Copy")
copyButton.SetIcon(tomo.IconCopy)
pasteButton := elements.NewButton("Paste")
@ -123,7 +122,7 @@ func run () {
func imageWindow (parent tomo.Window, image image.Image) {
window, _ := parent.NewModal(tomo.Bounds(0, 0, 0, 0))
window.SetTitle("Clipboard Image")
container := containers.NewContainer(layouts.Vertical { true, true })
container := containers.NewVBox(true, true)
closeButton := elements.NewButton("Ok")
closeButton.SetIcon(tomo.IconYes)
closeButton.OnClick(window.Close)

View File

@ -1,30 +0,0 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
func main () {
tomo.Run(run)
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
window.SetTitle("dialog")
container := containers.NewContainer(layouts.Dialog { true, true })
window.Adopt(container)
container.Adopt(elements.NewLabel("you will explode", false), true)
cancel := elements.NewButton("Cancel")
cancel.SetEnabled(false)
container.Adopt(cancel, false)
okButton := elements.NewButton("OK")
container.Adopt(okButton, false)
okButton.Focus()
window.OnClose(tomo.Stop)
window.Show()
}

View File

@ -2,7 +2,6 @@ package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/flow"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
@ -14,7 +13,7 @@ func main () {
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 192, 192))
window.SetTitle("adventure")
container := containers.NewContainer(layouts.Vertical { true, true })
container := containers.NewVBox(true, true)
window.Adopt(container)
var world flow.Flow
@ -31,13 +30,11 @@ func run () {
button2 := elements.NewButton("turn around")
button2.OnClick(world.SwitchFunc("bear"))
container.Warp ( func () {
container.Adopt(label, true)
container.Adopt(button0, false)
container.Adopt(button1, false)
container.Adopt(button2, false)
button0.Focus()
})
container.Adopt(label, true)
container.Adopt(button0, false)
container.Adopt(button1, false)
container.Adopt(button2, false)
button0.Focus()
},
"wet": func () {
label := elements.NewLabel (
@ -49,12 +46,10 @@ func run () {
button1 := elements.NewButton("exit")
button1.OnClick(tomo.Stop)
container.Warp (func () {
container.Adopt(label, true)
container.Adopt(button0, false)
container.Adopt(button1, false)
button0.Focus()
})
container.Adopt(label, true)
container.Adopt(button0, false)
container.Adopt(button1, false)
button0.Focus()
},
"house": func () {
label := elements.NewLabel (
@ -66,12 +61,10 @@ func run () {
button0 := elements.NewButton("turn back")
button0.OnClick(world.SwitchFunc("start"))
container.Warp (func () {
container.Adopt(label, true)
container.Adopt(button1, false)
container.Adopt(button0, false)
button1.Focus()
})
container.Adopt(label, true)
container.Adopt(button1, false)
container.Adopt(button0, false)
button1.Focus()
},
"inside": func () {
label := elements.NewLabel (
@ -84,11 +77,9 @@ func run () {
button0 := elements.NewButton("go back outside")
button0.OnClick(world.SwitchFunc("house"))
container.Warp (func () {
container.Adopt(label, true)
container.Adopt(button0, false)
button0.Focus()
})
container.Adopt(label, true)
container.Adopt(button0, false)
button0.Focus()
},
"bear": func () {
label := elements.NewLabel (
@ -100,12 +91,10 @@ func run () {
button1 := elements.NewButton("exit")
button1.OnClick(tomo.Stop)
container.Warp (func () {
container.Adopt(label, true)
container.Adopt(button0, false)
container.Adopt(button1, false)
button0.Focus()
})
container.Adopt(label, true)
container.Adopt(button0, false)
container.Adopt(button1, false)
button0.Focus()
},
}
world.Switch("start")

View File

@ -3,7 +3,6 @@ package main
import "os"
import "time"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import "git.tebibyte.media/sashakoshka/tomo/elements/fun"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
@ -17,7 +16,7 @@ func main () {
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 200, 216))
window.SetTitle("Clock")
container := containers.NewContainer(layouts.Vertical { true, true })
container := containers.NewVBox(true, true)
window.Adopt(container)
clock := fun.NewAnalogClock(time.Now())

View File

@ -1,7 +1,6 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
@ -14,7 +13,7 @@ func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 360, 0))
window.SetTitle("horizontal stack")
container := containers.NewContainer(layouts.Horizontal { true, true })
container := containers.NewHBox(true, true)
window.Adopt(container)
container.Adopt(elements.NewLabel("this is sample text", true), true)

View File

@ -1,7 +1,6 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
@ -14,7 +13,7 @@ func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 360, 0))
window.SetTitle("Icons")
container := containers.NewContainer(layouts.Vertical { true, true })
container := containers.NewVBox(true, true)
window.Adopt(container)
container.Adopt(elements.NewLabel("Just some of the wonderful icons we have:", false), false)
@ -24,9 +23,8 @@ func run () {
container.Adopt(icons(tomo.IconOpen, tomo.IconRemoveFavorite), true)
container.Adopt(icons(tomo.IconCursor, tomo.IconDistort), true)
closeButton := elements.NewButton("Ok")
closeButton := elements.NewButton("Yes verynice")
closeButton.SetIcon(tomo.IconYes)
closeButton.ShowText(false)
closeButton.OnClick(tomo.Stop)
container.Adopt(closeButton, false)
@ -34,8 +32,8 @@ func run () {
window.Show()
}
func icons (min, max tomo.Icon) (container *containers.Container) {
container = containers.NewContainer(layouts.Horizontal { true, false })
func icons (min, max tomo.Icon) (container *containers.Box) {
container = containers.NewHBox(false, true)
for index := min; index <= max; index ++ {
container.Adopt(elements.NewIcon(index, tomo.IconSizeSmall), true)
}

View File

@ -7,7 +7,6 @@ import _ "image/png"
import "github.com/jezek/xgbutil/gopher"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
@ -17,7 +16,7 @@ func main () {
}
func run () {
window, _ := tomo.NewWindow(2, 2)
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
window.SetTitle("Tomo Logo")
file, err := os.Open("assets/banner.png")
@ -26,16 +25,17 @@ func run () {
file.Close()
if err != nil { fatalError(window, err); return }
container := containers.NewContainer(layouts.Vertical { true, true })
container := containers.NewVBox(true, true)
logoImage := elements.NewImage(logo)
button := elements.NewButton("Show me a gopher instead")
button.OnClick (func () { container.Warp (func () {
container.DisownAll()
gopher, _, err :=
image.Decode(bytes.NewReader(gopher.GopherPng()))
if err != nil { fatalError(window, err); return }
container.Adopt(elements.NewImage(gopher),true)
}) })
button.OnClick (func () {
window.SetTitle("Not the Tomo Logo")
container.DisownAll()
gopher, _, err :=
image.Decode(bytes.NewReader(gopher.GopherPng()))
if err != nil { fatalError(window, err); return }
container.Adopt(elements.NewImage(gopher),true)
})
container.Adopt(logoImage, true)
container.Adopt(button, false)

View File

@ -2,7 +2,6 @@ package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
@ -14,7 +13,7 @@ func main () {
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
window.SetTitle("Enter Details")
container := containers.NewContainer(layouts.Vertical { true, true })
container := containers.NewVBox(true, true)
window.Adopt(container)
// create inputs

View File

@ -3,7 +3,6 @@ package main
import "fmt"
import "image"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
@ -16,7 +15,7 @@ func run () {
window, _ := tomo.NewWindow(tomo.Bounds(200, 200, 256, 256))
window.SetTitle("Main")
container := containers.NewContainer(layouts.Vertical { true, true })
container := containers.NewVBox(true, true)
container.Adopt(elements.NewLabel("Main window", false), true)
window.Adopt(container)
@ -33,7 +32,7 @@ func createPanel (parent tomo.MainWindow, id int, bounds image.Rectangle) {
window, _ := parent.NewPanel(bounds)
title := fmt.Sprint("Panel #", id)
window.SetTitle(title)
container := containers.NewContainer(layouts.Vertical { true, true })
container := containers.NewVBox(true, true)
container.Adopt(elements.NewLabel(title, false), true)
window.Adopt(container)
window.Show()

View File

@ -2,7 +2,6 @@ package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
@ -16,7 +15,7 @@ func run () {
if err != nil { panic(err.Error()) }
window.SetTitle("Dialog Boxes")
container := containers.NewContainer(layouts.Vertical { true, true })
container := containers.NewVBox(true, true)
window.Adopt(container)
container.Adopt(elements.NewLabel("Try out different dialogs:", false), true)
@ -67,9 +66,10 @@ func run () {
menuButton := elements.NewButton("menu")
menuButton.OnClick (func () {
// TODO: make a better way to get the bounds of something
menu, err := window.NewMenu (
tomo.Bounds(0, 0, 64, 64).
Add(menuButton.Bounds().Min))
Add(menuButton.Entity().Bounds().Min))
if err != nil { println(err.Error()) }
menu.Adopt(elements.NewLabel("I'm a shy window...", true))
menu.Show()

View File

@ -3,7 +3,6 @@ package main
import "time"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
@ -15,7 +14,7 @@ func main () {
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
window.SetTitle("Approaching")
container := containers.NewContainer(layouts.Vertical { true, true })
container := containers.NewVBox(true, true)
window.Adopt(container)
container.Adopt (elements.NewLabel (

View File

@ -1,9 +1,7 @@
package main
import "time"
import "image"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/canvas"
type Game struct {
*Raycaster
@ -31,21 +29,17 @@ func NewGame (world World, textures Textures) (game *Game) {
return
}
func (game *Game) DrawTo (
canvas canvas.Canvas,
bounds image.Rectangle,
onDamage func (image.Rectangle),
) {
if canvas == nil {
select {
case game.stopChan <- true:
default:
}
} else if !game.running {
game.running = true
go game.run()
}
game.Raycaster.DrawTo(canvas, bounds, onDamage)
func (game *Game) Start () {
if game.running == true { return }
game.running = true
go game.run()
}
func (game *Game) Stop () {
select {
case game.stopChan <- true:
default:
}
}
func (game *Game) Stamina () float64 {
@ -110,7 +104,7 @@ func (game *Game) tick () {
game.stamina = 0
}
tomo.Do(game.Draw)
tomo.Do(game.Invalidate)
if statUpdate && game.onStatUpdate != nil {
tomo.Do(game.onStatUpdate)
}

View File

@ -5,7 +5,6 @@ import _ "embed"
import _ "image/png"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
@ -17,11 +16,13 @@ func main () {
tomo.Run(run)
}
// FIXME this entire example seems to be broken
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 640, 480))
window.SetTitle("Raycaster")
container := containers.NewContainer(layouts.Vertical { false, false })
container := containers.NewVBox(false, false)
window.Adopt(container)
wallTexture, _ := TextureFrom(bytes.NewReader(wallTextureBytes))
@ -48,7 +49,7 @@ func run () {
wallTexture,
})
topBar := containers.NewContainer(layouts.Horizontal { true, true })
topBar := containers.NewHBox(true, true)
staminaBar := elements.NewProgressBar(game.Stamina())
healthBar := elements.NewProgressBar(game.Health())

View File

@ -4,10 +4,11 @@ package main
import "math"
import "image"
import "image/color"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/input"
import "git.tebibyte.media/sashakoshka/tomo/canvas"
import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/artist/shapes"
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
import "git.tebibyte.media/sashakoshka/tomo/default/config"
type ControlState struct {
@ -21,10 +22,8 @@ type ControlState struct {
}
type Raycaster struct {
*core.Core
*core.FocusableCore
core core.CoreControl
focusableControl core.FocusableCoreControl
entity tomo.FocusableEntity
config config.Wrapped
Camera
@ -49,31 +48,105 @@ func NewRaycaster (world World, textures Textures) (element *Raycaster) {
textures: textures,
renderDistance: 8,
}
element.Core, element.core = core.NewCore(element, element.drawAll)
element.FocusableCore,
element.focusableControl = core.NewFocusableCore(element.core, element.Draw)
element.core.SetMinimumSize(64, 64)
element.entity = tomo.NewEntity(element).(tomo.FocusableEntity)
element.entity.SetMinimumSize(64, 64)
return
}
func (element *Raycaster) Entity () tomo.Entity {
return element.entity
}
func (element *Raycaster) Draw (destination canvas.Canvas) {
bounds := element.entity.Bounds()
// artist.FillRectangle(element.core, artist.Uhex(0x000000FF), bounds)
width := bounds.Dx()
height := bounds.Dy()
halfway := bounds.Max.Y - height / 2
ray := Ray { Angle: element.Camera.Angle - element.Camera.Fov / 2 }
for x := 0; x < width; x ++ {
ray.X = element.Camera.X
ray.Y = element.Camera.Y
distance, hitPoint, wall, horizontal := ray.Cast (
element.world, element.renderDistance)
distance *= math.Cos(ray.Angle - element.Camera.Angle)
textureX := math.Mod(hitPoint.X + hitPoint.Y, 1)
if textureX < 0 { textureX += 1 }
wallHeight := height
if distance > 0 {
wallHeight = int((float64(height) / 2.0) / float64(distance))
}
shade := 1.0
if horizontal {
shade *= 0.8
}
shade *= 1 - distance / float64(element.renderDistance)
if shade < 0 { shade = 0 }
ceilingColor := color.RGBA { 0x00, 0x00, 0x00, 0xFF }
floorColor := color.RGBA { 0x39, 0x49, 0x25, 0xFF }
// draw
data, stride := destination.Buffer()
wallStart := halfway - wallHeight
wallEnd := halfway + wallHeight
for y := bounds.Min.Y; y < bounds.Max.Y; y ++ {
switch {
case y < wallStart:
data[y * stride + x + bounds.Min.X] = ceilingColor
case y < wallEnd:
textureY :=
float64(y - halfway) /
float64(wallEnd - wallStart) + 0.5
// fmt.Println(textureY)
wallColor := element.textures.At (wall, Vector {
textureX,
textureY,
})
wallColor = shadeColor(wallColor, shade)
data[y * stride + x + bounds.Min.X] = wallColor
default:
data[y * stride + x + bounds.Min.X] = floorColor
}
}
// increment angle
ray.Angle += element.Camera.Fov / float64(width)
}
// element.drawMinimap()
}
func (element *Raycaster) Invalidate () {
element.entity.Invalidate()
}
func (element *Raycaster) OnControlStateChange (callback func (ControlState)) {
element.onControlStateChange = callback
}
func (element *Raycaster) Draw () {
if element.core.HasImage() {
element.drawAll()
element.core.DamageAll()
}
func (element *Raycaster) Focus () {
element.entity.Focus()
}
func (element *Raycaster) Enabled () bool { return true }
func (element *Raycaster) HandleFocusChange () { }
func (element *Raycaster) HandleMouseDown (x, y int, button input.Button) {
if !element.Focused() { element.Focus() }
element.entity.Focus()
}
func (element *Raycaster) HandleMouseUp (x, y int, button input.Button) { }
func (element *Raycaster) HandleMouseMove (x, y int) { }
func (element *Raycaster) HandleMouseScroll (x, y int, deltaX, deltaY float64) { }
func (element *Raycaster) HandleKeyDown (key input.Key, modifiers input.Modifiers) {
switch key {
@ -109,75 +182,6 @@ func (element *Raycaster) HandleKeyUp(key input.Key, modifiers input.Modifiers)
}
}
func (element *Raycaster) drawAll () {
bounds := element.Bounds()
// artist.FillRectangle(element.core, artist.Uhex(0x000000FF), bounds)
width := bounds.Dx()
height := bounds.Dy()
halfway := bounds.Max.Y - height / 2
ray := Ray { Angle: element.Camera.Angle - element.Camera.Fov / 2 }
for x := 0; x < width; x ++ {
ray.X = element.Camera.X
ray.Y = element.Camera.Y
distance, hitPoint, wall, horizontal := ray.Cast (
element.world, element.renderDistance)
distance *= math.Cos(ray.Angle - element.Camera.Angle)
textureX := math.Mod(hitPoint.X + hitPoint.Y, 1)
if textureX < 0 { textureX += 1 }
wallHeight := height
if distance > 0 {
wallHeight = int((float64(height) / 2.0) / float64(distance))
}
shade := 1.0
if horizontal {
shade *= 0.8
}
shade *= 1 - distance / float64(element.renderDistance)
if shade < 0 { shade = 0 }
ceilingColor := color.RGBA { 0x00, 0x00, 0x00, 0xFF }
floorColor := color.RGBA { 0x39, 0x49, 0x25, 0xFF }
// draw
data, stride := element.core.Buffer()
wallStart := halfway - wallHeight
wallEnd := halfway + wallHeight
for y := bounds.Min.Y; y < bounds.Max.Y; y ++ {
switch {
case y < wallStart:
data[y * stride + x + bounds.Min.X] = ceilingColor
case y < wallEnd:
textureY :=
float64(y - halfway) /
float64(wallEnd - wallStart) + 0.5
// fmt.Println(textureY)
wallColor := element.textures.At (wall, Vector {
textureX,
textureY,
})
wallColor = shadeColor(wallColor, shade)
data[y * stride + x + bounds.Min.X] = wallColor
default:
data[y * stride + x + bounds.Min.X] = floorColor
}
}
// increment angle
ray.Angle += element.Camera.Fov / float64(width)
}
// element.drawMinimap()
}
func shadeColor (c color.RGBA, brightness float64) color.RGBA {
return color.RGBA {
uint8(float64(c.R) * brightness),
@ -187,8 +191,8 @@ func shadeColor (c color.RGBA, brightness float64) color.RGBA {
}
}
func (element *Raycaster) drawMinimap () {
bounds := element.Bounds()
func (element *Raycaster) drawMinimap (destination canvas.Canvas) {
bounds := element.entity.Bounds()
scale := 8
for y := 0; y < len(element.world.Data) / element.world.Stride; y ++ {
for x := 0; x < element.world.Stride; x ++ {
@ -204,7 +208,7 @@ func (element *Raycaster) drawMinimap () {
cellColor = color.RGBA { 0xFF, 0xFF, 0xFF, 0xFF }
}
shapes.FillColorRectangle (
element.core,
destination,
cellColor,
cellBounds.Inset(1))
}}
@ -219,16 +223,16 @@ func (element *Raycaster) drawMinimap () {
playerBounds := image.Rectangle { playerPt, playerPt }.Inset(scale / -8)
shapes.FillColorEllipse (
element.core,
destination,
artist.Hex(0xFFFFFFFF),
playerBounds)
shapes.ColorLine (
element.core,
destination,
artist.Hex(0xFFFFFFFF), 1,
playerPt,
playerAnglePt)
shapes.ColorLine (
element.core,
destination,
artist.Hex(0x00FF00FF), 1,
playerPt,
hitPt)

View File

@ -1,7 +1,6 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
@ -14,7 +13,7 @@ func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
window.SetTitle("Spaced Out")
container := containers.NewContainer(layouts.Vertical { true, true })
container := containers.NewVBox(true, true)
window.Adopt(container)
container.Adopt (elements.NewLabel("This is at the top", false), false)

View File

@ -1,7 +1,6 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
@ -14,7 +13,7 @@ func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
window.SetTitle("Switches")
container := containers.NewContainer(layouts.Vertical { true, true })
container := containers.NewVBox(true, true)
window.Adopt(container)
container.Adopt(elements.NewSwitch("hahahah", false), false)

View File

@ -1,17 +0,0 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/elements/testing"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
func main () {
tomo.Run(run)
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 128, 128))
window.SetTitle("hellorld!")
window.Adopt(testing.NewMouse())
window.OnClose(tomo.Stop)
window.Show()
}

View File

@ -60,6 +60,10 @@ func NewDialog (
messageRow.Adopt(elements.NewLabel(message, false), true)
controlRow.Adopt(elements.NewSpacer(false), true)
box.Adopt(messageRow, true)
box.Adopt(controlRow, false)
window.Adopt(box)
if len(buttons) == 0 {
button := elements.NewButton("OK")
button.SetIcon(tomo.IconYes)
@ -80,9 +84,6 @@ func NewDialog (
button.Focus()
}
box.Adopt(messageRow, true)
box.Adopt(controlRow, false)
window.Adopt(box)
window.Show()
return
}