Team Ai
Datasetpublic

hschumann2/TempleOS-Source-Code

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes847downloads
Bounce.txt49 linesDownload Raw Back to Graphics
1 2//Uses fixed-point-arithmetic.3 4I64 x[16],y[16],dx[16],dy[16];5 6U0 Init()7{8  I64 i;9  F64 theta;10  MemSet(x,0,sizeof(x));11  MemSet(y,0,sizeof(y));12  for (i=0;i<16;i++) {13    theta=Rand*2*pi;14    dx[i]=I32_MAX*Cos(theta);15    dy[i]=I32_MAX*Sin(theta);16  }17}18 19U0 Bounce()20{21  CDC *dc=DCAlias;22  I64 i,ch;23  Init;24  try {//Catch <CTRL-ALT-c>25    do {26      for (i=0;i<16;i++) {27        dc->color=i;28        GrPlot(dc,x[i].i32[1],y[i].i32[1]);29        x[i]+=dx[i];30        y[i]+=dy[i];31        if (!(0<=x[i]<Fs->pix_width<<32)) {32          x[i]-=dx[i];33          dx[i]=-dx[i];34        }35        if (!(0<=y[i]<Fs->pix_height<<32)) {36          y[i]-=dy[i];37          dy[i]=-dy[i];38        }39      }40      Yield;41    } while (!(ch=ScanChar) || (ch!=CH_SHIFT_ESC && ch!=CH_ESC));42  } catch43    PutExcept;44  DCFill(dc);45  DCDel(dc);46}47 48Bounce;49