Condensed Palette, Bird AI Update

* The Red Bird now records its original altitude on the level and will
  try and return there should it accidentally climb up or down a wall.
  Sometimes goes into a wavy pattern surrounding its original altitude.
* Editor UI: in the default (vertical) toolbar, the Palette now has a
  two column view to show more color choices on screen at once.
* User setting added: hide the touch control hints.
This commit is contained in:
Noah 2021-10-12 20:49:48 -07:00
parent 3a9cc83e78
commit ddf0074099
7 changed files with 56 additions and 12 deletions

View File

@ -47,10 +47,17 @@ function main() {
} }
sampleTick++; sampleTick++;
// If we are not flying at our original altitude, correct for that.
var curV = Self.Position();
var Vy = 0.0;
if (curV.Y != altitude) {
Vy = curV.Y < altitude ? 1 : -1;
}
// TODO: Vector() requires floats, pain in the butt for JS, // TODO: Vector() requires floats, pain in the butt for JS,
// the JS API should be friendlier and custom... // the JS API should be friendlier and custom...
var Vx = parseFloat(speed * (direction === "left" ? -1 : 1)); var Vx = parseFloat(speed * (direction === "left" ? -1 : 1));
Self.SetVelocity(Vector(Vx, 0.0)); Self.SetVelocity(Vector(Vx, Vy));
// If we changed directions, stop animating now so we can // If we changed directions, stop animating now so we can
// turn around quickly without moonwalking. // turn around quickly without moonwalking.

View File

@ -243,6 +243,7 @@ func (d *Doodle) MakeSettingsWindow(supervisor *ui.Supervisor) *ui.Window {
EnableFeatures: &usercfg.Current.EnableFeatures, EnableFeatures: &usercfg.Current.EnableFeatures,
CrosshairSize: &usercfg.Current.CrosshairSize, CrosshairSize: &usercfg.Current.CrosshairSize,
CrosshairColor: &usercfg.Current.CrosshairColor, CrosshairColor: &usercfg.Current.CrosshairColor,
HideTouchHints: &usercfg.Current.HideTouchHints,
} }
return windows.MakeSettingsWindow(d.width, d.height, cfg) return windows.MakeSettingsWindow(d.width, d.height, cfg)
} }

View File

