Guest User

Untitled

a guest
Apr 28th, 2018
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' ##############################################################################
  2. ' #                                           +-------+                        #
  3. ' #      DiskManager  v 0.1                   |   #   |                        #
  4. ' #                                           |   O.  |                        #
  5. ' #      11.12.2011  Alexander Dahmen         ]       |                        #
  6. ' #                                           +-------+                        #
  7. ' #                                                                            #
  8. ' ##############################################################################
  9.  
  10. ' -- Definitionen --
  11. #define false 0
  12. #define true not(false)
  13.  
  14. ' ---------- Screen ------------------------------------------------------------
  15. screen 18,32
  16.  
  17. ' ---------- Typen -------------------------------------------------------------
  18.  
  19. type tdot
  20.     as integer x
  21.     as integer y
  22. end type
  23.  
  24. type tsquare
  25.     as tdot p1
  26.     as tdot p2
  27. end type
  28.  
  29. type tdisk
  30.     as integer x
  31.     as integer y
  32.     as integer visible
  33.     as integer grab
  34.    
  35.     as string caption
  36.     as string program(255)
  37.    
  38.     as tsquare button
  39.    
  40.     declare sub create (buffer as any ptr,disk as tdisk,number as integer)
  41.     declare sub label (byref disk as tdisk,byval caption as string)
  42. '    declare sub prog (byref disk() as tdisk,byval progname() as string)
  43. end type
  44.  
  45. type tmouse
  46.     as integer x
  47.     as integer y
  48.     as integer wheel
  49.     as integer key
  50.    
  51.     as tdot button
  52.    
  53.     declare sub reload(byref Mouse as tmouse)
  54. end type
  55.  
  56. type tbox
  57.     as tsquare button
  58.     as integer result(1 to 255)
  59.     as integer returned
  60. end type
  61.  
  62. ' ---------- Deklarationen -----------------------------------------------------
  63.  
  64. dim Mouse as tmouse
  65. dim Disk(1 to 255) as tdisk
  66. dim box as tbox
  67.  
  68. dim disknumber as ubyte
  69. dim key as string*1
  70.  
  71. dim i as integer
  72.  
  73. declare function inside(sqare as tsquare,dot as tdot) as integer
  74. declare sub diskbox()
  75.  
  76. ' ---------- Sprite-Daten ------------------------------------------------------
  77.  
  78. const name_back="Background.bmp"
  79. const name_disk="DiskBig.bmp"
  80. const name_dbox="DiskBox.bmp"
  81.  
  82. dim ptr_back as any ptr
  83. dim ptr_disk as any ptr
  84. dim ptr_dbox as any ptr
  85.  
  86. ptr_back=imagecreate(640,480)
  87. ptr_disk=imagecreate(128,128)
  88. ptr_dbox=imagecreate(640,480)
  89.  
  90. bload name_back,ptr_back
  91. bload name_disk,ptr_disk
  92. bload name_dbox,ptr_dbox
  93.  
  94. ' ---------- HAUPTPROGRAMM -----------------------------------------------------
  95.  
  96. disk(1).x=100
  97. disk(1).y=200
  98. disk(1).visible=true
  99.  
  100. for i=2 to 255
  101.     disk(i).visible=false
  102. next
  103.  
  104. box.button.p1.x=516
  105. box.button.p1.y=378
  106. box.button.p2.x=631
  107. box.button.p2.y=477
  108.  
  109. do
  110.     screenlock
  111.         put (0,0),ptr_back                                                      ' Hintergrund setzen
  112.         disk(1).create(ptr_disk,disk(1),1)                                      ' Disk Sprite zeigen
  113.        
  114.         key=inkey                                                               ' Tastatur abfragen
  115.         mouse.reload(mouse)                                                     ' \
  116.         mouse.button.x=mouse.x                                                  '  } Maus abfagen
  117.         mouse.button.y=mouse.y                                                  ' /
  118.        
  119.         if mouse.key=1 then                                                     ' Disketten bewegen
  120.             for i=1 to 255
  121.                 if inside(disk(i).button,mouse.button)=true and _
  122.                    disk(i).grab=false and _
  123.                    disk(i).visible=true then
  124.                         disk(i).grab=true                                       ' Den Parameter fΓΌr Greifen einstellen
  125.                         exit for
  126.                 end if
  127.             next i
  128.            
  129.             if inside(box.button,mouse.button) and box.returned=false then
  130.                 box.returned=true
  131.                 diskbox()
  132.             end if
  133.            
  134.         else
  135.             for i=1 to 255:disk(i).grab=false:next i
  136.             box.returned=false
  137.         end if
  138.        
  139.         for i=1 to 255
  140.             disk(i).button.p1.x=disk(i).x
  141.             disk(i).button.p1.y=disk(i).y
  142.             disk(i).button.p2.x=disk(i).x+128
  143.             disk(i).button.p2.y=disk(i).y+128
  144.            
  145.             if disk(i).grab=true then
  146.                 disk(i).x=mouse.x-64
  147.                 disk(i).y=mouse.y-64
  148.             end if
  149.         next i
  150.        
  151.     screenunlock
  152.     sleep 10,1
  153.     cls
  154. loop until key=chr(27)
  155.  
  156. if ptr_disk <> 0 then imagedestroy ptr_back
  157. if ptr_back <> 0 then imagedestroy ptr_disk
  158. if ptr_dbox <> 0 then imagedestroy ptr_dbox
  159. end
  160.  
  161. ' ---------- Subs --------------------------------------------------------------
  162.  
  163. sub tmouse.reload(byref mouse as tmouse)
  164.     with mouse
  165.         getmouse .x,.y,.wheel,.key
  166.     end with
  167. end sub
  168.  
  169. sub tdisk.create (buffer as any ptr,disk as tdisk,number as integer)
  170.     put (disk.x,disk.y),buffer,pset
  171.     draw string (disk.x+65,disk.y+98),str(number),&HFF0000
  172. end sub
  173.  
  174. sub label (byref disk as tdisk,byval caption as string)
  175.     disk.caption=caption
  176. end sub
  177.  
  178. function inside(square as tsquare,dot as tdot) as integer
  179.     if (dot.x>square.p1.x and dot.x<square.p2.x) and (dot.y>square.p1.y and dot.y<square.p2.y) then return true
  180. end function
  181.  
  182. sub diskbox()
  183.     cls
  184.     do:sleep 10:loop until inkey<>""
  185. '    dim page as integer
  186. '    dim i as integer
  187. '    dim chosen as integer
  188. '    
  189. '    dim key as string*1
  190. '    
  191. '    dim mouse as tmouse
  192. '    dim result as boxresult
  193. '    
  194. '    do
  195. '        screenlock
  196. '            put(1,1),back,pset
  197. '            key=inkey
  198. '        screenunlock
  199. '        sleep 10,1
  200. '        cls
  201. '    loop until key<>""
  202. '    sleep
  203. end sub
Add Comment
Please, Sign In to add comment