Fullscreen Scaling in Phaser

This weekend I’ve been playing a bit with nailing down multi-device scaling in Phaser games. This was a bit more confusing than I expected, but I mostly figured out why and thought I’d share.

Update: I’ve posted this example and a state-based project template to GitHub.

My objectives were very simple:

  • Set logical view dimensions around which the game will be based;
  • Scale the game to fill the available window when loaded, maintaining aspect ratio and content;
  • Upon clicking have the game go fullscreen and scale to fill the screen, maintaining aspect ratio and content.

This minimal example demonstrates those (click to fullscreen, again to return):

 

In the blog view here the game has been placed inside a 300px iframe and scales down accordingly from an 800×600 logical view. After you click it scales up to fill the screen as much as it can without losing content. All of this is using Phaser 2.1.3, the latest release. Note that this is just in Chrome & Chromium. Desktop Firefox seems to have have wholly separate issues, and on Android Firefox fullscreening doesn’t seem to do anything.

This test is extremely similar to Phaser’s dragon and anime fullscreen examples as well as its Full Screen Mobile project template. However, those have a couple issues and do not work ideally for me on both my desktop (Linux laptop, Chromium) and phone (Galaxy S3, Chrome). In the end the problems were small but critical.

First, Phaser’s ScaleManager has an undocumented property fullScreenScaleMode that controls how games scale in fullscreen mode. The examples use this. The project template however uses the property scaleMode. It’s fairly easy to miss that these are using different properties, and that the fullscreen variant even exists. Further, it seems you actually have to set both to get the expected behavior, at least for SHOW_ALL scaling and my two platforms. The code below has a simple chart of the effects under various combinations of setting or not setting both of these.

Second, the ScaleManager property pageAlignHorizontally seems to have a bug. In windowed mode it works as expected, but in fullscreen it actually causes the game to be horizontally off-centered. For the moment I’m planning to put the game into a container div to center in windowed mode. Phaser seems to take care of centering the game in fullscreen mode even without this being set. I haven’t diagnosed this further. My guess is the base code is setting a left margin to center the game if the property is set, and then fullscreen mode applies a left margin again without checking to see if that has already been done.

Third, it’s not clear from the examples and docs what of Phaser’s ScaleManager API is needed and what is not. The project template in particular does several things that don’t seem to matter, for example calling ScaleManager::setScreenSize(). Removing that seems to have no effect with these settings, though the docs say it’s necessary. Conversely, it is important to call ScaleManager::refresh() to have the game scale at the start. Otherwise you have to go fullscreen or cause another window change to have the settings apply. The examples however don’t call this.

In any event, after finally identifying all these the test seems to work well on both my laptop and phone. Code is as follows:

<html>
<head>
  <script src="/deps/phaser-2.1.3-arcade-min.js"></script>
</head>

<body style="margin:0px; padding: 0px;">
<div id="game"></div>

<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'game',
  { preload: preload, create: create });

function preload() {
  game.stage.backgroundColor = '#336699';
  game.load.image('logo', '20141026-scaletest-logo.png');
}

function create() {

  // Put a graphic in the center to demonstrate.
  sprite = game.add.sprite(game.world.centerX, game.world.centerY, 'logo');
  sprite.anchor.set(0.5);

  /*
   * How the following modes take affect.
   *
   * On a laptop (Linux, Chromium browser):
   *   FS Scale  Reg Scale Reg Result  FS Result
   *   On        On        Fills       Fills
   *   On        Off       Unscaled    Fills
   *   Off       On        Fills       Unscaled
   *   Off       Off       Unscaled    Unscaled
   *
   * On a phone (Galaxy S3, Chrome browser):
   *   FS Scale  Reg Scale N Result    FS Result
   *   On        On        Fills       Fills
   *   On        Off       Too big     Unscaled
   *   Off       On        Fills       Unscaled; buggy
   *   Off       Off       Too big     Exact fit
   *
   */
  game.scale.fullScreenScaleMode = Phaser.ScaleManager.SHOW_ALL;
  game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;

  // Properly centers game in windowed mode, but aligning
  // horizontally makes it off-centered in fullscreen mode.
  //game.scale.pageAlignHorizontally = true;
  //game.scale.pageAlignVertically = true;

  // Docs say this is necessary, but it doesn't seem to change behavior?
  //game.scale.setScreenSize(true);

  // This is necessary to scale before waiting for window changes.
  game.scale.refresh();

  game.input.onDown.add(gofull, this);

}