@ -44,10 +44,11 @@ func (u *EditorUI) setupPaletteFrame(window *ui.Window) *ui.Frame {
packConfig = ui.Pack{ packConfig = ui.Pack{
Side: packAlign, Side: packAlign,
Fill: true, Fill: true,
PadY: 4, PadY: 1,
} }
tooltipEdge = ui.Left tooltipEdge = ui.Left
buttonSize = 32 buttonSize = 32
twoColumn = true // To place in two columns, halves buttonSize to /2
) )
if usercfg.Current.HorizontalToolbars { if usercfg.Current.HorizontalToolbars {
packAlign = ui.W packAlign = ui.W
@ -58,6 +59,7 @@ func (u *EditorUI) setupPaletteFrame(window *ui.Window) *ui.Frame {
} }
tooltipEdge = ui.Top tooltipEdge = ui.Top
buttonSize = 24 buttonSize = 24
twoColumn = false
} }
// Handler function for the radio buttons being clicked. // Handler function for the radio buttons being clicked.
@ -74,16 +76,37 @@ func (u *EditorUI) setupPaletteFrame(window *ui.Window) *ui.Frame {
} }
// Draw the radio buttons for the palette. // Draw the radio buttons for the palette.
var row *ui.Frame
if u.Canvas != nil && u.Canvas.Palette != nil { if u.Canvas != nil && u.Canvas.Palette != nil {
for _, swatch := range u.Canvas.Palette.Swatches { for i, swatch := range u.Canvas.Palette.Swatches {
swFrame := ui.NewFrame(fmt.Sprintf("Swatch(%s) Button Frame", swatch.Name)) swatch := swatch
swFrame.Configure(ui.Config{ var width = buttonSize
Width: buttonSize,
Height: buttonSize, // Drawing buttons in two-column mode? (default right-side palette layout)
if twoColumn {
width = buttonSize / 2
if row == nil || i%2 == 0 {
row = ui.NewFrame(fmt.Sprintf("Swatch(%s) Button Frame", swatch.Name))
frame.Pack(row, packConfig)
}
} else {
row = ui.NewFrame(fmt.Sprintf("Swatch(%s) Button Frame", swatch.Name))
frame.Pack(row, packConfig)
}
colorbox := ui.NewFrame(swatch.Name)
colorbox.Configure(ui.Config{
Width: width,
Height: width,
Background: swatch.Color, Background: swatch.Color,
}) })
btn := ui.NewRadioButton("palette", &u.selectedSwatch, swatch.Name, swFrame) btn := ui.NewRadioButton("palette", &u.selectedSwatch, swatch.Name, colorbox)
btn.Configure(ui.Config{
BorderColor: swatch.Color.Darken(20),
BorderSize: 2,
OutlineSize: 0,
})
btn.Handle(ui.Click, onClick) btn.Handle(ui.Click, onClick)
u.Supervisor.Add(btn) u.Supervisor.Add(btn)
@ -95,7 +118,10 @@ func (u *EditorUI) setupPaletteFrame(window *ui.Window) *ui.Frame {
btn.Compute(u.d.Engine) btn.Compute(u.d.Engine)
frame.Pack(btn, packConfig) row.Pack(btn, ui.Pack{
Side: ui.W,
PadX: 1,
})
} }
} }

View File

@ -5,6 +5,7 @@ import (
"git.kirsle.net/apps/doodle/pkg/balance" "git.kirsle.net/apps/doodle/pkg/balance"
"git.kirsle.net/apps/doodle/pkg/log" "git.kirsle.net/apps/doodle/pkg/log"
"git.kirsle.net/apps/doodle/pkg/usercfg"
"git.kirsle.net/go/render" "git.kirsle.net/go/render"
"git.kirsle.net/go/render/event" "git.kirsle.net/go/render/event"
"git.kirsle.net/go/ui" "git.kirsle.net/go/ui"
@ -111,6 +112,10 @@ func (s *PlayScene) LoopTouchable(ev *event.State) {
// DrawTouchable draws any UI elements if needed for the touch UI. // DrawTouchable draws any UI elements if needed for the touch UI.
func (s *PlayScene) DrawTouchable() { func (s *PlayScene) DrawTouchable() {
if usercfg.Current.HideTouchHints {
return
}
var ( var (
middle = s.touchGetMiddleBox() middle = s.touchGetMiddleBox()
background = render.RGBA(200, 200, 200, uint8(s.idleHelpAlpha)) background = render.RGBA(200, 200, 200, uint8(s.idleHelpAlpha))

View File

@ -222,9 +222,6 @@ func (w *Canvas) Loop(ev *event.State) error {
} }
_ = w.loopConstrainScroll() _ = w.loopConstrainScroll()
// Current time of this loop so we can advance animations.
// now := time.Now()
// Remove any actors that were destroyed the previous tick. // Remove any actors that were destroyed the previous tick.
var newActors []*Actor var newActors []*Actor
for _, a := range w.actors { for _, a := range w.actors {

View File

@ -33,6 +33,7 @@ type Settings struct {
EnableFeatures bool `json:",omitempty"` EnableFeatures bool `json:",omitempty"`
CrosshairSize int `json:",omitempty"` CrosshairSize int `json:",omitempty"`
CrosshairColor render.Color CrosshairColor render.Color
HideTouchHints bool `json:"omitempty"`
// Secret boolprops from balance/boolprops.go // Secret boolprops from balance/boolprops.go
ShowHiddenDoodads bool `json:",omitempty"` ShowHiddenDoodads bool `json:",omitempty"`

View File

@ -28,6 +28,7 @@ type Settings struct {
EnableFeatures *bool EnableFeatures *bool
CrosshairSize *int CrosshairSize *int
CrosshairColor *render.Color CrosshairColor *render.Color
HideTouchHints *bool
// Configuration options. // Configuration options.
SceneName string // name of scene which called this window SceneName string // name of scene which called this window
@ -135,6 +136,12 @@ func (c Settings) makeOptionsTab(tabFrame *ui.TabFrame, Width, Height int) *ui.F
PadX: 4, PadX: 4,
name: "toolbars", name: "toolbars",
}, },
{
Boolean: c.HideTouchHints,
Text: "Hide touchscreen control hints during Play Mode",
PadX: 4,
name: "toolbars",
},
{ {
Integer: c.CrosshairSize, Integer: c.CrosshairSize,
Text: "Editor: Crosshair size (0 to disable):", Text: "Editor: Crosshair size (0 to disable):",