|
|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 1428 (0x594)
Types: TextFile
Notes: UNIX file
Names: »sstars.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
└─⟦926b8033d⟧ UNIX Filesystem
└─⟦this⟧ »u/demo/slide/sstars.c«
#define MAXFARSTARS 100
#define MAXNEARSTARS 90
#define STARTX 508
#define STARTY 62
#define ENDX 700
#define ENDY 195
#define MAXX (ENDX-STARTX)
#define MAXY (ENDY-STARTY)
#define DX 20
#define DY 20
#define MD 5
#define MAXCOUNT 300
short count = 0;
struct STAR {
short x,y,dx,dy;
};
struct STAR s[MAXNEARSTARS];
space()
{
srand(14234);
sclear();
stars();
}
sclear()
{
register int x,y;
for(x = 0; x <= (MAXX/2); x++)
for(y = STARTY; y< ENDY; y++)
{
sp(STARTX+x,y,0);
sp(ENDX-x,y,0);
}
}
stars()
{
short i;
short x,y;
for(i = 0; i< MAXFARSTARS;i++)
{
x = irand(MAXX); y = irand(MAXY);
point(STARTX+x,STARTY+y);
}
for(i = 0; i<MAXNEARSTARS; i++)
{
getpnt(&s[i]);
point(STARTX+s[i].x, STARTY+s[i].y);
}
while(count++ < MAXCOUNT)
for(i = 0; i < MAXNEARSTARS; i++) {
x = s[i].x;
y = s[i].y;
s[i].x += s[i].dx;
s[i].y += s[i].dy;
if(inside(s[i].x, s[i].y)==0) {
getpnt(&s[i]);
}
point(STARTX+x,STARTY +y);
point(STARTX+x+1,STARTY+y);
point(STARTX+s[i].x,STARTY+s[i].y);
point(STARTX+s[i].x+1,STARTY+s[i].y);
}
}
getpnt(s)
struct STAR *s;
{
while(1) {
s->dx = (DX/2) - irand(DX);
s->dy = (DY/2) - irand(DY);
if((s->x == (MAXX/2))&& (s->y ==(MAXY/2))) continue;
s->x = (MAXX/2) + s->dx * MD;
s->y = (MAXY/2) + s->dy * MD;
if(inside(s->x,s->y)) break;
}
}
inside(x,y)
{
return((x > 0) && (x < MAXX) && (y > 0) && (y < MAXY));
}