function gofull() {
  if (game.scale.isFullScreen) {
    game.scale.stopFullScreen();
  } else {
    game.scale.startFullScreen(false);
  }
}
</script>
</body>
</html>

Berks PA Doubles @ Railyard

kingbreakers-iconSaturday the dynamic duos of Colin and Brett and John L and I went out for a Berks PA 40K Doubles Tournament at Railyard Hobbies. First of all, that place is amazing. I haven’t been to the Railyard before, and it blew my mind.  It’s ridiculously huge, and the terrain building supplies are all but endless. Definitely a good tournament venue, and though a bit out of the way from Center City Philly, potentially worth the trip for terrain materials and tools.

Armies were 1500 points per player, battle forged but no other restrictions. Both players on a team fielded a warlord. All partners were treated as Allies of Convenience. A single psychic warp charge pool was shared.

Eight teams showed, with various Marines, Imperial Guard, Daemons and Chaos Marines, a small Eldar presence, Necrons, some Imperial Knights, a couple more Knights dropping out of a Thunderhawk, and oh yeah a C’Tan and his buddies who just happen to also be Knights. Photos are in the Flickr gallery.

For the Emperor.

For the Emperor.

Armies

John and I fielded what I feel is a well balanced and relatively normal army. Originally we were going to divide into John on offense and me on defense. But then we were both busy and didn’t coordinate at all, so we wound up with a combined thrust across backfield, midfield, and the frontline.

On the Raukaan side:

  • Epistolary w/ The Gorgon’s Chain
  • Ironclad Dreadnought w/ Drop Pod
  • Sternguard x5 w/ 5x Combi-Melta, Drop Pod
  • Tacticals x10 w/ Meltagun, Lascannon, Lascannon Razorback
  • Tacticals x10 w/ Meltagun, Lascannon, Lascannon Razorback
  • Stormtalon Gunship
  • Stormtalon Gunship
  • Centurion Devastators (Grav-Cannons and Grav-Amps, Hurricane Bolters)

On the Kingbreakers side:

  • Captain Angholan (Vulkan)
  • Squad Harmon (Sternguard x5 w/ 3x Combi-Melta, Drop Pod)
  • Squad Scolirus (Tacticals x10 w/ Powerfist, Flamer, Missile Launcher, Drop Pod)
  • Squad Harbinger (Tacticals x5 w/ Combi-Melta, Meltagun, Meltabombs, Drop Pod)
  • Scouts x5 w/ Sniper Rifles
  • Devastators w/ 2x Plasmacannon, 2x Heavy Bolter
  • Knight Errant Greenheart (generic melta Knight)
  • Inquisitor Hersch (Coteaz)
  • Imperial Bunker w/ Void Shield

The few “gimmicks” in there are the Knight, Coteaz, the Void Shield Bunker, and the Librarian with The Gorgon’s Chain hanging out with Centurions hoping to cast Invisibility on them. Well, ok, maybe that’s a couple of gimmicks.  But it’s no re-rollable 3++ on a 6 HP model or a world-ending god shard. And it’s a solidly fluffy, Marines-out-for-a-stroll force composition.

IMG_9026

Come get some!

Round 1

First up we faced Ethan and Dustin with Imperial Guard and Space Wolves with a Knight. Mission was Dawn of War (12″), five objectives, double value Slay (effectively quadruple if you tagged both opposing warlords), Linebreaker, and bonus points for killing both opposing warlords while losing none of your own.

