Because the supported platforms have various screen layouts and resolutions, we need to have separated definitions for each platform. For some devices the game will have a landscape orientation except for phone devices.
First we need to adjust the EDGELIB configuration within the OnDisplayConfig()
function to enable landscape or portrait mode depending on the resolution:
main.h (13 lines)
config->engineconsole = false; //Desktop PC: Disable the EDGELIB console
config->width = XRES; //Desktop PC: Custom display width
config->height = YRES; //Desktop PC: Custom display height
//Determine screen orientation
if (XRES < YRES)
config->orientation = DOR_PORTRAIT;
else if (XRES > YRES)
config->orientation = DOR_LANDSCAPE;
else
config->orientation = DOR_STARTUP;
return(E_OK);
XRES and YRES are platform dependent definitions and will be explained below.
The best way to create platform dependent definitions is to create a header file within each workspace folder. The header file included by the compiler will be the one from the active workspace, this will enable you to create definitions for each workspace separately. First let's create a definition file for workspace_pc:
def_platf.h (14 lines)
/////////////////////////////////////////////////////////////////////
// Workspace_pc/def_platf.h
//
// Copyright (c) 2006-2017 Elements Interactive B.V.
// http://www.edgelib.com
//
// Contains specific definitions for this platform
/////////////////////////////////////////////////////////////////////
#define XRES 640
#define YRES 480
#define MOVE_SPEED 8
#define DIM_SPRITE 8
This will define the screen resolution and a definition for resolution independent sprite animation as well as a sprite size modifier. After adding this file, we need to include it:
blastar.cpp (8 lines)
//Link the EDGELIB static library
#pragma comment(lib, "edge.lib")
//Platform dependent definitions
#include "def_platf.h"
//Include the main wrapper class
#include "main.h"
After running the sample, the desktop version should have a bigger screen in the correct orientation.
These will be the files for the other platforms. For this project, the UIQ platform will be similar to a Pocket PC, but with less vertical space.
def_platf.h (14 lines)
/////////////////////////////////////////////////////////////////////
// workspace_eide_320x240/def_platf.h
//
// Copyright (c) 2006-2017 Elements Interactive B.V.
// http://www.edgelib.com
//
// Contains specific definitions for this platform
/////////////////////////////////////////////////////////////////////
#define XRES 320
#define YRES 240
#define MOVE_SPEED 4
#define DIM_SPRITE 4
def_platf.h (14 lines)
/////////////////////////////////////////////////////////////////////
// workspace_eide_176x208/def_platf.h
//
// Copyright (c) 2006-2017 Elements Interactive B.V.
// http://www.edgelib.com
//
// Contains specific definitions for this platform
/////////////////////////////////////////////////////////////////////
#define XRES 176
#define YRES 208
#define MOVE_SPEED 3
#define DIM_SPRITE 3
def_platf.h (14 lines)
/////////////////////////////////////////////////////////////////////
// workspace_eide_320x208/def_platf.h
//
// Copyright (c) 2006-2017 Elements Interactive B.V.
// http://www.edgelib.com
//
// Contains specific definitions for this platform
/////////////////////////////////////////////////////////////////////
#define XRES 320
#define YRES 208
#define MOVE_SPEED 4
#define DIM_SPRITE 4
When looking at the MOVE_SPEED
definition for every platform, you will notice that this value will decrease when the resolution decreases. Objects will move faster when there is more screen space.