Spit and polish
* Made the loadscreen useful again (give it work to do async so the game doesn't simply freeze during): does a first call to LoadUnloadChunks to preload the viewport chunks. * Hide the mouse cursor when movement keys are pressed.
This commit is contained in:
parent
450c6b3bb2
commit
434416d3a4
|
@ -147,8 +147,10 @@ func Loop(ev *event.State) {
|
|||
if SceneName == "Play" {
|
||||
// Toggle between GameplayMode and MouseMode.
|
||||
if p1mode == GameplayMode {
|
||||
shmem.FlashError("Mouse Mode: Left stick moves the cursor.")
|
||||
p1mode = MouseMode
|
||||
} else {
|
||||
shmem.FlashError("Game Mode: Left stick moves the player.")
|
||||
p1mode = GameplayMode
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"git.kirsle.net/apps/doodle/pkg/balance"
|
||||
"git.kirsle.net/apps/doodle/pkg/collision"
|
||||
"git.kirsle.net/apps/doodle/pkg/cursor"
|
||||
"git.kirsle.net/apps/doodle/pkg/doodads"
|
||||
"git.kirsle.net/apps/doodle/pkg/gamepad"
|
||||
"git.kirsle.net/apps/doodle/pkg/keybind"
|
||||
|
@ -17,6 +18,7 @@ import (
|
|||
"git.kirsle.net/apps/doodle/pkg/physics"
|
||||
"git.kirsle.net/apps/doodle/pkg/savegame"
|
||||
"git.kirsle.net/apps/doodle/pkg/scripting"
|
||||
"git.kirsle.net/apps/doodle/pkg/shmem"
|
||||
"git.kirsle.net/apps/doodle/pkg/sprites"
|
||||
"git.kirsle.net/apps/doodle/pkg/uix"
|
||||
"git.kirsle.net/go/render"
|
||||
|
@ -44,6 +46,7 @@ type PlayScene struct {
|
|||
scripting *scripting.Supervisor
|
||||
running bool
|
||||
deathBarrier int // Y position of death barrier in case of falling OOB.
|
||||
lastCursor render.Point // position of cursor X,Y last tick
|
||||
|
||||
// Score variables.
|
||||
startTime time.Time // wallclock time when level begins
|
||||
|
@ -282,6 +285,7 @@ func (s *PlayScene) setupAsync(d *Doodle) error {
|
|||
// images which later get fed directly into SDL2 saving speed at
|
||||
// runtime, + the bitmap generation is pretty wicked fast anyway.
|
||||
loadscreen.PreloadAllChunkBitmaps(s.Level.Chunker)
|
||||
s.drawing.LoadUnloadChunks(true)
|
||||
|
||||
// Gamepad: put into GameplayMode.
|
||||
gamepad.SetMode(gamepad.GameplayMode)
|
||||
|
@ -624,6 +628,9 @@ func (s *PlayScene) GetCheated() bool {
|
|||
// This is the common handler function between easy methods such as
|
||||
// BeatLevel, FailLevel, and DieByFire.
|
||||
func (s *PlayScene) ShowEndLevelModal(success bool, title, message string) {
|
||||
// Always restore the cursor.
|
||||
cursor.Current = cursor.NewPointer(s.d.Engine)
|
||||
|
||||
config := modal.ConfigEndLevel{
|
||||
Engine: s.d.Engine,
|
||||
Success: success,
|
||||
|
@ -758,6 +765,15 @@ func (s *PlayScene) Loop(d *Doodle, ev *event.State) error {
|
|||
// Touch regions.
|
||||
s.LoopTouchable(ev)
|
||||
|
||||
// Hide the mouse cursor if a gameplay input was received.
|
||||
if keybind.Right(ev) || keybind.Left(ev) || keybind.Up(ev) || keybind.Down(ev) ||
|
||||
keybind.Use(ev) {
|
||||
cursor.Current = cursor.NoCursor
|
||||
} else if s.lastCursor != shmem.Cursor {
|
||||
cursor.Current = cursor.NewPointer(s.d.Engine)
|
||||
}
|
||||
s.lastCursor = shmem.Cursor
|
||||
|
||||
s.movePlayer(ev)
|
||||
if err := s.drawing.Loop(ev); err != nil {
|
||||
log.Error("Drawing loop error: %s", err.Error())
|
||||
|
|
|
@ -54,7 +54,7 @@ func (w *Canvas) presentCursor(e render.Engine) {
|
|||
// Are we editing with a thick brush?
|
||||
if w.Tool == drawtool.LineTool || w.Tool == drawtool.RectTool ||
|
||||
w.Tool == drawtool.PencilTool || w.Tool == drawtool.EllipseTool ||
|
||||
w.Tool == drawtool.EraserTool {
|
||||
w.Tool == drawtool.EraserTool && w.Editable {
|
||||
|
||||
// Draw a box where the brush size is.
|
||||
if w.BrushSize > 0 {
|
||||
|
|
|
@ -17,10 +17,12 @@ import (
|
|||
LoadUnloadChunks optimizes memory for (level) canvases by warming up chunk images
|
||||
that fall within the LoadingViewport and freeing chunks that are outside of it.
|
||||
*/
|
||||
func (w *Canvas) LoadUnloadChunks() {
|
||||
if w.level == nil || shmem.Tick%balance.CanvasLoadUnloadModuloTicks != 0 || !balance.Feature.LoadUnloadChunk {
|
||||
func (w *Canvas) LoadUnloadChunks(force ...bool) {
|
||||
if !(len(force) > 0 && force[0]) {
|
||||
if w.level == nil || shmem.Tick%balance.CanvasLoadUnloadModuloTicks != 0 || !balance.Feature.LoadUnloadChunk || (len(force) > 0 && force[0]) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
vp = w.LoadingViewport()
|
||||
|
|
|
@ -497,11 +497,12 @@ func (c Settings) makeControllerTab(tabFrame *ui.TabFrame, Width, Height int) *u
|
|||
Value: int(gamepad.NStyle),
|
||||
},
|
||||
},
|
||||
SelectValue: *c.ControllerStyle,
|
||||
SelectValue: &c.ControllerStyle,
|
||||
OnSelect: func(v interface{}) {
|
||||
style, _ := v.(int)
|
||||
log.Error("style: %d", style)
|
||||
gamepad.SetStyle(gamepad.Style(style))
|
||||
*c.ControllerStyle = style
|
||||
saveGameSettings()
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user