These guys did a good job deploying, in part through simply having so much to field. We had no juicy, vulnerable alpha strike targets and wound up taking risky drops against the opposing Knight, tucked hard into a corner and surrounded by Guardsmen. One Combat Squad went well off course but luckily toward our own forces, and bunkered down in ruins on an objective until it had a chance to pop out late-game and help slag a Punisher. The joint Sternguard attack put five hull points on the traitor Knight but didn’t manage to take it down before being summarily blown off the board. A lone surviving veteran did tie up the enemy Knight in combat for a turn or two, though this mostly just protected it from our lascannons.

Our Knight meanwhile trudged forward dropping melta on Terminators and Guard tanks, eventually walking onto an opposing objective. Centurions defended our center table and wiped out Terminators that made it to threatening positions. Squad Scolirus and Raukaan Tacticals burned out Creed and the Guard’s Company Command, but paid for it when Captain Angholan was forced to face the full withering fire of a Punisher at point blank and was mortally wounded. With things looking grim in the mid-game,  the Space Wolves and Guardsmen  started taking chances on risky reserve drops with terrible results teleporting in and dropping from flyers, further boosting our momentum.

Scoping out the battlefield.

Scoping out the battlefield.

Creeeeed!

Creeeeed!

Notes

We wound up with all the objectives and secondaries, only missing out on max points by losing my warlord. Unfortunately I took a bunch of chances on Angholan withstanding the Punisher, trying to tank wounds on him rather than his squad. He actually made it through the main gun pretty ok, but I forgot it would also then be shooting heavy bolters and a stubber at him and it was just too much. On the upside, it seemed like almost nobody got this bonus either.

The big thing here was that we had a bunch of weapons to fight Terminators, enough alpha strike and mobility to pen their army up against their back line, and nothing especially fearful of the Guard’s large blasts or heavy weaponry. Our small Combat Squads all over the place made for inefficient blast targets, and a combination of good line-of-sight blockers and the Knight’s shield rendered the missile launcher and lascannon teams largely moot until we could take them out.

Aaaaaahhhh!!!

Aaaaaahhhh!!!

Round 2

Next up was Zack and Brad with Imperial Guard and Grey Knights. Mission was Vanguard deployment (corners) for table quarters control with bonuses for Slay, surviving friendly Warlords, and no enemy units in your deployment zone.

Joint Sternguard blew up a Landraider, dumping out the many Purifiers inside on foot, far removed from our central area. The Sternguard along with reinforcing Raukaan Tacticals and an Ironclad Dreadnought spent the battle in an ongoing fight with them before eventually prevailing.  Our Knight got an early lucky hit torching the Grey Knights warlord and his bodyguards. Greenheart and our lascannon teams then wore down a squad of plasmacannon Sentinels before they could target our Centurions. Squad Harbinger put a lot of wounds on a Dreadknight, which then shunted right into the middle of half a dozen Raukaan lascannons. Captain Angholan and Scolirus spent the battle in assault with a group of Bullgryns protecting their Lord Commissar, eventually smashing her. A late arriving Vendetta and Valkyrie harried a thinly held rear table quarter, but were slowly attrited away by Stormtalons and lascannons.

No further!

No further!

Aaaahhh again!

Aaaahhh again!

Notes

We wound up with max points in this one, controlling all the quarters and picking up the secondaries. This battle was very similar to the previous one given the matchup. Again we were fortunate to have many tools, especially the Centurions and Knight Errant, for taking out Terminators. Zack did a great job of drawing it out with his Guard via harrying thrusts all over the board, but with us largely taking out the Grey Knights early on we just had too much momentum.

I really liked this mission. I wouldn’t want to replace standard objectives with table quarters, but it’s a good mix-in. One thing I liked was that because it’s harder to calculate on the fly, and in some ways easier to swing at the last minute, it can be much less clear who’s ahead and by how much, raising the tension throughout.

