Skip to content

Instantly share code, notes, and snippets.

@entozoon
Created November 24, 2016 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save entozoon/114ef4739f24d82e218343871314ccd8 to your computer and use it in GitHub Desktop.
Save entozoon/114ef4739f24d82e218343871314ccd8 to your computer and use it in GitHub Desktop.
Pointy Prism - RobotC Lego NXT code
void makeCircle(int _cx,int _cy,int _rad) {
int l=_cx-_rad;
int r=_cx+_rad;
int u=_cy+_rad;
int d=_cy-_rad;
nxtFillEllipse (l, u,r, d);
}
void eraseCircle(int _cx,int _cy,int _rad) {
int l=_cx-_rad;
int r=_cx+_rad;
int u=_cy+_rad;
int d=_cy-_rad;
nxtEraseEllipse (l, u,r, d);
}
task main () {
// 4th line ~ 8 lines, 0-7.
nxtDisplayString (4," Hello World !");
wait1Msec (100);
int cx,cy,rad,x,y,cxx,cyy;
int flop;
x=0;
y=0;
while (1) {
// if (cxx>3 || cxx<-3){
eraseDisplay();
cx=50;
cy=32;
rad=40;
flop=0;
while(rad>0) {
makeCircle(cx,cy,rad);
if (rad==30)wait1Msec (10);
if (rad==20)wait1Msec (10);
if (rad==2)wait1Msec (100);
rad-=1;
if (flop==1){
cy+=cyy;}
eraseCircle(cx,cy,rad);
rad-=1;
if (flop==2){flop=0;}
if (flop==1){flop=2;}
if (flop==0){
cx+=cxx;
flop=1;}
}
x+=8;
y+=6;
cxx=5*sinDegrees(x);
cyy=5*cosDegrees(y);
//nxtDisplayBigStringAt (29 ,41 ,(string)x);
wait1Msec (10);
}
//nxtSetPixel(x,y);
wait1Msec (1000);
nxtDisplayBigStringAt (29 ,41 ,"Boo!");
wait1Msec (8000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment