#include <windows.h>
#include <stdio.h>
#include <time.h>
#include <iostream>
using namespace std;
#define CELL 20
#define ROWS 15
#define SCORE_LEVEL_INC 60
#define ID_TIMER 1
HWND hwnd; //保存窗口句柄
int insectx=0,insecty=0; //虫子坐标
int score=0; //分数
int level=0; //级数
int interval_unit=28; //随级数递增的时间间隔增量
int interval_base=350; //时间间隔基量
int old_interval; //保存当前的时间间隔,用于加速操作
bool isPause=false; //暂停标识
UINT timer_id=0; //保存计时器ID
char oldDirection=1;
char direction=0; //1上 2下 3左 4右
char newDirection=0;
class linkNode{
public:
int x,y;
linkNode *Next;
linkNode(int X=0,int Y=0) { Next=NULL; x=X; y=Y; } };
class Queue
{
public:
linkNode *First,*Last;
int lenth;
Queue() { First=Last=NULL; lenth=0; }
bool EQueue(int x,int y);
bool QQueue();
bool Find(int x,int y);
};
bool Queue::EQueue(int x,int y)
{
linkNode *p=new linkNode(x,y);
if(!p) { cerr<<"Memory allocation failure"<<endl; return false; }
p->Next=First;
First=p;
if(!First->Next) Last=First;
++lenth;
return true;
}
bool Queue::QQueue()
{
if(!Last) return false;
linkNode *p=First;
for(;p&&p->Next!=Last;p=p->Next);
delete Last;
if(p) { Last=p; Last->Next=NULL; }
else Last=NULL;
--lenth;
return true;
}
bool Queue::Find(int x,int y)