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

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

main()
{
/* Variables */
int lines[6][16], first_x_inc, second_x_inc, first_y_inc;
int second_y_inc, third_x_inc, third_y_inc;
unsigned char curline;

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

/* Seed the random numbers, set variables */
randomize();
first_x_inc=0;
second_x_inc=2;
third_x_inc=-2;
first_y_inc=-2;
second_y_inc=2;
third_y_inc=2;

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

/* Set first some lines */
lines[0][0] = 320;
lines[1][0] = 170;
lines[2][0] = 320;
lines[3][0] = 170;
lines[4][0] = 320;
lines[5][0] = 170;

for (curline=1; curline<16; curline++)
{
lines[0][curline] = lines[0][curline-1]+first_x_inc;
lines[1][curline] = lines[1][curline-1]+first_y_inc;
lines[2][curline] = lines[2][curline-1]+second_x_inc;
lines[3][curline] = lines[3][curline-1]+second_y_inc;
lines[4][curline] = lines[4][curline-1]+third_x_inc;
lines[5][curline] = lines[5][curline-1]+third_y_inc;
}

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

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

/* Erase the last triangle */
ega_puttriangle(lines[0][curline&15], lines[1][curline&15],
lines[2][curline&15], lines[3][curline&15],
lines[4][curline&15], lines[5][curline&15], 0);

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

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

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

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

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

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

/* Draw the new triangle */
ega_puttriangle(lines[0][curline&15], lines[1][curline&15],
lines[2][curline&15], lines[3][curline&15],
lines[4][curline&15], lines[5][curline&15],
curline);

delay(5);
}

/* Exit the program */
getxch();
set80x25();
}



  3 Responses to “Category : C Source Code
Archive   : LSPD05-2.ZIP
Filename : 047.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/