home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frostbyte's 1980s DOS Shareware Collection
/
floppyshareware.zip
/
floppyshareware
/
USCX
/
CROBJ2.ZIP
/
RND120.R
< prev
next >
Wrap
Text File
|
1987-09-02
|
2KB
|
119 lines
/***************************************
ROUND Robot Ver.1.20 (RND120.R)
Copyright (C) 1987 AkihikoSugawara
pcs26423
Aug 29 1987
***************************************/
int dist, deg, rot; /* current */
int pdeg, pdist; /* previoua */
int unit; /* rot unit */
int time; /* rot time */
int x,y; /* location */
main()
{
deg = 0;
pdeg = 0;
pdist = 0;
rot = 0;
time = 0;
unit = 90;
center();
while(1){
x = loc_x();
y = loc_y();
if( ( x > 900 ) | ( x < 100 ) | ( y > 900 ) | ( y < 100 ) )
center();
else {
shoot();
move();
}
}
}
move() /* move robot */
{
int near;
near = scan( deg, 10 );
if( ( near > 0 ) & ( near < 100 ) )
{
while( speed() > 50 )
drive( 0, 0 );
rot = deg + 135;
time = 0;
}
else if( time == 2 )
{
while( speed() > 50 )
drive( 0, 0 );
time = 0;
}
else time += 1;
if( speed() <= 50 )
{
drive( rot, 100 );
rot += unit;
}
}
shoot() /* shoot cannon */
{
int count;
count = 0;
while( ( dist = scan( deg, 5 ) ) == 0 )
{
deg += 10;
count += 1;
}
if( count > 5 )
cannon( deg, dist );
else cannon( deg + ( deg - pdeg ) / 2, dist + ( dist - pdist ) / 2 );
pdeg = deg;
pdist = dist;
deg -= 25;
}
center() /* move robot to center of the field */
{
while( speed() > 0 )
drive( 0, 0 );
while( loc_x() < 480 )
{
drive( 0, 100 );
shoot();
}
while( speed() > 5 )
drive( 0, 0 );
while(loc_y() < 480 )
{
drive( 90, 100 );
shoot();
}
while(speed() > 5 )
drive( 0, 0 );
while(loc_x() > 520 )
{
drive( 180, 100 );
shoot();
}
while(speed() > 5 )
drive( 0, 0 );
while(loc_y() > 520 )
{
drive( 270, 100 );
shoot();
}
while(speed() > 5 )
drive( 0, 0 );
}
/* end of program */