Files
TempleOS-Rijn/LT/DEMO/Graphics/Sprite2.CPZ
T
2018-09-08 21:45:17 +02:00

60 lines
1.2 KiB
Plaintext

//This demo uses grbase2, so you must add a
//update_window routine because grbase2 is not
//persistent. (It gets erased each update by
//the system.)
$PI,"<PI 1>",2$
GrBitMap *base=GrNew(grbase2);
void DrawIt()
{
U1 *img=$IB,"<IB 1>",2$;
//Without this, the text of other windows below
//would appear.
ClearWindowText;
//We can change the pen width because it was not
//define in CTRL-R.
base->pen_width=2;
GrElemsPlot(base,0,0,0,img,GR_BLACK);
}
void Sprite2()
{
double theta=0,phi=0;
I8 *r1,*r2;
U8 sc,ch;
U4 *old_update_window=Fs->update_window;
Fs->update_window=&DrawIt;
base->x=200;
base->y=200;
base->flags|=BMF_TRANSFORMATION;
while (TRUE) {
if (ScanChar(&sc,&ch)) break;
r1=GrTheta(theta);
r2=GrPhi(phi);
Free(base->r);
//This combines the two rotations.
base->r=GrMulMat(r1,r2);
Free(r1);
Free(r2);
Sleep(40);
theta+=pi2/100;
phi +=pi2/130;
}
Fs->update_window=old_update_window;
}
Sprite2;®#øÿÿÿ#øÿÿÿ1 1 ""***þÿÿÿþÿÿÿ*