Author Topic: ScriptBasic SokoMouse Game  (Read 2574 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
ScriptBasic SokoMouse Game
« on: February 19, 2013, 11:37:05 AM »

« Last Edit: March 09, 2013, 11:28:29 AM by JRS »

Offline John

  • Forum Support / SB Dev
  • Posts: 2999
    • ScriptBasic Open Source Project
Re: ScriptBasic SokoMouse Game
« Reply #1 on: March 07, 2013, 08:49:51 PM »
I was able to convert the SokoMouse game over to DLLC as my first round of testing.

Note: I'm using the Windows sound API and not Bass. I'm using my SB routine to load the maps. The modules folder in the zip contains the DLLC.dll that needs to go in the ScriptBasic modules folder. You can run the SokoMouse game from where ever.

Update (b2) - I had missed a couple SW function definitions in the sw.inc file I wasn't using in the game. I also change SM.sbx so the number of moves shows first before the game ending wave file is played. The # of moves text is no longer refreshed 60 times a second without purpose. I'm still picking out areas of the game that are doing more work than they should.



SM.sbx
Code: OxygenBasic
  1. ' ScriptBasic SokoMouse
  2.  
  3. INCLUDE "sw.inc"
  4.  
  5. SUB Initialize
  6.   SW_DrawBmp p1, 0, 0, 640, 480, 0
  7.   SW_BmpText fo, 200, 8, "SokoMouse", 24, 24
  8.   zA = 0
  9.   Notified = FALSE
  10.   CALL ShowLevel
  11.   FOR bc = 0 TO 299
  12.     xBox[bc] = 0
  13.     yBox[bc] = 0
  14.     rBox[bc] = 0
  15.     zBox[bc] = 0
  16.     iBox[bc] = 0
  17.   NEXT
  18.   zR = 0
  19.   vR = 0
  20.   pHead = 3
  21.   Ready = 0
  22.   sl = 0
  23.   cV = 0
  24.   cR = 0
  25.   Steps = 0
  26.   RasReg = 0
  27.   KeyR = 0
  28.   KeyL = 0
  29.   KeyU = 0
  30.   KeyD = 0
  31.   BoxRas = 0
  32.   Turn = 1
  33.   zTurn = 0
  34. END SUB
  35.  
  36. SUB LoadMaps
  37.   SW_LoadBytes "Maps/Map" & lev & "-1.bin", Map1
  38.   SW_LoadBytes "Maps/Map" & lev & "-2.bin", Map2
  39.   SW_LoadBytes "Maps/Map" & lev & "-3.bin", Map3
  40. END SUB  
  41.  
  42. SUB ShowLevel
  43.   SW_Sprite s8, 480, 420, zA
  44.   SW_Sprite s9, 576, 420, zA
  45.   SW_BmpText fo, 520, 420, "0" & lev, 24, 24
  46.   vA += 1
  47.   IF vA = 8 THEN
  48.     vA = 0
  49.     zA = zA + 1
  50.     IF zA = 4 THEN zA = 0
  51.   END IF
  52. END SUB
  53.  
  54. SUB ShowMaps
  55.   FOR icx = 0 TO 14
  56.     FOR idx = 0 TO 19
  57.       ibx = icx * 20 + idx
  58.       IF ASC(Map1[ibx]) = 3 THEN SW_Sprite s1, idx * 32, icx * 32, 3
  59.       IF ASC(Map3[ibx]) = 2 THEN SW_Sprite s1, idx * 32, icx * 32, 2
  60.       IF ASC(Map2[ibx]) = 5 THEN SW_Sprite s2, idx * 32, icx * 32, zR
  61.     NEXT
  62.   NEXT
  63.   vR += 1
  64.   IF vR = 10 THEN
  65.     vR = 0
  66.     zR += 1
  67.   END IF
  68.   IF zR = 4 THEN zR = 0
  69. END SUB
  70.  
  71. SUB FindHead
  72.   FOR icx = 0 TO 14
  73.     FOR idx = 0 TO 19
  74.       ibx = icx * 20 + idx
  75.       IF ASC(Map3[ibx]) = 6 THEN
  76.         xHead = idx * 32
  77.         yHead = icx * 32
  78.         rHead = 0
  79.         zHead = 0
  80.         EXIT SUB
  81.       END IF
  82.     NEXT
  83.   NEXT
  84. END SUB
  85.  
  86. SUB AllDone
  87.   IF Ready >= 1 THEN EXIT SUB
  88.   FOR icx = 0 TO 14
  89.     FOR idx = 0 TO 19
  90.       ibx = icx * 20 + idx
  91.       IF ASC(Map2[ibx]) = 5 AND ASC(Map3[ibx]) <> 4 THEN
  92.         EXIT SUB
  93.       END IF
  94.     NEXT
  95.   NEXT
  96.   Ready = 2
  97.   RasReg = 1
  98.   Turn = 0
  99.   pHead = 0
  100.   rTurn = SW_Rnd(1, 2)
  101.   xTurn = xHead
  102.   yTurn = yHead
  103. END SUB
  104.  
  105. SUB TurnHead
  106.   IF Turn > 0 THEN EXIT SUB
  107.   IF rTurn = 1 THEN
  108.     SW_Sprite s6, xTurn, yTurn, zTurn
  109.   ELSE IF rTurn = 2 THEN
  110.     SW_Sprite s7, xTurn, yTurn, zTurn
  111.   END IF
  112.   zTurn = zTurn + 1
  113.   IF zTurn = 64 THEN zTurn = 0
  114. END SUB
  115.  
  116. SUB FlashBox
  117.   FOR icx = 0 TO 14
  118.     FOR idx = 0 TO 19
  119.       ibx = icx * 20 + idx
  120.       IF ASC(Map2[ibx]) = 5 AND ASC(Map3[ibx]) = 4 THEN
  121.         SW_Sprite s4, idx * 32, icx * 32, cR
  122.       END IF
  123.     NEXT
  124.   NEXT
  125.   cV += 1
  126.   IF cV = 10 THEN
  127.     cV = 0
  128.     cR += 1
  129.   END IF
  130.   IF cR = 4 THEN cR = 0
  131. END SUB
  132.  
  133. SUB ScanBoxes
  134.   IF BoxRas > 0 THEN EXIT SUB
  135.   FOR icx = 0 TO 14
  136.     FOR idx = 0 TO 19
  137.       ibx = icx * 20 + idx
  138.       IF ASC(Map3[ibx]) = 4 THEN
  139.         iBox[ibx] = 1
  140.         xBox[ibx] = idx * 32
  141.         yBox[ibx] = icx * 32
  142.         rBox[ibx] = 0
  143.       END IF
  144.     NEXT
  145.   NEXT
  146. END SUB
  147.  
  148. SUB ShowBoxes
  149.   FOR ibx = 20 TO 280
  150.     IF iBox[ibx] = 1 AND rBox[ibx] = 0 THEN
  151.       SW_Sprite s1, xBox[ibx], yBox[ibx], 4
  152.     ELSE IF iBox[ibx] = 1 AND rBox[ibx] = 1 THEN
  153.       xBox[ibx] = xBox[ibx] + 2
  154.       SW_Sprite s1, xBox[ibx], yBox[ibx], 4
  155.       zBox[ibx] = zBox[ibx] + 2
  156.       IF zBox[ibx] = 32 THEN
  157.         zBox[ibx] = 0
  158.         iBox[ibx] = 0
  159.         icx = (yBox[ibx] * 20 + xBox[ibx]) / 32
  160.         Map3[icx] = CHR(4)
  161.       END IF
  162.     ELSE IF iBox[ibx] = 1 AND rBox[ibx] = 2 THEN
  163.       xBox[ibx] = xBox[ibx] - 2
  164.       SW_Sprite s1, xBox[ibx], yBox[ibx], 4
  165.       zBox[ibx] = zBox[ibx] + 2
  166.       IF zBox[ibx] = 32 THEN
  167.         zBox[ibx] = 0
  168.         iBox[ibx] = 0
  169.         icx = (yBox[ibx] * 20 + xBox[ibx]) / 32
  170.         Map3[icx] = CHR(4)
  171.       END IF
  172.     ELSE IF iBox[ibx] = 1 AND rBox[ibx] = 3 THEN
  173.       yBox[ibx] = yBox[ibx] - 2
  174.       SW_Sprite s1, xBox[ibx], yBox[ibx], 4
  175.       zBox[ibx] = zBox[ibx] + 2
  176.       IF zBox[ibx] = 32 THEN
  177.         zBox[ibx] = 0
  178.         iBox[ibx] = 0
  179.         icx = (yBox[ibx] * 20 + xBox[ibx]) / 32
  180.         Map3[icx] = CHR(4)
  181.       END IF
  182.     ELSE IF iBox[ibx] = 1 AND rBox[ibx] = 4 THEN
  183.       yBox[ibx] = yBox[ibx] + 2
  184.       SW_Sprite s1, xBox[ibx], yBox[ibx], 4
  185.       zBox[ibx] = zBox[ibx] + 2
  186.       IF zBox[ibx] = 32 THEN
  187.         zBox[ibx] = 0
  188.         iBox[ibx] = 0
  189.         icx = (yBox[ibx] * 20 + xBox[ibx]) / 32
  190.         Map3[icx] = CHR(4)
  191.       END IF
  192.     END IF
  193.   NEXT
  194. END SUB
  195.  
  196. SUB ScanHead
  197.   IF RasReg > 0 THEN EXIT SUB
  198.   idx = xHead / 32
  199.   icx = yHead / 32
  200.   ibx = icx * 20 + idx
  201.   IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_right) AND ASC(Map3[ibx + 1]) = 4 AND ASC(Map3[ibx + 2]) = 0 AND KeyR = 0 THEN
  202.     Map3[ibx] = CHR(0)
  203.     Map3[ibx + 1] = CHR(6)
  204.     rHead = 1
  205.     pHead = 1
  206.     BoxRas = 0
  207.     xBox[ibx + 1] = xHead + 32
  208.     yBox[ibx + 1] = yHead
  209.     rBox[ibx + 1] = 1
  210.     iBox[ibx + 1] = 1
  211.     Steps += 1
  212.     SW_PlayWav w2
  213.   ELSE IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_left) AND ASC(Map3[ibx - 1]) = 4 AND ASC(Map3[ibx - 2]) = 0 AND KeyL = 0 THEN
  214.     Map3[ibx] = CHR(0)
  215.     Map3[ibx - 1] = CHR(6)
  216.     rHead = 2
  217.     pHead = 2
  218.     BoxRas = 0
  219.     xBox[ibx - 1] = xHead - 32
  220.     yBox[ibx - 1] = yHead
  221.     rBox[ibx - 1] = 2
  222.     iBox[ibx - 1] = 1
  223.     Steps += 1
  224.     SW_PlayWav w2
  225.   ELSE IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_up) AND ASC(Map3[ibx - 20]) = 4 AND ASC(Map3[ibx - 40]) = 0 AND KeyU = 0 THEN
  226.     Map3[ibx] = CHR(0)
  227.     Map3[ibx - 20] = CHR(6)
  228.     rHead = 3
  229.     pHead = 3
  230.     BoxRas = 0
  231.     xBox[ibx - 20] = xHead
  232.     yBox[ibx - 20] = yHead - 32
  233.     rBox[ibx - 20] = 3
  234.     iBox[ibx - 20] = 1
  235.     Steps += 1
  236.     SW_PlayWav w2
  237.   ELSE IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_down) AND ASC(Map3[ibx + 20]) = 4 AND ASC(Map3[ibx + 40]) = 0 AND KeyD = 0 THEN
  238.     Map3[ibx] = CHR(0)
  239.     Map3[ibx + 20] = CHR(6)
  240.     rHead = 4
  241.     pHead = 4
  242.     BoxRas = 0
  243.     xBox[ibx + 20] = xHead
  244.     yBox[ibx + 20] = yHead + 32
  245.     rBox[ibx + 20] = 4
  246.     iBox[ibx + 20] = 1
  247.     Steps += 1
  248.     SW_PlayWav w2
  249.   ELSE IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_right) AND ASC(Map3[ibx + 1]) = 0 AND KeyR = 0 THEN
  250.     rHead = 1
  251.     pHead = 1
  252.     Map3[ibx] = CHR(0)
  253.     Map3[ibx + 1] = CHR(6)
  254.     Steps += 1
  255.     SW_PlayWav w1
  256.   ELSE IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_left) AND ASC(Map3[ibx - 1]) = 0 AND KeyL = 0 THEN
  257.     rHead = 2
  258.     pHead = 2
  259.     Map3[ibx] = CHR(0)
  260.     Map3[ibx - 1] = CHR(6)
  261.     Steps += 1
  262.     SW_PlayWav w1
  263.   ELSE IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_up) AND ASC(Map3[ibx - 20]) = 0 AND KeyU = 0 THEN
  264.     rHead = 3
  265.     pHead = 3
  266.     Map3[ibx] = CHR(0)
  267.     Map3[ibx - 20] = CHR(6)
  268.     Steps += 1
  269.     SW_PlayWav w1
  270.   ELSE IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_down) AND ASC(Map3[ibx + 20]) = 0 AND KeyD = 0 THEN
  271.     rHead = 4
  272.     pHead = 4
  273.     Map3[ibx] = CHR(0)
  274.     Map3[ibx + 20] = CHR(6)
  275.     Steps += 1
  276.     SW_PlayWav w1
  277.   ELSE
  278.     rHead = 0
  279.   END IF
  280. END SUB
  281.  
  282. SUB ShowHead
  283.   IF rHead = 0 AND pHead = 1 THEN
  284.     SW_Sprite s3, xHead, yHead, 3
  285.   ELSE IF rHead = 0 AND pHead = 2 THEN
  286.     SW_Sprite s3, xHead, yHead, 1
  287.   ELSE IF rHead = 0 AND pHead = 3 THEN
  288.     SW_Sprite s3, xHead, yHead, 0
  289.   ELSE IF rHead = 0 AND pHead = 4 THEN
  290.     SW_Sprite s3, xHead, yHead, 2
  291.   ELSE IF rHead = 1 THEN
  292.     xHead += 2
  293.     SW_Sprite s3, xHead, yHead, 3
  294.     RasReg += 2
  295.     IF RasReg = 32 THEN
  296.       RasReg = 0
  297.       rHead = 0
  298.     END IF
  299.   ELSE IF rHead = 2 THEN
  300.     xHead -= 2
  301.     SW_Sprite s3, xHead, yHead, 1
  302.     RasReg += 2
  303.     IF RasReg = 32 THEN
  304.       RasReg = 0
  305.       rHead = 0
  306.     END IF
  307.   ELSE IF rHead = 3 THEN
  308.     yHead -= 2
  309.     SW_Sprite s3, xHead, yHead, 0
  310.     RasReg += 2
  311.     IF RasReg = 32 THEN
  312.       RasReg = 0
  313.       rHead = 0
  314.     END IF
  315.   ELSE IF rHead = 4 THEN
  316.     yHead += 2
  317.     SW_Sprite s3, xHead, yHead, 2
  318.     RasReg += 2
  319.     IF RasReg = 32 THEN
  320.       RasReg = 0
  321.       rHead = 0
  322.     END IF
  323.   END IF
  324. END SUB
  325.  
  326. SUB MousePos
  327.   xPos = FIX(SW_xMouse() / 32)
  328.   yPos = FIX(SW_yMouse() / 32)
  329.   IF SW_MouseButton() = 1 THEN
  330.     IF xPos = 15 AND yPos = 13 AND lev > 1 AND ButtonC = 0 THEN
  331.       lev -= 1
  332.       ButtonC = 1
  333.       SW_PlayWav w4
  334.       Initialize
  335.       LoadMaps
  336.       FindHead
  337.       EXIT SUB
  338.     END IF
  339.   END IF
  340.   IF SW_MouseButton() = 1 THEN
  341.     IF xPos = 18 AND yPos = 13 AND lev < 9 AND ButtonC = 0 THEN
  342.       lev += 1
  343.       ButtonC = 1
  344.       SW_PlayWav w4
  345.       Initialize
  346.       LoadMaps
  347.       FindHead
  348.     END IF
  349.   END IF
  350.   IF SW_MouseButton() = 0 THEN ButtonC = 0
  351. END SUB
  352.  
  353.  
  354. ' MAIN
  355.  
  356. SW_Window 640, 480, 1
  357. SW_SetCaption "ScriptBasic SokoMouse"
  358.  
  359. SW_SetFps(60)
  360.  
  361. Q  = SW_LoadBmp("SokoMedia/sokomouse.bmp", 1)
  362. p1 = SW_LoadBmp("SokoMedia/Phantasie.bmp", 1)
  363. Fo = SW_LoadBmp("SokoMedia/FontStrip.bmp", 96)
  364. s1 = SW_LoadBmp("SokoMedia/SokoStrip.bmp", 5)
  365. s2 = SW_LoadBmp("SokoMedia/RundStrip.bmp", 4)
  366. s3 = SW_LoadBmp("SokoMedia/HeadStrip.bmp", 4)
  367. s4 = SW_LoadBmp("SokoMedia/BoxsStrip.bmp", 4)
  368. s6 = SW_LoadBmp("SokoMedia/HeadStripR.bmp", 64)
  369. s7 = SW_LoadBmp("SokoMedia/HeadStripL.bmp", 64)
  370. s8 = SW_LoadBmp("SokoMedia/ArroStripL.bmp", 4)
  371. s9 = SW_LoadBmp("SokoMedia/ArroStripR.bmp", 4)
  372.  
  373. w1 = "SokoMedia/move.wav"
  374. w2 = "SokoMedia/push.wav"
  375. w3 = "SokoMedia/done.wav"
  376. w4 = "SokoMedia/clic.wav"
  377.  
  378.  
  379. SW_Cls  0xCCCCCC
  380. SW_Sprite Q, 180, 60, 0
  381. SW_BmpText fo, 205, 32, "SOKOMOUSE", 24, 24
  382. SW_BmpText fo, 170, 428, "PRESS ANY KEY", 24, 24
  383. SW_WaitKey
  384.  
  385. lev = 1
  386. Initialize
  387. LoadMaps
  388. ShowLevel
  389. FindHead
  390.  
  391. WHILE SW_Key(27) = 0
  392.   ShowMaps
  393.   IF sl THEN ShowLevel
  394.   ScanBoxes
  395.   ScanHead
  396.   ShowBoxes
  397.   ShowHead
  398.   FlashBox
  399.   AllDone
  400.   MousePos
  401.   TurnHead
  402.   IF SW_Key(vk_space) THEN
  403.     SW_BmpText fo, 64, 420, "Wait...", 24, 24
  404.     Initialize
  405.     LoadMaps
  406.     FindHead
  407.   END IF
  408.   IF Ready = 2 AND NOT(Notified) THEN
  409.     SW_BmpText fo, 64, 420, Steps & " moves to solve.", 20, 20
  410.     SW_Sync
  411.     SW_PlayWav w3
  412.     sl = 1
  413.     Notified = TRUE
  414.   END IF
  415.   BoxRas += 2
  416.   IF BoxRas = 32 THEN BoxRas = 0
  417.   IF SW_Key(vk_right) = 0 THEN KeyR = 1
  418.   IF SW_Key(vk_right)THEN KeyR = 0
  419.   IF SW_Key(vk_left) = 0 THEN KeyL = 1
  420.   IF SW_Key(vk_left) THEN KeyL = 0
  421.   IF SW_Key(vk_up) = 0 THEN KeyU = 1
  422.   IF SW_Key(vk_up) THEN KeyU = 0
  423.   IF SW_Key(vk_down) = 0 THEN KeyD = 1
  424.   IF SW_Key(vk_down) THEN KeyD = 0
  425.   SW_Sync
  426. WEND
  427. SW_CloseWindow
  428.  