You're following the wrong path, commissar!

You’re following the wrong path, commissar!

Round 3

Finally we faced Mike and Al with their four Imperial Knights and Necron C’Tan army. Mission was Hammer and Anvil deployment (long axis) for a combination of kill points and objectives, with bonuses for Slay and each surviving troop unit.

All three objectives wound up placed in a short line along the table center cross axis. We mostly positioned far forward, as near to them as we could, and held on as long as possible. Join Sternguard got a good drop on one of the opposing Knights but its rerollable save via the Adamantine Lance formation shrugged it all off. The Knights and C’Tan hung back for several turns pinging away at our threatening weapons before coming forward supported by Night Scythes. From there the forces of good got slowly rolled up.

Yep.

Yep.

Notes

We picked up a single point for the Raukaan zapping a Night Scythe, and otherwise gave up an obscene amount of points as all our units except one lonely Drop Pod got obliterated. We felt it was a moral victory that we lasted until Turn 7, but the outcome was pretty much foregone from the start. Four Knights with three in an Adamantine Lance, a Transcendant C’Tan, and four Night Scythes with Warriors is a rough force to be looking at across the board. Playing the long axis didn’t help, as it enabled them to lurk out of range of our lascannons for most of the game. I really don’t know how we could have done any better against this army though.

Hands up!

Hands up!

Outcome

We didn’t come in with any tournament bonuses (early list submission, fully painted, etc.), but it seemed like few people did so that didn’t matter. Despite the third round drubbing, John and I held on for second place by a reasonable margin. First place, our Knights+C’Tan opponents, were ridiculously far ahead. A couple people quietly cheered us as the “non-cheese real winners.” I was happy with how we played throughout, and the final results. Depending on how you consider the NOVA Trios (we got crushed on games but got the 2nd best prize), that maintains what I believe is still a straight record of 2nd place results for me throughout 2014.

Thoughts

A couple more general thoughts.

Meta

I’m always hesitant to single out individual units, but it seems very plausible that the Transcendant C’Tan is a gamebreaker. Talking afterward I asked Al what could beat it. He replied “Well, you could buy a Warhound.” I had to work pretty hard to keep a straight face. Eventually he did come up with some other ideas, but they were all generally very specific and substantial purchases.

The Adamantine Lance formation is certainly a huge problem. It makes absolutely no game design sense to take an extremely strong, somewhat undercosted unit like the Imperial Knight, and give a collection of them huge bonuses for no additional points cost. Sure, they have to stay within 3″ of each other to get the effects, but that’s barely a limitation for the group in practice. Some of GW’s formations make rules sense to me as a way to fix or buff underpowered units and armies, like the Stormwing formation. A huge problem in frequently being a deliberate cash grab, like the Tyranid supplements (1, 2, 3), but otherwise solid. Others like the Lance though are definitely detrimental to both the game’s affordability and its play.

Lords of war.

Lords of war.

Tournament

The final mission highlighted issues with the scoring approach being used here, and I gather in several of the Berks PA events. Rather than determining games by victory points and then giving tournament points for wins and losses with bonuses for some special conditions, points earned in missions were simply summed throughout. In that last game the entire opposing army would have only given up fourteen kill points total even if we’d somehow managed to destroy everything. Meanwhile, John and I were each fielding that many units. That’s one thing in terms of the problems inherent to kill points missions, but a huge problem for a tournament if that goes directly into the tournament standings. It wouldn’t have mattered, but those last guys got a massive points boost off John & I between the kill points, objectives, and bonuses, unfair to everybody else. In general, tournament points should always at least be capped, preferably normalized.

That matchup was also a good example of where optional continuous scoring can really help balance the game. If we could have scored points throughout by holding objectives then we could have played a more tactical game, sacrificing units to try and hold up the oncoming tide with no expectation of lasting to the end. We all but certainly would have still lost, but potentially we’d have stood at least a chance of not being completed wiped on points, given that our opponents had so few units with which to attempting claiming and holding throughout.

