#include "FS.h"
#include "SPIFFS.h"
SoundGenerator soundGenerator;
SquareWaveformGenerator swg;
#include "controllers.h"
#include "gameimages.h"
#define JOY_LEFT 13
#define JOY_RIGHT 2
#define JOY_DOWN 14
#define JOY_FIRE 12
GameController cNone = GameController(0, MODE_NONE);
GameControllerMouse cMouse;
GameControllerJoystick cJoystick;
GameControllerKeys cKeysArrows;
GameControllerKeys cKeysASTF;
GameControllerKeys cKeysQAOP;
GameController *gameControllers[] = { &cNone, &cMouse, &cJoystick, &cKeysArrows, &cKeysASTF, &cKeysQAOP };
#include "support.h"
#include "soundchip.h"
#include "score.h"
#include "race.h"
#include "menu.h"
void setup()
{
Serial.begin(115200);
Serial.println( "ClassicRacer by Carles Oriol 2020");
PS2Controller.
begin(PS2Preset::KeyboardPort0_MousePort1, KbdMode::GenerateVirtualKeys);
cMouse = GameControllerMouse (1);
cJoystick = GameControllerJoystick (2, JOY_FIRE, JOY_DOWN, JOY_LEFT, JOY_RIGHT, JOY_FIRE );
VGAController.begin();
VGAController.moveScreen(-6, 0);
soundGenerator.setVolume(127);
soundGenerator.play(true);
soundGenerator.attach( &swg);
initNumbers();
loadScore();
highScore = top[0].points;
fastest = top[0].timesec;
lowestTopScore = top[HIGHSCORE_ITEMS-1].points;
}
void loop()
{
static int exitv = 0;
static int editItem = -1;
playSoundTuc();
waitNoButton(250);
if ( exitv == 2 )
{
Score score;
score.editItem = editItem;
score.start();
editItem = -1;
exitv = score.exitValue;
}
else if ( exitv == 1 )
{
Race race;
race.players[0].controller = gameControllers[playercontrol[0]];
race.players[1].controller = gameControllers[playercontrol[1]];
race.start();
exitv = 2;
if( exitv == 2 )
{
ScoreCard *psc = addScore( "AAA",
race.players[race.winner].points,
race.winnerTime,
race.players[race.winner].cars,
race.players[race.winner].controller->id,
(gameControllers[playercontrol[0]]->id!=0?1:0)+(gameControllers[playercontrol[1]]->id!=0?1:0));
if( psc != NULL )
{
editItem = getScoreIndex( psc );
saveScore();
highScore = top[0].points;
fastest = top[0].timesec;
lowestTopScore = top[HIGHSCORE_ITEMS-1].points;
}
}
}
else
{
Menu menu;
menu.start();
exitv = menu.exitValue;
}
}
A class with a set of drawing methods.
static void begin(gpio_num_t port0_clkGPIO, gpio_num_t port0_datGPIO, gpio_num_t port1_clkGPIO=GPIO_UNUSED, gpio_num_t port1_datGPIO=GPIO_UNUSED)
Initializes PS2 device controller.
The PS2 device controller class.
Represents the VGA bitmapped controller.
This file is the all in one include file. Application can just include this file to use FabGL library...