COOL GLASS OF WATER WITH ICE CUBES
Quote from Forum Archives on November 22, 1997, 4:39 pmPosted by: MattBeedle <MattBeedle@...>
Here is a code I did for fun.
Enjoy this COOL GLASS OF WATER WITH ICE CUBES!'----------------------------
COMPILE 1,_caseInsensitive
DIM MyGWorld&
DIM TheOldWorld&
DIM TheOldDevice&
DIM GrafPortT,GrafPortL,GrafPortB,GrafPortR_cubes = 3
DIM RECORD myCube
DIM yes
DIM xstep
DIM ystep
DIM dirX
DIM dirY
DIM whereX
DIM whereY
DIM offsetX
DIM offsetY
DIM sizeX
DIM sizeY
DIM speed
DIM END RECORD .myCube
DIM c.myCube (_cubes)
END GLOBALSWINDOW 1,"Matt's Cubes",(0,0)-(256,288),_docNoGrow
GrafPortT = 0
GrafPortL = 0
GrafPortR = 256
GrafPortB = 288
CALL GETGWORLD(TheOldWorld&,TheOldDevice&)
OSErr = FN NEWGWORLD(MyGWorld&,SYSTEM(_Crntdepth),GrafPortT,0,0,0)LOCAL FN drawCubes
LONG FN getX (myadd)
myVar = c.whereX(id)+.5*(SIN((myadd+c.xstep
(id))/360*2*ATN(1)<<2)*c.sizeX(id)/ATN(1)<<2)
'myVar = 256+.5*(SIN(myVar/360*2*ATN(1)<<2)*45/ATN(1)<<2)
END FN = myVarLONG FN getY (myadd)
myVar = c.whereY(id)+.5*(COS((myadd+c.ystep
(id))/360*2*ATN(1)<<2)*c.sizeY(id)/ATN(1)<<2)
'myVar = 128+.5*(COS(myVar/360*2*ATN(1)<<2)*45/ATN(1)<<2)
END FN = myVarCALL SETGWORLD(MyGWorld&,0)
PEN ,,,,0
BOX FILL 0,0 TO 256,288
COLOR _zBlue
BOX FILL 31,70 TO 199,255
COLOR _zYellow
PLOT 30,4 TO 60,250
PLOT 32,6 TO 62,252
COLOR _zBlack
PEN ,,,,19
FOR id = 1 TO _cubes
LONG IF c.yes (id)
IF c.dirX (id) = 1 THEN c.xstep (id) = c.xstep (id) - c.speed (id)
IF c.dirX (id) = 2 THEN c.xstep (id) = c.xstep (id) + c.speed (id)
IF c.dirY (id) = 1 THEN c.ystep (id) = c.ystep (id) - c.speed (id)
IF c.dirY (id) = 2 THEN c.ystep (id) = c.ystep (id) + c.speed (id)
oX = c.offsetX(id)
oY = c.offsetY(id)
aX = FN getX (0)
aY = FN getY (0)
bX = FN getX (90)
bY = FN getY (90)
cX = FN getX (180)
cY = FN getY (180)
dX = FN getX (270)
dY = FN getY (270)
PLOT aX,aY TO bX,bY TO cX,cY TO dX,dY TO aX,aY
PLOT aX+oX,aY+oY TO bX+oX,bY+oY TO cX+oX,cY+oY TO dX+oX,dY+oY TO
aX+oX,aY+oY
PLOT aX,aY TO aX+oX,aY+oY
PLOT bX,bY TO bX+oX,bY+oY
PLOT cX,cY TO cX+oX,cY+oY
PLOT dX,dY TO dX+oX,dY+oY
IF c.xstep (id) > 360 THEN c.xstep (id) = 1
IF c.ystep (id) > 360 THEN c.ystep (id) = 1
IF c.xstep (id) < 1 THEN c.xstep (id) = 360
IF c.ystep (id) < 1 THEN c.ystep (id) = 360
END IF
NEXT
BOX 30,30 TO 200,256
CALL SETGWORLD(TheOldWorld&,TheOldDevice&)
CALL COPYBITS(#MyGWorld& + 2,#TheOldWorld& +
2,GrafPortT,GrafPortT,_srcCopy,0)
END FNLOCAL FN makeCube
(myxstep,myystep,mydirX,mydirY,myspeed,myX,myY,mySizeX,mySizeY,myoffsetX,myoff
setY)
FOR id = 1 TO _cubes
LONG IF c.yes (id) = 0
c.yes (id) = 1
c.xstep (id) = myxstep
c.ystep (id) = myystep
c.dirX (id) = mydirX
c.dirY (id) = mydirY
c.x (id) = myXStep
c.speed (id) = myspeed
c.whereX (id) = myX
c.whereY (id) = myY
c.sizeX (id) = mySizeX
c.sizeY (id) = mySizeY
c.offsetX (id) = myoffsetX
c.offsetY (id) = myoffsetY
id = _cubes
END IF
NEXT
END FN'xstep
'ystep
'mydirX
'mydirY
'myspeed
'myX
'myY
'mySizeX
'mySizeY
'myoffsetX
'myoffsetY
FN makeCube (360,360,2,2,5,70 ,100,8 ,8 ,16,16)
FN makeCube (360,360,2,2,2,90 ,170,10,10,20,20)
FN makeCube (1 ,1 ,1,1,2,140,90 ,12,12,24,24)DO
FN drawCubes
UNTIL FN BUTTONCALL DISPOSEGWORLD (MyGWorld&)
Posted by: MattBeedle <MattBeedle@...>
Enjoy this COOL GLASS OF WATER WITH ICE CUBES!
'----------------------------
COMPILE 1,_caseInsensitive
DIM MyGWorld&
DIM TheOldWorld&
DIM TheOldDevice&
DIM GrafPortT,GrafPortL,GrafPortB,GrafPortR
_cubes = 3
DIM RECORD myCube
DIM yes
DIM xstep
DIM ystep
DIM dirX
DIM dirY
DIM whereX
DIM whereY
DIM offsetX
DIM offsetY
DIM sizeX
DIM sizeY
DIM speed
DIM END RECORD .myCube
DIM c.myCube (_cubes)
END GLOBALS
WINDOW 1,"Matt's Cubes",(0,0)-(256,288),_docNoGrow
GrafPortT = 0
GrafPortL = 0
GrafPortR = 256
GrafPortB = 288
CALL GETGWORLD(TheOldWorld&,TheOldDevice&)
OSErr = FN NEWGWORLD(MyGWorld&,SYSTEM(_Crntdepth),GrafPortT,0,0,0)
LOCAL FN drawCubes
LONG FN getX (myadd)
myVar = c.whereX(id)+.5*(SIN((myadd+c.xstep
(id))/360*2*ATN(1)<<2)*c.sizeX(id)/ATN(1)<<2)
'myVar = 256+.5*(SIN(myVar/360*2*ATN(1)<<2)*45/ATN(1)<<2)
END FN = myVar
LONG FN getY (myadd)
myVar = c.whereY(id)+.5*(COS((myadd+c.ystep
(id))/360*2*ATN(1)<<2)*c.sizeY(id)/ATN(1)<<2)
'myVar = 128+.5*(COS(myVar/360*2*ATN(1)<<2)*45/ATN(1)<<2)
END FN = myVar
CALL SETGWORLD(MyGWorld&,0)
PEN ,,,,0
BOX FILL 0,0 TO 256,288
COLOR _zBlue
BOX FILL 31,70 TO 199,255
COLOR _zYellow
PLOT 30,4 TO 60,250
PLOT 32,6 TO 62,252
COLOR _zBlack
PEN ,,,,19
FOR id = 1 TO _cubes
LONG IF c.yes (id)
IF c.dirX (id) = 1 THEN c.xstep (id) = c.xstep (id) - c.speed (id)
IF c.dirX (id) = 2 THEN c.xstep (id) = c.xstep (id) + c.speed (id)
IF c.dirY (id) = 1 THEN c.ystep (id) = c.ystep (id) - c.speed (id)
IF c.dirY (id) = 2 THEN c.ystep (id) = c.ystep (id) + c.speed (id)
oX = c.offsetX(id)
oY = c.offsetY(id)
aX = FN getX (0)
aY = FN getY (0)
bX = FN getX (90)
bY = FN getY (90)
cX = FN getX (180)
cY = FN getY (180)
dX = FN getX (270)
dY = FN getY (270)
PLOT aX,aY TO bX,bY TO cX,cY TO dX,dY TO aX,aY
PLOT aX+oX,aY+oY TO bX+oX,bY+oY TO cX+oX,cY+oY TO dX+oX,dY+oY TO
aX+oX,aY+oY
PLOT aX,aY TO aX+oX,aY+oY
PLOT bX,bY TO bX+oX,bY+oY
PLOT cX,cY TO cX+oX,cY+oY
PLOT dX,dY TO dX+oX,dY+oY
IF c.xstep (id) > 360 THEN c.xstep (id) = 1
IF c.ystep (id) > 360 THEN c.ystep (id) = 1
IF c.xstep (id) < 1 THEN c.xstep (id) = 360
IF c.ystep (id) < 1 THEN c.ystep (id) = 360
END IF
NEXT
BOX 30,30 TO 200,256
CALL SETGWORLD(TheOldWorld&,TheOldDevice&)
CALL COPYBITS(#MyGWorld& + 2,#TheOldWorld& +
2,GrafPortT,GrafPortT,_srcCopy,0)
END FN
LOCAL FN makeCube
(myxstep,myystep,mydirX,mydirY,myspeed,myX,myY,mySizeX,mySizeY,myoffsetX,myoff
setY)
FOR id = 1 TO _cubes
LONG IF c.yes (id) = 0
c.yes (id) = 1
c.xstep (id) = myxstep
c.ystep (id) = myystep
c.dirX (id) = mydirX
c.dirY (id) = mydirY
c.x (id) = myXStep
c.speed (id) = myspeed
c.whereX (id) = myX
c.whereY (id) = myY
c.sizeX (id) = mySizeX
c.sizeY (id) = mySizeY
c.offsetX (id) = myoffsetX
c.offsetY (id) = myoffsetY
id = _cubes
END IF
NEXT
END FN
'xstep
'ystep
'mydirX
'mydirY
'myspeed
'myX
'myY
'mySizeX
'mySizeY
'myoffsetX
'myoffsetY
FN makeCube (360,360,2,2,5,70 ,100,8 ,8 ,16,16)
FN makeCube (360,360,2,2,2,90 ,170,10,10,20,20)
FN makeCube (1 ,1 ,1,1,2,140,90 ,12,12,24,24)
DO
FN drawCubes
UNTIL FN BUTTON
CALL DISPOSEGWORLD (MyGWorld&)