
|
December 14, 2005 |
|
|
| |
The Sony Ericsson W550 and W600 Walkman phones boast a screen display that can be rotated 90 degrees (so called "landscape mode" support), aimed specifically for gaming and camera use. Game developer and publisher Digital Chocolate converted their successful Mobile Java 3D game 3D Extreme Air Snowboarding to landscape mode ready for preloading on the Sony Ericsson W550i and W600 mobile phones at market launch. |
![]() |
The lessons learned from this development experience, and the support from Sony Ericsson during the project, helped Digital Chocolate to port four more mobile games, of which two are Mobile Java 3D, to the landscape gameplay style for Sony Ericsson mobile phones. The landscape versions of Johnny Crash Does Texas, Scarlotti's Mafia Wars II, 3D Beach Mini Golf, 3D Extreme Air Snowboarding and 3D Mini Golf Castles are all available through Digital Chocolate's own distribution channels and Sony Ericsson's Fun & Downloads website.
|
Here, Digital Chocolate explain the development challenges they faced during the Extreme Air Snowboarding 3D porting project, how they solved them and provide an example code snippet from the canvas implementation.
|
![]() |
|
Digital Chocolate started the landscape mode porting project for 3D Extreme Air Snowboarding by writing and adding a new canvas implementation to their core gaming library. This implementation, together with changes to Digital Chocolate's core toolkit, handles all the hard work and if the game is designed properly, the game itself requires little or no changes to existing code. The canvas simply receives information whenever the orientation of the screen is changed, and it reacts to this information by enabling/disabling an extra backbuffer, to which the graphics are rendered before drawing them to the screen, and by signaling the game to re-calculate screen offsets of graphical elements, tile counts and other data required for rendering the output. The game continues to draw into the graphics object it receives as usual, but the canvas implementation rotates the backbuffer by 90 degrees before drawing it to the actual screen graphics object. If the game code is designed to support this feature from the ground-up, this is theoretically all that is needed. Thankfully, most of Digital Chocolate's games have been designed so that they support scalable screen sizes so porting has been relatively easy. |
3D Extreme Air Snowboarding in landscape mode. |
Challenges and solutions
"For best portability, it's extremely important that the positions of the graphical elements are not hard-coded to fixed screen locations; instead, locations should be specified relatively to screen edges. Better yet, a percentage scale should be used whenever possible," explains Miikka Kukkosuo.
Figuring out a good layout for screen items requires some extra thinking at the beginning of the development cycle, as rotating the screen radically changes the display's aspect ratio. This poses an extra challenge for the graphic designers, who are often already working with tight graphics memory budgets and have to find an effective way to fit textboxes, score displays and other items onto the screen. Also the game components need to be designed so that they will not look bad even if the orientation changes, as usually only one graphics/tile set can be used for each game.
"For example in Scarlotti's Mafia Wars II we have a graphics engine which can adapt easily to different screen sizes, so adding landscape mode support to it was particularly easy," Miikka continues.
|
Does Mobile Java 3D make things easier?
|
Miikka Kukkosuo, game engineer at Digital Chocolate. |
On the W550, the game-pad style controller provides an easy way to control most games, and the extra A and B gaming buttons on the edge of the phone screen enhance playability. To keep things simple in the actual game code, Digital Chocolate grab the actual keycodes received from the Canvas before they are sent over to the game logic, and convert them to "real" key directions according to the screen orientation. This way the game code remains unchanged.
Softkey handling
As 3D Extreme Air Snowboarding was a preinstalled game, it was decided with Sony Ericsson to only draw a return/back softkey icon over the right softkey, as users of Sony Ericsson mobile phones already know that game selections (or fire) can be made with the left softkey or middle softkey.
This made the softkey drawing easier, as the right softkey icon could be drawn to the lower right corner when in normal mode, and to the lower left corner when in landscape mode. Left softkey text was just overridden with a space character, so that it remained enabled in landscape mode but no text or icon was visible for the user.
Conclusion and example code
Digital Chocolate discovered that adding landscape mode support to an existing game was relatively easy in both 2D and Mobile Java 3D if the game was well designed from the ground up. Digital Chocolate recommend spending some time to build flexible core classes so that fixed screen locations and parameters are kept to a minimum. This also enhances the portability of the game to other mobile phones and screen sizes.
"The landscape rendering mode and hardware buttons for two-handed control on the W550 and W600 phones truly improve the mobile gaming experience, regardless of whether you're a casual or more experienced gamer. As a game developer, we appreciate the fact that Sony Ericsson manages to create phones with true mass-market appeal while constantly being willing to listen to and learn from the professional development community in order to further advance the game-playing features and performance of its phones," concludes Mika Tammenkoski, VP Technology at Digital Chocolate.
The following code snippets are taken from the canvas implementation used by Digital Chocolate in the landscape version of 3D Extreme Air Snowboarding. In the code example, it should be noted that when the orientation of the screen is changed, the graphics buffer should be re-allocated, as done in setScreenRotated() method.
/**
* Sets the orientation of the canvas
*/
public void setScreenRotated(boolean rotated)
{
if (rotated)
{
m_rotated = true;
//update GameMIDlet static values
GameMIDlet.sm_screenHeight = super.getWidth();
GameMIDlet.sm_screenWidth = super.getHeight();
GameMIDlet.sm_screenOrientationNormal = false;
// Store the orientation flag to "global variables"
DataStorage.set(DataStorage.SCREEN_MODE_SETTING, DataStorage.SCREEN_LANDSCAPE);
}
else
{
m_rotated = false;
//update GameMIDlet static values
GameMIDlet.sm_screenHeight = super.getHeight();
GameMIDlet.sm_screenWidth = super.getWidth();
GameMIDlet.sm_screenOrientationNormal = true;
// Store the orientation flag to "global variables"
DataStorage.set(DataStorage.SCREEN_MODE_SETTING, DataStorage.SCREEN_NORMAL);
}
//empty old graphics buffer
m_frameBuffer = null;
}
/**
* Renders the Canvas.
* @param a_graphics Graphics object used for rendering
*/
public void paint(Graphics a_graphics)
{
try
{
if (m_frameBuffer == null)
{
a_graphics.setClip(0,0,this.getWidth(), this.getHeight());
m_frameBuffer = Image.createImage(this.getWidth(), this.getHeight());
m_frameG = m_frameBuffer.getGraphics();
if (Debugger.DEBUG) // Debug switched on
{
Debugger.verbose("Rotating canvas: framebuffer created, size: " + this.getWidth() + " x " + this.getHeight());
}
}
m_frameG.setClip(0,0,this.getWidth(), this.getHeight());
// Draw new frame on-screen
m_owner.draw(m_frameG);
// Draw softkey labels if fullscreen mode is used
// otherwise separate Softkey area is used & JVM handles drawing
if (DeviceStatics.USE_FULLSCREEN)
{
drawSoftkeyLabels(m_frameG);
}
//check screen rotation
if (m_rotated)
{
a_graphics.drawRegion(m_frameBuffer, 0,0, this.getWidth(),
this.getHeight(), Sprite.TRANS_ROT270, 0,0, Graphics.TOP + Graphics.LEFT);
}
else
{
a_graphics.drawRegion(m_frameBuffer, 0,0, this.getWidth(),
this.getHeight(), Sprite.TRANS_NONE, 0,0, Graphics.TOP + Graphics.LEFT);
}
}
catch (Throwable caught)
{
if (Debugger.DEBUG) // Debug switched on
{
caught.printStackTrace();
// Report to Debugger
Debugger.exceptionCaught(caught, "SumeaRotatingCanvas::paint() catch-all");
}
}
}
/**
* Overridden to ensure x/y sizes are flipped if necessary
*/
public int getWidth()
{
if (m_rotated)
{
//screen is rotated 90 degrees clockwise
return super.getHeight();
}
else
{
//normal orientation
return super.getWidth();
}
}
/**
* Overridden to ensure x/y sizes are flipped if necessary
*/
public int getHeight()
{
if (m_rotated)
{
//screen is rotated 90 degrees clockwise
return super.getWidth();
}
else
{
//normal orientation
return super.getHeight();
}
}
More information:
Copyright © 2001 - 2009 Sony Ericsson Mobile Communications AB. All Rights Reserved.