This is a code, in 16 total lines, to create a rotating cube. As it rotates, the colors change with the rotation. Rotation control keys are the arrow keys and the w and s keys. The d key turns on a "random"
feature - the cube goes to a random position and color. In addition, the background is inverted (I think it is inverted - please confirm if I am right or wrong, and if I am wrong, please give the code and/or equation to do it.)
Here is the code:
sync on
sync rate 60
make object cube 1,10
xrot=0:yrot=0:zrot=0:r=255:g=255:b=255:done=0:rndmx=0:rndmy=0:rndmz=0
do
if downkey()=1 : xrotate object 1,xrot-2:xrot=xrot-2:r=r+2:rndm=0:ENDIF:if upkey()=1 : xrotate object 1,xrot+2:xrot=xrot+2:r=r-2:rndm=0:ENDIF
if leftkey()=1 : yrotate object 1,yrot-2:yrot=yrot-2:g=g+2:rndm=0:ENDIF:if rightkey()=1 : yrotate object 1,yrot+2:yrot=yrot+2:g=g-2:rndm=0:ENDIF
if keystate(17)=1 : zrotate object 1,zrot-2:zrot=zrot-2:b=b+2:rndm=0:ENDIF:if keystate(31)=1 : zrotate object 1,zrot+2:zrot=zrot+2:b=b-2:rndm=0:ENDIF
if keystate(32)=1 then rndm=1
if keystate(30)=1 then rndm=0
if rndm=1 then done=done+1
if rndm=1 and done>100 then xrotate object 1,rnd(360):yrotate object 1,rnd(360):zrotate object 1,rnd(360):r=rnd(255):g=rnd(255):b=rnd(255):done=0
if r>255 then r=r-255 :if g>255 then g=g-255 :if b>255 then b=b-255:if r<0 then r=0:if g<0 then g=0:if b<0 then b=0
color backdrop rgb(r+255/2,g+255/2,b+255/2):color object 1,rgb(r,g,b)
sync
LOOP