Remove ScreenshotKey Event, Add F* Key Handlers
* The F3 key now toggles the Debug Overlay, which is now OFF by default. * The F4 key now toggles the Debug Collision Boxes feature.
This commit is contained in:
parent
2a162a86dd
commit
52a2545692
25
README.md
25
README.md
|
@ -40,8 +40,14 @@ Escape
|
|||
Exit the program otherwise.
|
||||
|
||||
Enter
|
||||
Open and close the developer console, and run commands while the console
|
||||
is open.
|
||||
Open and close the developer console, and run commands while the
|
||||
console is open.
|
||||
|
||||
F3
|
||||
Toggle the Debug Overlay.
|
||||
|
||||
F4
|
||||
Toggle debug collision hitboxes.
|
||||
```
|
||||
|
||||
In Play Mode:
|
||||
|
@ -51,13 +57,6 @@ Cursor Keys
|
|||
Move the player around.
|
||||
```
|
||||
|
||||
In Edit Mode:
|
||||
|
||||
```
|
||||
F12
|
||||
Take a screenshot (generate a PNG based on level data)
|
||||
```
|
||||
|
||||
## Developer Console
|
||||
|
||||
Press `Enter` at any time to open the developer console.
|
||||
|
@ -68,14 +67,14 @@ Commands supported:
|
|||
new
|
||||
Create a new map in Edit Mode.
|
||||
|
||||
save [filename.json]
|
||||
save [filename]
|
||||
Save the current map in Edit Mode. The filename is required if the map has
|
||||
not been saved yet.
|
||||
|
||||
edit [filename.json]
|
||||
Open a map in Edit Mode.
|
||||
edit [filename]
|
||||
Open a map or doodad in Edit Mode.
|
||||
|
||||
play [filename.json]
|
||||
play [filename]
|
||||
Open a map in Play Mode.
|
||||
|
||||
echo <text>
|
||||
|
|
|
@ -11,8 +11,6 @@ type State struct {
|
|||
Button1 *BoolTick
|
||||
Button2 *BoolTick
|
||||
|
||||
// Screenshot key.
|
||||
ScreenshotKey *BoolTick
|
||||
EscapeKey *BoolTick
|
||||
EnterKey *BoolTick
|
||||
ShiftActive *BoolTick
|
||||
|
@ -35,7 +33,6 @@ func New() *State {
|
|||
return &State{
|
||||
Button1: &BoolTick{},
|
||||
Button2: &BoolTick{},
|
||||
ScreenshotKey: &BoolTick{},
|
||||
EscapeKey: &BoolTick{},
|
||||
EnterKey: &BoolTick{},
|
||||
ShiftActive: &BoolTick{},
|
||||
|
|
|
@ -19,6 +19,14 @@ var (
|
|||
// Poll for events.
|
||||
func (r *Renderer) Poll() (*events.State, error) {
|
||||
s := r.events
|
||||
|
||||
// helper function to push keyboard key names on keyDown events only.
|
||||
pushKey := func(name string, state uint8) {
|
||||
if state == 1 {
|
||||
s.KeyName.Push(name)
|
||||
}
|
||||
}
|
||||
|
||||
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
|
||||
switch t := event.(type) {
|
||||
case *sdl.QuitEvent:
|
||||
|
@ -103,8 +111,30 @@ func (r *Renderer) Poll() (*events.State, error) {
|
|||
continue
|
||||
}
|
||||
s.EnterKey.Push(t.State == 1)
|
||||
case sdl.SCANCODE_F1:
|
||||
pushKey("F1", t.State)
|
||||
case sdl.SCANCODE_F2:
|
||||
pushKey("F2", t.State)
|
||||
case sdl.SCANCODE_F3:
|
||||
pushKey("F3", t.State)
|
||||
case sdl.SCANCODE_F4:
|
||||
pushKey("F4", t.State)
|
||||
case sdl.SCANCODE_F5:
|
||||
pushKey("F5", t.State)
|
||||
case sdl.SCANCODE_F6:
|
||||
pushKey("F6", t.State)
|
||||
case sdl.SCANCODE_F7:
|
||||
pushKey("F7", t.State)
|
||||
case sdl.SCANCODE_F8:
|
||||
pushKey("F8", t.State)
|
||||
case sdl.SCANCODE_F9:
|
||||
pushKey("F9", t.State)
|
||||
case sdl.SCANCODE_F10:
|
||||
pushKey("F10", t.State)
|
||||
case sdl.SCANCODE_F11:
|
||||
pushKey("F11", t.State)
|
||||
case sdl.SCANCODE_F12:
|
||||
s.ScreenshotKey.Push(t.State == 1)
|
||||
pushKey("F12", t.State)
|
||||
case sdl.SCANCODE_UP:
|
||||
s.Up.Push(t.State == 1)
|
||||
case sdl.SCANCODE_LEFT:
|
||||
|
|
|
@ -118,6 +118,14 @@ func (d *Doodle) Run() error {
|
|||
break
|
||||
}
|
||||
|
||||
if ev.KeyName.Now == "F3" {
|
||||
DebugOverlay = !DebugOverlay
|
||||
ev.KeyName.Read()
|
||||
} else if ev.KeyName.Now == "F4" {
|
||||
DebugCollision = !DebugCollision
|
||||
ev.KeyName.Read()
|
||||
}
|
||||
|
||||
// Run the scene's logic.
|
||||
err = d.Scene.Loop(d, ev)
|
||||
if err != nil {
|
||||
|
|
|
@ -17,7 +17,7 @@ const maxSamples = 100
|
|||
// Debug mode options, these can be enabled in the dev console
|
||||
// like: boolProp DebugOverlay true
|
||||
var (
|
||||
DebugOverlay = true
|
||||
DebugOverlay = false
|
||||
DebugCollision = false
|
||||
|
||||
DebugTextPadding int32 = 8
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"math"
|
||||
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
)
|
||||
|
||||
// Chunker is the data structure that manages the chunks of a level, and
|
||||
|
@ -30,7 +29,6 @@ func NewChunker(size int) *Chunker {
|
|||
// on disk) to connect references to the swatches in the palette.
|
||||
func (c *Chunker) Inflate(pal *Palette) error {
|
||||
for coord, chunk := range c.Chunks {
|
||||
log.Debug("Chunker.Inflate: expanding chunk %s", coord)
|
||||
chunk.Point = coord
|
||||
chunk.Size = c.Size
|
||||
chunk.Inflate(pal)
|
||||
|
|
|
@ -169,9 +169,7 @@ func (w *Canvas) Loop(ev *events.State) error {
|
|||
if err := w.loopFollowActor(ev); err != nil {
|
||||
log.Error("Follow actor: %s", err) // not fatal but nice to know
|
||||
}
|
||||
if err := w.loopConstrainScroll(); err != nil {
|
||||
log.Debug("loopConstrainScroll: %s", err)
|
||||
}
|
||||
_ = w.loopConstrainScroll()
|
||||
|
||||
// Remove any actors that were destroyed the previous tick.
|
||||
var newActors []*Actor
|
||||
|
|
Loading…
Reference in New Issue
Block a user