REM ======================================================== REM scprtl20.DLL demonstration script. REM Simple Game REM (C) 1999 by Alex Vakulenko, http://www.vakcer.com/oberon REM ======================================================== #include "scprtl20.csi" ' Script private declarations DECLARE SUB BuildPreview GLOBAL ImageFile$ ' BMP image file to store previewa ImageFile$=GetTempFolder()+"demo_temp.bmp" GLOBAL Height&,Width&,Pos&,rx&,ry& Height&=140 ' Field height Width&=235 ' Field width Pos=Width\2 ' Pad position rx=25:ry=5 ' Pad size GLOBAL x&,y&,cx&,cy&,vx&,vy& cx&=10:cy&=10 ' Ball size vx&=5:vy&=-5 ' Ball speed x=Width/2:y=Height-ry-cy-2 ' Ball initial position ' ========== Main Dialog description BEGIN DIALOG OBJECT MainDialog 164, 130, "Arcanoid 2", SUB MainDlgFunc CANCELBUTTON 63, 109, 40, 14, .Cancel1 IMAGE 2, 3, 160, 89, .Preview HSLIDER 0, 95, 164, 11, .Slider END DIALOG '===== Dialog box even handler SUB MainDlgFunc(BYVAL ControlID%, BYVAL EventCode%) SELECT CASE EventCode CASE 0 BuildPreview ' Create preview MainDialog.SetTimer 50 ' Step time interval CASE 2 SELECT CASE ControlID CASE MainDialog.Slider.GETID() Pos&=MainDialog.Slider.GetValue() BuildPreview END SELECT CASE 5 e&=0 ' e<>0 if 'Beep' must be played if x+vx+cx>Width or x+vx<0 then vx=-vx:e=1 if y+vy<0 then vy=-vy:e=1 if y+vy+cy>Height-ry-2 then if (xPos+rx\2) then x=messagebox("You have missed the ball"+CHR(13)+"Do you want to try again?","You lost!",20) if x=6 then x=Width/2:y=Height-ry-cy-2 vx=5:vy=5 else MainDialog.CloseDialog 2 endif else e=1 endif vy=-vy endif x=x+vx y=y+vy if e then beep BuildPreview END SELECT END SUB '=========================== Main Script Body ===================================== ' Initialize all dialog controls MainDialog.Preview.SetStyle 288 MainDialog.Slider.SetMinRange 0 MainDialog.Slider.SetMaxRange Width MainDialog.Slider.SetIncrement 1 MainDialog.Slider.SetValue Pos DIALOG MainDialog ' Display dialog box STOP ' ======= Create preview of the selected font SUB BuildPreview BeginImage Width,Height,BLACK ' Create an empty image in memory ImageFillRect Pos-rx\2,Height-ry-2,Pos+rx\2,Height-2,RED ImageFillEllipse x,y,x+cx,y+cy,WHITE EndImage ImageFile$ ' Save the image to file and free memory MainDialog.Preview.SetImage ImageFile ' Display the image in dialog box IMAGE control END SUB