2021-12-20 22:22:05 +00:00
|
|
|
|
#include "SBomber.h"
|
|
|
|
|
#include "MyTools.h"
|
|
|
|
|
#include "ScreenSingleton.h"
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <fstream>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <termios.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
|
|
|
|
int _kbhit()
|
|
|
|
|
{
|
|
|
|
|
static const int STDIN = 0;
|
|
|
|
|
static bool initialized = false;
|
|
|
|
|
|
|
|
|
|
if (!initialized)
|
|
|
|
|
{
|
|
|
|
|
// Use termios to turn off line buffering
|
|
|
|
|
termios term;
|
|
|
|
|
tcgetattr(STDIN, &term);
|
|
|
|
|
term.c_lflag &= ~ICANON;
|
|
|
|
|
tcsetattr(STDIN, TCSANOW, &term);
|
|
|
|
|
setbuf(stdin, NULL);
|
|
|
|
|
initialized = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int bytesWaiting;
|
|
|
|
|
ioctl(STDIN, FIONREAD, &bytesWaiting);
|
|
|
|
|
return bytesWaiting;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
|
{
|
2021-12-20 23:33:45 +00:00
|
|
|
|
MyTools::LoggerSingleton::getInstance().OpenLogFile("log.txt");
|
2021-12-20 22:22:05 +00:00
|
|
|
|
|
|
|
|
|
SBomber game;
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
game.TimeStart();
|
|
|
|
|
|
|
|
|
|
if (_kbhit())
|
|
|
|
|
{
|
|
|
|
|
game.ProcessKBHit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScreenSingleton::getInstance().ClrScr();
|
|
|
|
|
|
|
|
|
|
game.DrawFrame();
|
|
|
|
|
game.MoveObjects();
|
|
|
|
|
game.CheckObjects();
|
|
|
|
|
|
|
|
|
|
game.TimeFinish();
|
|
|
|
|
|
|
|
|
|
} while (!game.GetExitFlag());
|
2022-02-05 09:05:21 +00:00
|
|
|
|
game.AnimateScrolling();
|
2021-12-20 23:33:45 +00:00
|
|
|
|
MyTools::LoggerSingleton::getInstance().CloseLogFile();
|
2021-12-20 22:22:05 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|