|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
#include <list>
|
|
|
|
|
class Snake
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
const int MinSpeed = 1; //<2F>ߵ<EFBFBD><DFB5><EFBFBD>С<EFBFBD>ٶ<EFBFBD>
|
|
|
|
|
const int MaxSpeed = 25; //<2F>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
|
|
|
|
const int OrgSpeed = 20; //<2F>ߵ<EFBFBD>ԭʼ<D4AD>ٶ<EFBFBD>
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int m_len; //<2F>ߵij<DFB5><C4B3><EFBFBD>
|
|
|
|
|
int m_speed; //<2F>ߵ<EFBFBD><DFB5>ٶ<EFBFBD>
|
|
|
|
|
Dir m_direction; //<2F>ߵķ<DFB5><C4B7><EFBFBD>
|
|
|
|
|
Point m_tail; //<2F><><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD>ڵ㣬<DAB5><E3A3AC>Ҫ<EFBFBD><D2AA><EFBFBD>ڳ<EFBFBD>ʳ<EFBFBD><CAB3>
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
Snake();
|
|
|
|
|
Snake(int x);
|
|
|
|
|
std::list<Point> m_snakelist; //<2F>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int getLen(); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|
|
|
|
int getSpeed(); //<2F><>ȡ<EFBFBD>ٶ<EFBFBD>
|
|
|
|
|
Dir getDirection(); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|
|
|
|
bool setSpeed(int speed); //<2F><><EFBFBD><EFBFBD><EFBFBD>ٶȣ<D9B6><C8A3><EFBFBD><EFBFBD>óɹ<C3B3><C9B9><EFBFBD><EFBFBD><EFBFBD>true
|
|
|
|
|
|
|
|
|
|
void Move(); //<2F>ƶ<EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
void EatFood(); //<2F><>ʳ<EFBFBD><CAB3>
|
|
|
|
|
void ChangeDir(Dir dir); //<2F>ı䷽<C4B1><E4B7BD>
|
|
|
|
|
void Dead(); //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
bool ColideWall(int left, int top, int right, int bottom); //<2F><>ײ<EFBFBD><D7B2>ǽ
|
|
|
|
|
bool ColideSnake(); //<2F><>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
bool ColideSnake2(Snake& m_snake2); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
bool ColideFood(Point point); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʳ<EFBFBD><CAB3>
|
|
|
|
|
|
|
|
|
|
void DrawSnake(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void DrawSnake2(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2
|
|
|
|
|
void DrawSnakeHead(Point pos); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
|
|
|
|
void DrawSnakeNode(Point pos); //<2F><><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void DrawSnakeHead2(Point pos); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ2
|
|
|
|
|
void DrawSnakeNode2(Point pos); //<2F><><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2
|
|
|
|
|
std::list<Point> GetSnakeAllNode();
|
|
|
|
|
};
|