Author Topic: [SUG][PLAYER+EDITOR] "Auto" option for screen start  (Read 2102 times)

0 Members and 1 Guest are viewing this topic.

Offline namida

  • Administrator
  • Posts: 12398
    • View Profile
    • NeoLemmix Website
[SUG][PLAYER+EDITOR] "Auto" option for screen start
« on: January 16, 2021, 07:43:09 PM »
I don't want to go as far as Lix does and take away the option for level creators to manually set a screen start position altogether.

However, I would still like to implement support for automatically determining the screen start position, and in turn make this the default option for new levels - with levels still able to override it and pick a position manually if they prefer.
« Last Edit: April 22, 2021, 10:00:15 PM by namida »
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline WillLem

  • Posts: 3348
  • Unity isn't sameness, it's togetherness
    • View Profile
Re: [SUG][PLAYER] "Auto" option for screen start
« Reply #1 on: January 17, 2021, 08:06:18 AM »
Sounds good! How will the automatic screen start be determined?

Offline namida

  • Administrator
  • Posts: 12398
    • View Profile
    • NeoLemmix Website
Re: [SUG][PLAYER] "Auto" option for screen start
« Reply #2 on: January 17, 2021, 06:26:38 PM »
Sounds good! How will the automatic screen start be determined?

TBD. My "starting point" thought - which obviously doesn't account yet for preplaced lemmings or multiple hatches - is to place the center about half way between the entrance and the ground, and some distance (maybe ~64px or so) from the entrance horizontally, undecided if this should be "in the direction lemmings face when they spawn" or "towards the exit" but leaning more towards the former.
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline namida

  • Administrator
  • Posts: 12398
    • View Profile
    • NeoLemmix Website
Re: [SUG][PLAYER] "Auto" option for screen start
« Reply #3 on: February 10, 2021, 07:50:01 PM »
Okay, so my initial thoughts here.

If there is exactly one entrance that spawns normal lemmings, the screen start position should be about half way between it and the ground, and slightly in front of it. Exact distances to be determined by trial and error.

