Outer Court

Basic - BlitzBasic - A Basic Action Game

This describes the concept of an action game. The game world is grouped into:

Sprites are the living beings that move around on the screen or interact in some way with the player. These could be giant bees attacking.

Ground describes what the sprites walk on. This could be grass.

Events are raised by sprites during the course of the game. For example, if the player shoots, or leaves the screen, or a giant bee has found honey, an event is raised.


All sprites have some things in common. Those are the things you only have to code once. The player has to move around. So do the giant bees. They both have to be drawn on the screen. If the player shoots a bullet, this bullet is just another sprite. Sprites have various values attached which make for a basic sprite type.


The sprite shape is its width, height and image number.

    sprite\image = LoadImage("file/my_sprite.bmp")
    sprite\width = 32
    sprite\height = 32


The position on the screen is defined by the x (left) and y (top) coordinates.

    ; position the sprite in the middle of
    ; of the screen
    sprite\x = SCREEN_WIDTH / 2
    sprite\y = SCREEN_HEIGHT / 2


The speed will change the sprite position over time, so it's added to the x and y position values. If the speedX is positive, the sprite will move to the right.

    sprite\x = sprite\x + sprite\speedX
    sprite\y = sprite\y + sprite\speedY

Target position

The position the sprite tries to move to. Speed will be adjusted accordingly.

Speed step

The amount speed is adjusted at a single unit of game time.
The higher this value, the faster sprites can adjust their speed.

Target speed

The target speed is the value the speed will try to adjust to.
This makes for softer movement of sprites.

In every game time unit, target speed is adjusted:

    const SPEED_ADJUST# = .01

    if sprite\speedX < sprite\targetSpeedX
        sprite\speedX = sprite\speedX + SPEED_ADJUST#
    if sprite\speedX > sprite\targetSpeedX
        sprite\speedX = sprite\speedX - SPEED_ADJUST#

Speed limit

The speed should never cross this. You can code a hunter sprite which will increase the speedX value if it's left of the player sprite, but it will stop to increase speed at a certain value.

Speed brake

The amount the speed will be reduced at each game time unit.


Stores the type of ground the sprite stands on.


The basic type of sprite to be handled in class-specific functions.

Class morph energy

Sprites morph into other classes. For example, an attacked bee might morph into a hunter sprite for some seconds. The morph energy is reduced in every game time unit.

Old Class

This value will remember the old class: when the morph energy is reduced to zero, the old class will take over as the main class again.

There are many other values a sprite has to keep. It also needs to know if it's pushed (by whom and in what direction), at which height it moves (like ground, or near sky), if it needs to pause, if it has energy. There should be a counter to handle timing. An attribute "master" should store the class the sprite was generated by, for example if the player shoots a bullet, the master is the player-class. You also need to control animation by keeping track of the current frame. The attributes container, containable, collideable and contained tell about the sprite interacting capabilities/ interaction status.

Sprite classes

A sprite class is a specific sprite. You cannot express the behavior of it in very general routines applicable to all sprites, so you will check the sprite-class and branch to specialized subroutines.

    select sprite\class
        case CLASS_PLAYER
            adjustSpeedToKeyboard sprite
        case CLASS_HUNTER
            followPlayerPosition playerSprite, sprite
        case CLASS_SLIDER_ONCE
            dieOutsideScreen sprite
            bounceAtScreenBorder sprite
    end select

Ground types

Some basic ground types are: walkable, dangerous, water, barrier, ice...
These are your basic static tiles you read into your map array, using data describing terrain types and image/ animation details.


An event is something which is not connected to sprites directly interacting. If the player steals an item, the item raises an event before it dies. A guard sprite might come to life--switch to class hunter--if it catches this event.
Or, you can navigate a couple of bees to track down the player after a single bee is attacked.

More tutorials at www.blitzcoder.com
Make a donation