On a final note, three thousand points total is probably too many points for a doubles game. Somewhat counter-intuitively, they tend to run slower anyway. At that many points there’s just a lot going on to begin with, and doubles games can take a very long time. That’s particularly true if at least one side is active in all the phases. It seemed like Colin and Brett really suffered from this, with several of their games cut short when they would have benefited from more turns.

Conclusion

Despite those concerns about the scoring and the serious balance problems built into 40k itself right now, this was a super fun event, well run in a low key but smooth manner and with a great crowd. Berks is going to run another team tournament in January, and I’ll definitely try to make it to that.

Again, more photos are in the gallery.

Wwwwaaaaaahhhhh!

Wwwwaaaaaahhhhh!

40k: 1500 pts versus Mechanicum

kingbreakers-iconJohn O and I got in a game Friday evening pitting his 30k Mechanicum against the Kingbreakers. We played 1500 pts to match with the Berks Team Tournament the next day, though I already knew I would be changing my list quite a bit. Some photos are in the Flickr gallery. I wasn’t particularly sold on the robots from Forge World’s pictures, but he’s made them look really good. Definitely a nice looking army to play against. I particularly like how the metallic, corroded paint job has made the Scions work really well as Tech Thralls.

Castellax on the move!

Castellax on the move!

These Scions must have angered somebody in charge of the Tech Thrall lobotomy admissions...

These Scions must have angered somebody in charge of the Tech Thrall lobotomy admissions…

Battle

My army was more purely aggressive than my larger battles of late: Captain Angholan (Vulkan), Sternguard Pod, Tactical Pod, Tactical Pod, Tactical Rhino, Scouts, Predator, Knight. A Combat Squad and the Scouts hung back, but otherwise everybody went forward to pen the apparently untrustworthy Mechanicum into a corner. Sternguard slagged a Krios Venator on the drop, then were ambushed and engaged in an interminable combat with a Dark Angels Dreadnought creeping in the shadows. Angholan slew the opposing Magos but was then crumped by a Castellax Maniple. Sgt Harbinger dropped to try and save his ailing leader, but his squad was flattened by a deluge of Mechanicum shooting. Meanwhile, yet more treacherous Dark Angels arrived, rushing up to assault the Tacticals controlling the center of the battlefield. At this the Knight Errant Greenheart finally had enough and went rampaging, kicking the Dark Angels into the rocks, shattering the Castellax automatons, stomping the remaining Tech Thralls, and smiting a Thanatar to clear the battlefield.

The Thanatar, bombarding poor little Tacticals across the board.

The Thanatar, bombarding poor little Tacticals across the board.

Thoughts

My current take on the Mechanicum in 40k is that it’s well equipped to fight fairly standard Marine-ish armies. There’s a lot of big dudes with high toughness and many wounds that kind of shrug off small arms fire and chainswords. Ditto on light tanks and hordes, it has a fair amount of high strength shooting and access to large blast shots. But the crazier stuff it’s not really prepared for on its own. Those high wound, high toughness robots are basically exactly the kind of thing a Knight and similar D-weapon equipped units are designed to engage in combat. That makes some sense given how 30k is mostly Marines fighting Marines.

More generally, this kind of thing highlights the Imperial Knight as a unit with definite phase shifts in effectiveness: If you’re not really prepared to fight one, it’s devastating. If you are prepared, it’s pretty manageable. On the far right of that spectrum, you can definitely bring units that will almost completely nullify a Knight. Between each of those three there isn’t much of a continuum, you can’t just ignore it and weather the effects, nor will it hold up long against units chosen to take it down.  Against a large spectrum of opponents it’s either crushing face or getting crushed, and in the middle of the spectrum it’s probably fighting another solitary Knight.

Again, more photos are in the gallery.

No, my little friend, today is not your day.

No, my little friend, today is not your day.