Fix climbing on the right bug + eager-render boolprop

* New boolProp to help debug memory issues: eager-render, set it to
  false and the loadscreen will not eagerload Go images for all the
  level chunks.
* Finally fix the level collision bug where the player could climb walls
  to the right.
This commit is contained in:
Noah 2022-04-09 18:21:26 -07:00
parent 6b8c7a1efe
commit d694fcc7c2
4 changed files with 25 additions and 5 deletions

View File

@ -45,6 +45,10 @@ var Boolprops = map[string]Boolprop{
Get: func() bool { return CompressDrawings },
Set: func(v bool) { CompressDrawings = v },
},
"eager-render": {
Get: func() bool { return EagerRenderLevelChunks },
Set: func(v bool) { EagerRenderLevelChunks = v },
},
}
// GetBoolProp reads the current value of a boolProp.

View File

@ -105,6 +105,14 @@ var (
// Limits on the Flood Fill tool so it doesn't run away on us.
FloodToolVoidLimit = 600 // If clicking the void, +- 1000 px limit
FloodToolLimit = 1200 // If clicking a valid color on the level
// Eager render level chunks to images during the load screen.
// Originally chunks rendered to image and SDL texture on-demand, the loadscreen was
// added to eager load (to image) the whole entire level at once (SDL textures were
// still on demand, as they scroll into screen). Control this in-game with
// `boolProp eager-render false` and the loadscreen will go quicker cuz it won't
// load the whole entire level. Maybe useful to explore memory issues.
EagerRenderLevelChunks = true
)
// Edit Mode Values

View File

@ -55,8 +55,8 @@ The `target` is the point the actor wants to move to on this tick.
*/
func CollidesWithGrid(d Actor, grid *level.Chunker, target render.Point) (*Collide, bool) {
var (
P = d.Position()
S = d.Size()
P = d.Position()
S = d.Size()
hitbox = d.Hitbox()
result = &Collide{
@ -162,6 +162,10 @@ func CollidesWithGrid(d Actor, grid *level.Chunker, target render.Point) (*Colli
// left wall sometimes, but breaks walking up leftward slopes.
point.X = capLeft
}
if capRight != 0 && point.X > capRight {
// This if check fixes the climbing-walls-on-the-right bug.
point.X = capRight
}
if has := result.ScanBoundingBox(render.Rect{
X: point.X,

View File

@ -7,6 +7,7 @@ import (
"git.kirsle.net/apps/doodle/pkg/balance"
"git.kirsle.net/apps/doodle/pkg/level"
"git.kirsle.net/apps/doodle/pkg/log"
"git.kirsle.net/apps/doodle/pkg/shmem"
"git.kirsle.net/apps/doodle/pkg/uix"
"git.kirsle.net/go/render"
@ -225,9 +226,12 @@ func Loop(windowSize render.Rect, e render.Engine) {
// of chunks vs. chunks remaining to pre-cache bitmaps from.
func PreloadAllChunkBitmaps(chunker *level.Chunker) {
loadChunksTarget := len(chunker.Chunks)
// if loadChunksTarget == 0 {
// return
// }
// Skipping the eager rendering of chunks?
if !balance.EagerRenderLevelChunks {
log.Info("PreloadAllChunkBitmaps: skipping eager render")
return
}
for {
remaining := chunker.PrerenderN(10)