00:00
00:00
mike
hello!

Mike Welsh @mike

Age 38, Male

stupids

Penn State

San Diego

Joined on 2/24/00

Level:
23
Exp Points:
5,596 / 5,880
Exp Rank:
8,104
Vote Power:
6.47 votes
Rank:
Police Captain
Global Rank:
3,932
Blams:
1,268
Saves:
1,003
B/P Bonus:
16%
Whistle:
Normal
Trophies:
10
Medals:
916
Supporter:
9y 11m 14d
Gear:
1

widescreen woes

Posted by mike - November 29th, 2007


In today's world of 16:9 and 1080p, it's becoming more and more important to make sure a game supports a variety of resolutions. A person could be playing on a computer monitor, a 10-inch standard def TV, or the latest and greatest 1080p widescreen. Deciding how to handle widescreen has been a stumbling block in Castle Crashers.

Why is this such a big deal? If we're on a widescreen TV, can't the game just display the extra graphics? Sadly, life isn't that easy -- there are lots of subtle nuances that can have a negative effect on the game.

Unchanging Destiny: Determinism

Determinism means that each event is a direct and inevitable result of everything that has happened in the past. In computer science terms, determinism means that given the same inputs, you'll always get the same output. For a game, the inputs are the player's buttons presses, and the output is the game on the screen. Determinism is a necessary property for a game to have.

Why is determinism so important? The big reason is that all players should have the same, consistent game experience, regardless of what hardware they are playing on. How can differing screen size affect determinism?

In a 2D sidescroller like Castle Crashers, the game logic is tied closely to the size of the screen. The screen stops scrolling when the edge of the screen reaches a certain point. Players and enemies can't move past the edges of the screen. Enemies swing in from just offscreen. The camera zooms out to keep all the players in view. These are just a few of the gameplay elements that are affected by the aspect ratio of the screen. Change the aspect ratio, and the game itself changes.

Ensuring Determinism

It seems like these changes might be small and unnoticeable, but they easily snowball into big problems. Let's look at how to ensure gameplay is unaffected when the screen size changes.

1. Decouple game logic from the display.

A game should be viewed as a state machine, ticking from one state to the next without regard for how it's being displayed. The display is just a "camera" that shows a picture of the game, but should have absolutely no effect on it -- your game will still run just the same if you change cameras, or even if you have no camera at all. This fits in nicely with the Model-view-controller design pattern.

To ensure your game logic is decoupled from your display, avoid writing code like:

spawnNewEnemy( SCREEN_WIDTH+100, SCREEN_HEIGHT+100 );
if( player.x > camera.x + SCREEN_WIDTH/2 ) player.x = camera.x + SCREEN_WIDTH/2;

The enemy's position will vary depending on the size of the screen. The maximum position the player can reach will vary similarly. This violates determinism.

You CAN write code like:

playerHud.x = 10;
playerHud.y = SCREEN_HEIGHT-100;

Naturally, you want the HUD to position itself nicely on the edges on the screen. The HUD will have no effect on the actual gameplay, so doing this is fine!

Unfortunately, decoupling the display in this way is difficult for some types of games. Generally, 3D games are automatically decoupled from the display. On the other hand, many 2D game types rely heavily on the dimensions of the screen -- particularly sidescrollers, where the edges of the screen can play a big role in collision and enemy spawning. This leads to the alternative...

2. Force the game to always use the same size, and letterbox or crop the display.

If your game logic always uses the same size regardless of display type, you have no problem. Unfortunately, you then have to put some blacks bars or other ugly nonsense on the edges of your screen.

Castle Crashers is taking this route. The game itself always runs in a widescreen aspect ratio. On a standard TV, we letterbox the game. Instead of some ugly dead space, we use the extra area to display a nice HUD panel, similar to what Gauntlet does. In widescreen, the game fills the entire screen, and the health bars float on top of the game.

3. Screw it

If you want, you can totally ignore the fact that your game plays differently on one TV than it does on another. Your game is still mostly deterministic, only varying between widescreen and standard televisions. Regardless, this is a Bad Thing -- do you really want your game to play differently for some people than it does for others? It might be slightly harder or slightly easier.

Determinism is also necessary for other aspects of the game. Take multiplayer: say one player is on a standard TV and the other on widescreen. If your game plays differently on the different TVs, how will you possibly be able to keep the two players in sync? Making sure your game plays the same across different hardware will avoid these problems.

Always try to make game logic run exactly the same, regardless of the hardware it is running on.

widescreen woes


Comments

I personally agree with forcing it to be letterbox. Definitely don't "screw determinism". Decoupling sounds a bit too hard. Though, I guess it's up to you guys.

BTW, Is there a release date for this?

Personally, I hate widescreen, and I sympathize. There's no gaming experience I hate more than playing a 1024x768 game on a widescreen monitor. The black bars on the sides look SO STUPID.

Zomg looks fun!

My head hurts.

I would have thought having black bars on the top and bottom for standard displays would have been the best route, as it not only maintains the aspect ratio of the game, but gives it also gives the game a 'cinematic' feel, like in 'Beyond Good and Evil'.

That's how we're doing it -- but instead of black bars, it'll be the HUD containing the player's health, name, etc.

This was definitely something I noticed between the Alien Hominid PS2 and XBLA versions. The HD version seemed to kick my butt a little more, and I was quite sure it was due to enemies spawning earlier and further away from me due to the widescreen, thus their ability to shoot me easier. Or I could have just been deluded by my lame AH skills.

This difference also becomes annoying when watch HD channels that don't care to shoot their content at HD... they advertise this awesome HD quality but end up just filling in the sidebars with an ESPN logo or something like that.

Anyway, good luck with your resolution issues.

Fuck you mike for hurting my delicate brain.

I DUNNO MIKE YOU JUST SOUND LIKE A WEAK PROGRAMMER

AND YOU CAN'T EVEN BEAT GOD HAND ON DIFFICULT

is that a challenge

Computer science terms...I know they're necessary for effective communication within the industry, but they seem so hoity toity:

DETERMINISM! GAME LOGIC! DECOUPLE! STATE MACHINE! GRAY POUPON!

so true :)

the worst is when you mix marketing speak with it:
"Manufacturers operate in an environment that requires information exchange across every domain of the enterprise. Even more so in a global business climate that demands integrating operations and systems, collaboration must move beyond the buzzword and instead become a cornerstone."

It's like trying to convey the least amount of information in the maximum amount of convoluted text

Mike...follow your heart. You can do it!

Would there ever be a Flash version of this ?

Interesting, thanks!

I think I'll stick with square-pixeled computer monitor audience for now : (

I learned something today.

I'll remember that the next time I program a complex game to run on a nex-gen console. This has no effect on my life, but I read it. I need to prioritize better. Anyway, Castle Crashers is looking fantastic.

I couldn't think of anything better than black bars, just make them look as background'ish as possible eg. sandy yellow in the desert. Or make it a knights helm maybe. Or simply move HUD from bottom to sides (though that would confuse people).

You could do what many new HD channels are doing when they realize there is a vast lack of HD programs not being displayed somewhere else:

Do 4:3 programs in 16:9 with banners on each side.

Kinda like a DR Mario feel. Dunno if that would shit cheesy at all though...
Yeah I know that solves nothing . :)

woooooooooooooooooooo