Code:
#pragma inline
#include <dos.h>
#include <conio.h>
void setgfx()
{
_AL = 19;
_AH = 0;
geninterrupt(0x10);
}
void settxt()
{
_AL = 3;
_AH = 0;
geninterrupt(0x10);
}
void plotxyc(int x, int y, int c)
{
_CX = x;
_DX = y;
_AL = c;
_AH = 0x0c;
geninterrupt(0x10);
}
void plotcrossbow(int xpos, int ypos, int cpos)
{
int bow[2][12][12] =
{
{
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
},
{
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 12, 12, 12, 12, 0, 0, 0, 0},
{ 0, 0, 0, 12, 0, 0, 0, 0, 12, 0, 0, 0},
{ 0, 0, 0, 12, 0, 0, 0, 0, 12, 0, 0, 0},
{ 0, 0, 12, 0, 12, 0, 0, 12, 0, 12, 0, 0},
{ 0, 0, 12, 0, 0, 14, 14, 0, 0, 12, 0, 0},
{ 0, 0, 12, 0, 0, 14, 14, 0, 0, 12, 0, 0},
{ 0, 0, 12, 0, 12, 0, 0, 12, 0, 12, 0, 0},
{ 0, 0, 0, 12, 0, 0, 0, 0, 12, 0, 0, 0},
{ 0, 0, 0, 12, 0, 0, 0, 0, 12, 0, 0, 0},
{ 0, 0, 0, 0, 12, 12, 12, 12, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}
};
int xp, yp;
for(xp = 0; xp < 12; xp++)
{
for(yp = 0; yp < 12; yp++)
{
plotxyc(xpos+xp, ypos+yp, bow[cpos][yp][xp]);
}
}
}
int main()
{
int xpoint, ypoint, cpoint, rcpoint;
int xdot, ydot, bdot, cdot, ddot;
int xbow, ybow, cbow;
int left, right, bottom, top;
int xsight, ysight, setsight = 0;
char keypress;
setgfx();
left = 12;
right = 320-24;
bottom = 200-24;
top = 12;
xbow = right;
ybow = bottom;
cbow = 1;
xpoint = 0;
ypoint = 100;
cpoint = 1;
rcpoint = 15;
xdot = 0;
ydot = 80;
bdot = 0;
cdot = 14;
ddot = 0;
keypress = '';
start:;
xpoint++;
if(xpoint >= 320)
{
xpoint = 0;
}
cpoint++;
if(cpoint >= 15)
{
cpoint = 1;
}
rcpoint--;
if(rcpoint <= 1)
{
rcpoint = 15;
}
plotxyc(xdot, ydot, cdot);
ddot++;
if(ddot > 24)
{
ddot = 0;
plotxyc(xdot, ydot, bdot);
xdot++;
if(xdot >= 320)
{
xdot = 0;
}
}
plotxyc(xpoint, ypoint, cpoint);
plotxyc(320-xpoint, ypoint+24, rcpoint);
if(kbhit())
{
keypress = getch();
if(keypress == 'q')
{
goto exitprg;
}
if(keypress == 'a')
{
xbow--;
if(xbow < left)
{
xbow = left;
}
}
if(keypress == 'd')
{
xbow++;
if(xbow > right)
{
xbow = right;
}
}
if(keypress == 's')
{
ybow++;
if(ybow > bottom)
{
ybow = bottom;
}
}
if(keypress == 'w')
{
ybow--;
if(ybow < top)
{
ybow = top;
}
}
}
if(keypress == ' ')
{
if(setsight == 0)
{
setsight = 1;
xsight = xbow;
ysight = ybow;
}
}
if(setsight == 1)
{
ysight++;
if(ysight > bottom)
{
setsight = 0;
plotcrossbow(xsight, ysight, 0);
}
else
{
plotcrossbow(xsight, ysight, cbow);
}
}
if(keypress != '')
{
keypress = '';
plotcrossbow(xbow, ybow, cbow);
}
goto start;
exitprg:;
getch();
settxt();
return(0);
}
Once again, I apologize for my informal style. It's a bad habit since 30 years ago. It's like my parents just has to have a pizza from time to time haha.