worm2.h

来自「一个小游戏」· C头文件 代码 · 共 54 行

H
54
字号
//Worm2.h

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>

#define  UP        1
#define  DOWN      3
#define  LEFT      4
#define  RIGHT     2
#define  AHEAD     0
#define  STEP      3
#define  COLOR     14
#define  BACKCOLOR 0
#define  BEGIN     20

extern int grass=BEGIN;


class worm
{
int x;
int y;
float life;
int steps;
float left,right;
float direction;
int color;

public:
worm *pre,*next;
worm(int x1=100,int y1=100,float energy=200,float lef=33.33,float rig=33.33)
{
x=x1;
y=y1;
life=energy/2;
left=lef-((float)random(lef/3*100))/100+lef/6;
right=rig-((float)random(rig/3*100))/100+rig/6;
direction=random(4)+1;
steps=0;
}

float go();
int eat();
void bear();
void die();
~worm(){}
};

float worm::go()
{
int direct;
setcolor(BACKCOLOR);
outtextxy(x,y,"

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?