Race around the city collecting the flags while avoiding those that stand in the way of your mission. Make no mistake you will need to be quick to outwit your opponents, they are smart and will try to box you in. I wrote this game to prove that writing a game with scrolling scenery is possible even with the limited 6kB of RAM available. I had to compromise sound effects for features, I wanted multiple opponents, I wanted to be able to drop smoke bombs to trap the opponents but all this required memory so the sound effects had to take a back seat.

Dependencies:   mbed

main.cpp

Committer:
taylorza
Date:
2015-01-28
Revision:
0:d85c449aca6d
Child:
1:1b8125937f28

File content as of revision 0:d85c449aca6d:

#include "mbed.h"
#include "Constants.h"
#include "Canvas.h"
#include "GameEngine.h"
#include "Assets.h"
#include "GameScreen.h"

const uint16_t palette[] = 
{
    Color565::Black,
    Color565::Blue,
    Color565::Red,
    0xfe20
};

GameScreen gameScreen;

char buffer[10];
Timer timer;

CREATE_EFFECT(Sound_Intro)
    TONE(1, 10, 329, 0, 128, 0),    
END_EFFECT

//static OneBitSound g_sound(P0_18);

main()
{    
    GameScreenInstance = &gameScreen;
    
    Game::Surface.setPalette((uint16_t*)palette);
    Game::Surface.clearScreen(HUD_BACKGROUND);
    Game::Surface.setOrientation(LCD_ST7735::Rotate270, false);
    
//    g_sound.play(0, EFFECT(Sound_Intro));
            
    timer.start();
    int lastTime = timer.read_us();    
    int updateCounter = 0;    
    while(true)
    {          
        gameScreen.update();        
        gameScreen.draw();
        
        int time = timer.read_us();
        int duration = time - lastTime;
        lastTime = time;
        
        sprintf(buffer, "%d", duration);
        Game::Surface.drawString(font_ibm, 104, 120, buffer);
        
        ++updateCounter;
    }     
}