If there is more than one such entrance, then we should find the entrance or exit closest to the midpoint of all entrances (including neutral / zombie entrances - I don't know why, but I feel they should be included in this step). If the result is that we find an exit, the screen start position should be focused on said exit. If the result is that we find an entrance, the screen start position should instead be focused on (same offset as in the single-entrance scenario) whichever entrance will be the first to spawn a normal lemming - not necesserially the entrance that was closest to the midpoint.

Should the level not contain any normal entrances, but contains multiple preplaced lemmings, we follow a similar process re: finding closest lemming or exit to the midpoint. If it's an exit, we focus on the exit. If it's a lemming, I'm not sure whether we should focus on that lemming, or the furthest lemming from the midpoint instead. Focus on the lemming should be slightly in front, just like with entrances.

And if it's a one-lemming level where that lemming is preplaced, I think the answer there is obvious. :P
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline Dullstar

  • Posts: 2092
    • View Profile
    • Leafwing Studios Website (EXTREMELY OUTDATED)
Re: [SUG][PLAYER] "Auto" option for screen start
« Reply #4 on: February 11, 2021, 06:59:46 AM »
Personally, while I think the exit positioning should be a factor, I would generally expect there to be a hatch (or pre-placed lemming, if there is no hatch) somewhere on the screen at the beginning.

Levels with multiple hatches could probably still use some UI improvements - on some levels, no matter what, they won't all fit, unless you do what Lix does and also allow a per-level default zoom - though even then, some layouts might still not be possible. But it's not always obvious that you need to look for another hatch. Maybe an arrow that displays at the start of the level or something? IDK

Offline namida

  • Administrator
  • Posts: 12398
    • View Profile
    • NeoLemmix Website
Re: [SUG][PLAYER] "Auto" option for screen start
« Reply #5 on: February 11, 2021, 08:06:24 AM »
Quote
Personally, while I think the exit positioning should be a factor, I would generally expect there to be a hatch (or pre-placed lemming, if there is no hatch) somewhere on the screen at the beginning.

I had levels like Tricky 10 / Mayhem 15 in mind here - basically, if the exit is in the middle of two (or more) entrances.
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline Simon

  • Administrator
  • Posts: 3860
    • View Profile
    • Lix
Re: [SUG][PLAYER] "Auto" option for screen start
« Reply #6 on: February 11, 2021, 12:44:17 PM »
Zoom

Lix, on start of play, begins zoomed out as far as possible such that
the factor is still >= 1x, and
the entire vertical screen is filled; unless that is very close to some integer factor that we could use by zooming out a tad further, then zoom out that tad further.

The gist is that I want a large chunk of the map on the screen as possible, but it's even more important to fill the screen entirely (than to show a lot of the map, but with unused screen space). I'll have to explain more why vertical screen filling is more important than horizontal, I'm not 100 % sure anymore why it is like this, but it feels nice. Maybe it's too much zooming-out on maps that are both very tall and very wide.

This zooming-out will already help a lot with preventing bad initial scrolling. Maybe some people will still play in a 640x480 window? I assume most people will play on something bigger.

Focus

Lix will:
For the set of your hatches,
map each hatch to its spawn point plus horizontal constant according to spawn direction,
to each such point, add a vertical constant downwards,
compute the average of these points (gets fancy on torus maps, but NL doesn't wrap),
focus on this point.

Again, the exact choice of focus isn't so important when we begin zoomed-out; often, a lot of the map will be on screen and such algorithm is merely the icing. Because I fill the screen vertically, this algo will still be important on very wide maps.



For NL, the same ideas should work, but we also have pre-placed lememings.

Stragglers (pre-placed lemmings): Hmm, keep the horizontal constant. Maybe scan for land below the straggler to determine the vertical constant. Take care when the straggler is glider. Maybe there is no land even in the movement path, e.g., when the glider starts in a teleporter loop.

Maybe such scanning for land should also happen for hatches, but again I'm not so sure.

During computation of the average, I feel like stragglers should carry the same weight as hatches carry. Only if you have more stragglers than hatches, you might want to weigh the stragglers less.

I wouldn't focus so much on exits; the focusing on the exit in Fast-Food Kitchen is a side effect of focusing on the average of the hatches.

-- Simon
« Last Edit: February 11, 2021, 01:01:36 PM by Simon »

Offline namida

  • Administrator
  • Posts: 12398
    • View Profile
    • NeoLemmix Website
Re: [SUG][PLAYER] "Auto" option for screen start
« Reply #7 on: February 11, 2021, 05:59:52 PM »
NeoLemmix specifically has an options relating to initial level zoom. I'm not sure how common it is for people to modify these settings, though I know for sure there are at least some users who do.

The first option is "Initial Zoom". This is set to an integer between 1x and a maximum determined based on window/screen size (I think the formula is something like "find the highest zoom that would allow a 320x160 level section to fit completely on screen, then add a fixed constant to this"). The name says it all - when you start a level, zoom will be set to this value.

The second option, I forget the exact name, something like "Increase Zoom On Small Levels". When this option is enabled, the zoom at the start of a level will be increased, I forget the exact rule. It will never lead to zooming out, only to further zooming in.

Lix, I presume, simply goes with the one universal behavior?


An entire change from "user controls initial zoom, level sets screen start" to "the whole thing is automatic" is not out of the question (though might become out of the question after community discussion), but it's a much bigger change than simply "user controls initial zoom, level can set screen start but can also let NL determine it automatically". (For reference: Screen start position defines where the center of the screen should be, so it can adapt to different screen sizes.)
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline Simon

  • Administrator
  • Posts: 3860
    • View Profile
    • Lix
Re: [SUG][PLAYER] "Auto" option for screen start
« Reply #8 on: February 13, 2021, 06:44:59 PM »
Yeah, Lix has no way in a level to specify initial focus or initial zoom. There was a level field for initial focus 10 years ago, when C++ Lix had a fixed resolution, but I removed that field. Every level starts with automatic focus/zoom. Nepster wasn't happy about the removal. I think Proxima also liked the level author setting.

In one way, auto-only zoom/focus inflics nastiness on the players if it's not good; on the other hand, every time people complained, I was able to improve the algorithm substantially. Prod me again to fish all details from the code; there is likely a lot of iceberg knowledge hidden in the code that came from the requests over the years.

If you're happy with such trial and error yourself: Make auto-initial-focus and auto-initial-zoom the default for every new level. Maybe even add a player option, off by default and mainly meant for testing, that forces your algorithm to override the level's focus/zoom. Whoever feels adventurous (or ranty) can then activate this override and, over the months, point you to maps where your algo is still failing.

-- Simon

Offline namida

  • Administrator
  • Posts: 12398
    • View Profile
    • NeoLemmix Website
Re: [SUG][PLAYER] "Auto" option for screen start
« Reply #9 on: April 22, 2021, 09:59:51 PM »
I've implemented a slightly simplified version of my ideas from Reply #3. To be precise:

- If the level contains no entrances or preplaced lemmings, the middle of the level is used as a fallback. Not that this matters in practice. :P
- If the level contains at least one entrance, the focus will be on the entrance or exit closest to the middle of all entrances. (If there is exactly one entrance, in practice this will always select that entrance, rather than an exit.)
- If the level contains no entrances, the focus will be on the preplaced lemming or exit closest to the middle of all preplaced lemmings. (Ditto for exactly one preplaced lemming.)
- If an entrance is selected, the initial screen position will be 48px in front of, and 20px below, the selected entrance.
- If a preplaced lemming is selected, the initial screen position will be 48px in front of, and 12px above, the selected lemming.
- If an exit is selected, the initial screen position will be 12px above the selected exit (with no horizontal offset in either direction).

For the purpose of this, an entrance's position is taken to be the actual trigger point where lemmings spawn. Likewise, for exits, the position is taken to be the center of its trigger area. Finally, all zombie / neutral entrances and preplaced lemmings are treated as if they do not exist throughout this algorithm.


There are edge cases that this doesn't catch (for example, it doesn't produce very nice results on "Compression Method 1" or "The Boiler Room"), but the above already produces a good result on the majority of levels. If particular edge cases it doesn't handle well come to light later, adjustments could be considered. And I will stress that the ability for level creators to manually set their own screen start position, is not going to be taken away.

Support is added to NeoLemmix player in commit 37b282a. I've moved this topic to the Editor board because I still need to add editor support.


For anyone who's wanting to get "ahead of the crowd" on file formats: Auto screen start is simply specified by not having a START_X and START_Y line in the file. If one or both of those lines are missing, NL will instead use an automatic screen start position.
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline WillLem

  • Posts: 3348
  • Unity isn't sameness, it's togetherness
    • View Profile
Re: [SUG][PLAYER+EDITOR] "Auto" option for screen start
« Reply #10 on: April 22, 2021, 10:37:36 PM »
Will this feature also be getting rid of the "cursor to centre" upon level start, perchance?

Offline namida

  • Administrator
  • Posts: 12398
    • View Profile
    • NeoLemmix Website
Re: [SUG][PLAYER+EDITOR] "Auto" option for screen start
« Reply #11 on: April 23, 2021, 01:33:02 AM »
Editor support implemented in 745008f. Moved the topic back to the Engine board accordingly, as any further discussion is likely to be about the implementation in-game, not about anything to do with the editor.

Quote
Will this feature also be getting rid of the "cursor to centre" upon level start, perchance?

If you're talking about what I think you're talking about here, that is completely unrelated to this topic.
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline WillLem

  • Posts: 3348
  • Unity isn't sameness, it's togetherness
    • View Profile
Re: [SUG][PLAYER+EDITOR] "Auto" option for screen start
« Reply #12 on: April 23, 2021, 10:47:25 AM »
If you're talking about what I think you're talking about here, that is completely unrelated to this topic.

Ah, OK. I've created a new sug topic for it in that case.