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.
pull/84/head
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++;
// 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,
// the JS API should be friendlier and custom...
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
// turn around quickly without moonwalking.

View File

@ -243,6 +243,7 @@ func (d *Doodle) MakeSettingsWindow(supervisor *ui.Supervisor) *ui.Window {
EnableFeatures: &usercfg.Current.EnableFeatures,
CrosshairSize: &usercfg.Current.CrosshairSize,
CrosshairColor: &usercfg.Current.CrosshairColor,
HideTouchHints: &usercfg.Current.HideTouchHints,
}
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{
Side: packAlign,
Fill: true,
PadY: 4,
PadY: 1,
}
tooltipEdge = ui.Left
buttonSize = 32
twoColumn = true // To place in two columns, halves buttonSize to /2
)
if usercfg.Current.HorizontalToolbars {
packAlign = ui.W
@ -58,6 +59,7 @@ func (u *EditorUI) setupPaletteFrame(window *ui.Window) *ui.Frame {
}
tooltipEdge = ui.Top
buttonSize = 24
twoColumn = false
}
// 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.
var row *ui.Frame
if u.Canvas != nil && u.Canvas.Palette != nil {
for _, swatch := range u.Canvas.Palette.Swatches {
swFrame := ui.NewFrame(fmt.Sprintf("Swatch(%s) Button Frame", swatch.Name))
swFrame.Configure(ui.Config{
Width: buttonSize,
Height: buttonSize,
for i, swatch := range u.Canvas.Palette.Swatches {
swatch := swatch
var width = 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,
})
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)
u.Supervisor.Add(btn)
@ -95,7 +118,10 @@ func (u *EditorUI) setupPaletteFrame(window *ui.Window) *ui.Frame {
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/log"
"git.kirsle.net/apps/doodle/pkg/usercfg"
"git.kirsle.net/go/render"
"git.kirsle.net/go/render/event"
"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.
func (s *PlayScene) DrawTouchable() {
if usercfg.Current.HideTouchHints {
return
}
var (
middle = s.touchGetMiddleBox()
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()
// Current time of this loop so we can advance animations.
// now := time.Now()
// Remove any actors that were destroyed the previous tick.
var newActors []*Actor
for _, a := range w.actors {

View File

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

View File

@ -28,6 +28,7 @@ type Settings struct {
EnableFeatures *bool
CrosshairSize *int
CrosshairColor *render.Color
HideTouchHints *bool
// Configuration options.
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,
name: "toolbars",
},
{
Boolean: c.HideTouchHints,
Text: "Hide touchscreen control hints during Play Mode",
PadX: 4,
name: "toolbars",
},
{
Integer: c.CrosshairSize,
Text: "Editor: Crosshair size (0 to disable):",