/* * CChess Copyright (C) 2006 wesley.wang lily.ru * wq1977@gmail.com rujingli@163.com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include "allegro.h" #include "cstdio" #ifndef WIN32 #include "pthread.h" #include #include #include #include #include #include #include #include #endif #define WIDTH 800 #define HEIGHT 600 class aihomegame { public: aihomegame(){done=false; buffer=NULL; page1=NULL; page2=NULL;active_page=NULL;UseFlip=false;}; virtual ~aihomegame(){}; virtual bool ProcInput(int keycode){ return false;}; virtual void Draw()=0; virtual void Update(){}; virtual bool Init(){return true;}; virtual void Quit(){}; void CommonProcInput(int keycode); bool CommonInit(); void CommonQuit(); void CommonDraw(); void Done() {done=true;}; bool IsDone() {return done;}; protected: bool done,UseFlip; BITMAP *buffer; BITMAP *page1, *page2; BITMAP *active_page; }; #define AIHOME_START(x) int main(){ \ x game;\ game.CommonInit();\ while (!game.IsDone()){ \ while (keypressed()) {\ game.CommonProcInput(readkey()); \ } \ game.Update();\ game.CommonDraw(); \ }\ game.CommonQuit();\ return 0;\ }\ END_OF_MAIN()