Category : C Source Code
Archive   : LSPD05-2.ZIP
Filename : 044.C

 
Output of file : 044.C contained in archive : LSPD05-2.ZIP
/* Light Speed Reference Example Program */
/* Rectangle drawing */
#include "lspeed.h"
#include
#include

main()
{
/* Variables */
int lines[4][16], left_x_inc, right_x_inc, up_y_inc, down_y_inc;
unsigned char curline;

/* Set the graphics mode, register font */
set640x350();
registernicefont();

/* Seed the random numbers, set variables */
randomize();
left_x_inc=-5;
right_x_inc=5;
up_y_inc=-5;
down_y_inc=5;

/* Print the press a key message */
ega_writetext(220, 335, LS_YELLOW, LS_BLUE, NICE_FONT,
" Press a key to stop... ");

/* Set up some lines */
lines[0][0] = 320;
lines[1][0] = 170;
lines[2][0] = 320;
lines[3][0] = 170;
for (curline=1; curline<16; curline++)
{
lines[0][curline] = lines[0][curline-1]+left_x_inc;
lines[1][curline] = lines[1][curline-1]+up_y_inc;
lines[2][curline] = lines[2][curline-1]+right_x_inc;
lines[3][curline] = lines[3][curline-1]+down_y_inc;
}

/* Draw the lines */
for (curline=0; curline<16; curline++)
ega_putrectangle(lines[0][curline], lines[1][curline],
lines[2][curline], lines[3][curline], curline);
curline=15;

/* While there is no key... */
while (!kbhit())
{
curline++;

/* Erase the last rectangle */
ega_putrectangle(lines[0][curline&15], lines[1][curline&15],
lines[2][curline&15], lines[3][curline&15], 0);

/* Increment first point */
lines[0][curline&15] = lines[0][(curline-1)&15]+left_x_inc;
if (lines[0][curline&15]<0) /* Out of range? */
{
left_x_inc=random(11)+3;
lines[0][curline&15]=0;
}
if (lines[0][curline&15]>639) /* Out of range? */
{
left_x_inc=-10+random(11)-3;
lines[0][curline&15]=639;
}

/* Increment the second point */
lines[1][curline&15] = lines[1][(curline-1)&15]+up_y_inc;
if (lines[1][curline&15]<0) /* Out of range? */
{
up_y_inc=random(11)+3;
lines[1][curline&15]=0;
}
if (lines[1][curline&15]>334) /* Out of range? */
{
up_y_inc=-10+random(11)-3;
lines[1][curline&15]=334;
}

/* Increment the third point */
lines[2][curline&15] = lines[2][(curline-1)&15]+right_x_inc;
if (lines[2][curline&15]<0) /* Out of range? */
{
right_x_inc=random(11)+3;
lines[2][curline&15]=0;
}
if (lines[2][curline&15]>639) /* Out of range? */
{
right_x_inc=-10+random(11)-3;
lines[2][curline&15]=639;
}

/* Increment the last point */
lines[3][curline&15] = lines[3][(curline-1)&15]+down_y_inc;
if (lines[3][curline&15]<0) /* Out of range? */
{
down_y_inc=random(11)+3;
lines[3][curline&15]=0;
}
if (lines[3][curline&15]>334) /* Out of range? */
{
down_y_inc=-10+random(11)-3;
lines[3][curline&15]=334;
}
ega_putrectangle(lines[0][curline&15], lines[1][curline&15],
lines[2][curline&15], lines[3][curline&15], curline);

delay(15);
}

/* Get the key, exit */
getxch();
set80x25();
}


  3 Responses to “Category : C Source Code
Archive   : LSPD05-2.ZIP
Filename : 044.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/