sw.inc (ScriptBasic version)
Code: OxygenBasic
  1. ' SIMPLE WINDOWS LIBRARY FOR SCRIPTBASIC (sw.inc) by PETER WIRBELAUER
  2.  
  3. DECLARE SUB LoadMap ALIAS "loadstring" LIB "t"
  4. DECLARE SUB DLLC_File ALIAS "dllfile" LIB "DLLC"
  5. DECLARE SUB DLLC_Proc ALIAS "dllproc" LIB "DLLC"
  6. DECLARE SUB DLLC_Call ALIAS "dllcall" LIB "DLLC"
  7. DECLARE SUB DLLC_OleStr ALIAS "dllostr" LIB "DLLC"
  8. DECLARE SUB DLLC_DelOle ALIAS "dlldelo" LIB "DLLC"
  9.  
  10. GLOBAL CONST WHITE = 0xFFFFFF
  11. GLOBAL CONST DKGRAY = 0x404040
  12. GLOBAL CONST BLUE = 0xFF0000
  13. GLOBAL CONST BOLD = 700
  14.  
  15. ' Key Defs
  16. GLOBAL CONST vk_space = 0x20
  17. GLOBAL CONST vk_right = 0x27
  18. GLOBAL CONST vk_left = 0x25
  19. GLOBAL CONST vk_up = 0x26
  20. GLOBAL CONST vk_down = 0x28
  21.  
  22. sw = DLLC_File("sw.dll")
  23. ms = DLLC_File("winmm.dll")
  24.  
  25. ' Simple Windows function definitions
  26.  
  27. Window = DLLC_Proc(sw, "Window i = (i width, i height, i mode)")
  28. SetCaption = DLLC_Proc(sw, "SetCaption i = (c*capText)")
  29. GetWidth = DLLC_Proc(sw, "GetWidth 1 = ()")
  30. GetHeight = DLLC_Proc(sw, "GetHeight i = ()")
  31. Key = DLLC_Proc(sw, "Key i = (i mKey)")
  32. WaitKey = DLLC_Proc(sw, "WaitKey i = ( )")
  33. GetKey = DLLC_Proc(sw, "GetKey i = ( )")
  34. xMouse = DLLC_Proc(sw, "xMouse i = ( )")
  35. Wait = DLLC_Proc(sw, "Wait i = (i msec)")
  36. yMouse = DLLC_Proc(sw, "yMouse i = ( )")
  37. MouseButton = DLLC_Proc(sw, "MouseButton i = ( )")
  38. Cls = DLLC_Proc(sw, "Cls i = (i color)")
  39. DrawLine = DLLC_Proc(sw, "Line i = (i xPos, i yPos, i a, i b, i thickness, i color)")
  40. DrawPoint = DLLC_Proc(sw, "DrawPoint i = (i xPos, i yPos, i width, i height, i color)")
  41. SetPixel = DLLC_Proc(sw, "SetPixel i = (i xPos, i yPos, i color)")
  42. Box = DLLC_Proc(sw, "Box i = (i xPos, i yPos, i w, i h, i thickness, i color)")
  43. Circle = DLLC_Proc(sw, "Circle i = (i xPos, i yPos, i r1, i thickness, i color)")
  44. FillCircle = DLLC_Proc(sw, "FillCircle i = (i xPos, i yPos, i r1, i color)")
  45. Ellipse = DLLC_Proc(sw, "Ellipse i = (i xPos, i yPos, i r1, i r2, i thickness, i color)")
  46. RGB = DLLC_Proc(sw, "RGB i = (i rValue, i gValue, i bValue)")
  47. Rand = DLLC_Proc(sw, "Rnd i = (i minNumber, i maxNumber)")
  48. SetText = DLLC_Proc(sw, "SetText i = (i xPos, i yPos, o text, i color)")
  49. SetFont = DLLC_Proc(sw, "SetFont i = (i width, i height, i style, c*fontName)")
  50. LoadBmp = DLLC_Proc(sw, "LoadBmp i = (c*bmpFile, i frames)")
  51. Sprite = DLLC_Proc(sw, "Sprite i = (i idBmp, i xPos, i yPos, i frames)")
  52. BmpText = DLLC_Proc(sw, "BmpText i = (i idBmp, i xPos, i yPos, o iText, i Zoom, i yZoom)")
  53. DrawBmp = DLLC_Proc(sw, "DrawBmp i = (i idBmp, i xPos, i yPos, i xZoom, i yZoom, i frames)")
  54. Sync = DLLC_Proc(sw, "Sync ( )")
  55. Redraw = DLLC_Proc(sw, "Redraw ( )")
  56. SetFps = DLLC_Proc(sw, "SetFps i = (i frames)")
  57. PlayWav = DLLC_Proc(ms, "sndPlaySoundA i = (c*wavFile, i sync)")
  58. CloseWindow = DLLC_Proc(sw, "CloseWindow i = ( )")
  59.  
  60.  
  61.  
  62. ' Simple Windows wrapper functions
  63.  
  64. SUB SW_Window(width, height, mode)
  65.   DLLC_Call(Window, width, height, mode)
  66. END SUB
  67.  
  68. SUB SW_SetCaption(capText)
  69.   DLLC_Call(SetCaption, capText)
  70. END SUB
  71.  
  72. FUNCTION SW_GetWidth
  73.   SW_GetWidth = DLLC_Call(GetWidth)
  74. END FUNCTION
  75.  
  76. FUNCTION SW_GetHeight
  77.   SW_GetHeight = DLLC_Call(GetHeight)
  78. END FUNCTION
  79.  
  80. FUNCTION SW_Key(mKey)
  81.   SW_Key = DLLC_Call(Key, mKey)
  82. END FUNCTION
  83.  
  84. SUB SW_WaitKey
  85.   DLLC_Call(WaitKey)
  86. END SUB
  87.  
  88. FUNCTION SW_GetKey
  89.   SW_GetKey = DLLC_Call(GetKey)
  90. END FUNCTION
  91.  
  92. SUB SW_Wait(msec)
  93.   DLLC_Call(Wait, msec)
  94. END SUB
  95.  
  96. FUNCTION SW_xMouse
  97.   SW_xMouse = DLLC_Call(xMouse)
  98. END FUNCTION  
  99.  
  100. FUNCTION SW_yMouse
  101.   SW_yMouse = DLLC_Call(yMouse)
  102. END FUNCTION  
  103.  
  104. FUNCTION SW_MouseButton
  105.   SW_MouseButton = DLLC_Call(MouseButton)
  106. END FUNCTION
  107.  
  108. SUB SW_Cls(color)
  109.   DLLC_Call(Cls, color)
  110. END SUB
  111.  
  112. SUB SW_Line(xPos, yPos, a, b, thickness, color)
  113.   DLLC_Call(DrawLine, xPos, yPos, a, b, thickness, color)
  114. END SUB
  115.  
  116. SUB SW_DrawPoint(xPos, yPos, width, height, color)
  117.   DLLC_Call(DrawPoint, xPos, yPos, width, height, color)
  118. END SUB
  119.  
  120. SUB SW_SetPixel(xPos, yPos, color)
  121.   DLLC_Call(SetPixel, xPos, yPos, color)
  122. END SUB
  123.  
  124. SUB SW_Box(xPos, yPos, w, h, thickness, color)
  125.   DLLC_Call(Box, xPos, yPos, w, h, thickness, color)
  126. END SUB
  127.  
  128. SUB SW_Circle(xPos, yPos, r1, thickness, color)
  129.   DLLC_Call(Circle, xPos, yPos, r1, thickness, color)
  130. END SUB
  131.  
  132. SUB SW_FillCircle(xPos, yPos, r1, color)
  133.   DLLC_Call(FillCircle, xPos, yPos, r1, color)
  134. END SUB
  135.  
  136. SUB SW_Ellipse(xPos, yPos, r1, r2, thickness, color)
  137.   DLLC_Call(Ellipse, xPos, yPos, r1, r2, thickness, color)
  138. END SUB
  139.  
  140. FUNCTION SW_RGB(rValue, gValue, bValue)
  141.   SW_RGB = DLLC_Call(RGB, rValue, gValue, bValue)
  142. END FUNCTION
  143.  
  144. FUNCTION SW_Rnd(minNumber, maxNumber)
  145.   SW_Rnd = DLLC_Call(Rand, minNumber, maxNumber)
  146. END FUNCTION
  147.  
  148. SUB SW_SetText(xPos, yPos, text, color)
  149.   LOCAL ole_text
  150.   ole_text = DLLC_OleStr(text)
  151.   DLLC_Call(SetText, xPos, yPos, ole_text, color)
  152.   DLLC_DelOle(ole_text)
  153. END SUB
  154.  
  155. SUB SW_SetFont(width, height, style, fontName)
  156.   DLLC_Call(SetFont, width, height, style, fontName)
  157. END SUB
  158.  
  159. FUNCTION SW_LoadBmp(bmpFile, frames)
  160.   SW_LoadBmp = DLLC_Call(LoadBmp, bmpFile, frames)
  161. END FUNCTION
  162.  
  163. SUB SW_LoadBytes(nName, Destination)
  164.   LOCAL tmpstr
  165.   tmpstr = LoadMap(nName)
  166.   SPLITA tmpstr BY "" TO Destination
  167. END SUB  
  168.  
  169. SUB SW_Sprite(idBmp, xPos, yPos, frames)
  170.   DLLC_Call(Sprite, idBmp, xPos, yPos, frames)
  171. END SUB
  172.  
  173. SUB SW_BmpText(idBmp, xPos, yPos, sb_iText, Zoom, yZoom)
  174.   LOCAL ole_iText
  175.   ole_iText = DLLC_OleStr(sb_iText)
  176.   DLLC_Call(BmpText, idBmp, xPos, yPos, ole_iText, Zoom, yZoom)
  177.   DLLC_DelOle(ole_iText)
  178. END SUB  
  179.  
  180. SUB SW_DrawBmp(idBmp, xPos, yPos, xZoom, yZoom, frames)
  181.   DLLC_Call(DrawBmp, idBmp, xPos, yPos, xZoom, yZoom, frames)
  182. END SUB
  183.  
  184. SUB SW_Sync
  185.   DLLC_Call(Sync)
  186. END SUB
  187.  
  188. SUB SW_Redraw
  189.   DLLC_Call(Redraw)
  190. END SUB
  191.  
  192. SUB SW_SetFps(frames)
  193.   DLLC_Call(SetFps, frames)
  194. END SUB
  195.  
  196. SUB SW_PlayWav(sfn)
  197.   DLLC_Call(PlayWav, sfn, 0)
  198. END SUB
  199.  
  200. SUB SW_CloseWindow
  201.   DLLC_Call(CloseWindow)
  202. END SUB
  203.  
« Last Edit: March 09, 2013, 10:36:16 AM by JRS »