General control commands

Description

There are a collection of commands within AppGameKit Studio that provide you with extra fine control over some specific elements. These commands include the ability to sort sprites, disable screen clearing, alter the border color, set filtering options and return the frame rate at which the program is running.

Some of the commands demonstrated in this document are:

Setting supported orientations

When an AppGameKit Studio program launches it is initially set to support all screen orientations. On the Microsoft Windows and Mac OS X platforms this may not be an issue. However, on mobile devices this may be a concern. It's possible your game may only support landscape or portrait and not both. By using the command SetOrientationAllowed you can control the supported orientations for your program. This command takes 4 parameters with the first being portrait mode, the second flipped portrait, the third landscape and the fourth flipped landscape. Values of 1 indicate the mode is supported while a value 0 indicates the mode is not supported. This example shows that our program only supports both portrait modes:

SetOrientationAllowed ( 1, 1, 0, 0 )

Finding the frame rate

You may find it useful to find out how quick your program is running. This is handled with the command ScreenFPS. This command returns a value letting you know how fast it's performing. The best place to put this is within your main loop e.g.

do
    fps = ScreenFPS ( )
loop

Setting the clear color

When your program runs, by default the screen will be colored black. This is because the screen is cleared each frame to a specific color, which is black by default. It's possible to change this color by calling the command SetClearColor. This command takes 3 parameters for the red, green and blue components. If we wanted our clear color to be red we could call:

SetClearColor ( 255, 0, 0 )

Full code listing

Here's the final code for our program. It sets the allowed orientations (portrait only), the clear color to red and retrieves the frame rate of our program in the main loop:

SetOrientationAllowed ( 1, 1, 0, 0 )

SetClearColor ( 255, 0, 0 )
do fps = ScreenFPS ( ) Print ( fps )
Sync ( ) loop

Conclusion

These are some of the key commands to be aware of, there are many other general commands that are very useful for controlling certain apsects of your program. Please refer to the reference guide for more details.