#include "graphics.h"
#include "bios.h"
#include "conio.h"
#include "stdlib.h"
#include "dos.h"
#define UP 0x4800
#define DOWN 0x5000
#define LEFT 0x4600
#define RIGHT 0x4d00
#define ESC 0x0016
#define VGA256 0x13
#define TEXT 0x03
int x,y,l,sxzy=0,zx=0,xx=5,yy=167;
int x1=5,y1=3,x3=0,y3=0,x4=0,y4=0;
int youlife=50,mylife=30;
int board[100][170];
unsigned char far *video_buff=(char far *)0xA0000000L;
void setvideomode(int mode)
{ union REGS inregs,outregs;
inregs.h.ah=0;
inregs.h.al=(unsigned char)mode;
int86(0x10,&inregs,&outregs);
}
void v_line(int y0,int y1,int x,unsigned int color)
{ unsigned int address,n,temp;
address=320*y0+x;
for(n=0;n<=y1-y0;n++)
{
if(y0>y1)
{
temp=y1;
y1=y0;
y0=temp;
}
video_buff[address]=color;
address+=320;
}
}
void h_line(int x0,int x1,int y,unsigned int color)
{ unsigned int address,n,temp;
address=320*y+x0;
for(n=0;n<=x1-x0;n++)
{
if(x0>x1)
{
temp=x1;
x1=x0;
x0=temp;
}
video_buff[address]=color;
address+=1;
}
}
void p_pixel(int x,int y,unsigned int color)
{ video_buff[y*320+x]=color;
}
void s_square(int x,int y,int side,int color)
{
h_line(x,x+side,y,color);
h_line(x,x+side,y+side,color);
v_line(y,y+side,x,color);
v_line(y,y+side,x+side,color);
}
void r_rectangle(int x1,int y1,int x2,int y2,int color)
{
h_line(x1,x2,y1,color);
h_line(x1,x2,y2,color);
v_line(y1,y2,x1,color);
v_line(y1,y2,x2,color);
}
void fillRectangle(int x1,int y1,int x2,int y2,int color)
{
int i;
for(i=y1;i<=y2;i++)
{
h_line(x1,x2,i,color);
}
}
void ground() /*畫外框*/
{ r_rectangle(104,20,207,190,7);
}
void delzx() /*每次出拳後,刪除拳頭*/
{ delay(1000);
s_square(x3,y3,5,0);
s_square(x3,y3-6,5,0);
x3=0;
y3=0;
}
void me() /*畫出自己*/
{ int cas=0;
if(sxzy==18432) /*如果按上鍵,就往上移動*/
{ yy-=5;
if(yy < y1+30)
yy+=5;
if(yy==12)
yy=17;
}
if(sxzy==20480) /*如果按下鍵,就往下移動*/
{ yy+=5;
if(yy==172)
yy=167;
}
if(sxzy==19200) /*如果按左鍵,就往左移動*/
{ xx--;
if(xx==-1)
xx=0;
}
if(sxzy==19712) /*如果按右鍵,就往右移動*/
{ xx++;
if(xx==13)
xx=12;
}
sxzy=0;
for(x=xx;x<5+xx;x++) /*給自己搭建骨架*/
{
if(x==xx) /*左手*/
{
y=167;
board[x][yy]=1;
if(zx==11386)
{
board[x][yy-12]=3;
board[x][yy-11]=3;
if((yy-11 < y1+30) && (xx>=x1 && xx<=x1+4))
youlife--;
cas=1;
zx=0;
}
x++;
}
if(x==xx+4) /*右手*/
{
y=167;
board[x][yy]=1;
if(zx==11640)
{
board[x][yy-12]=3;
board[x][yy-11]=3;
if((yy-11 < y1+30) && (xx+4<=x1+4 && xx+4>=x1))
youlife--;
cas=2;
zx=0;
}