Author Topic: Analog Clock Demo  (Read 5278 times)

0 Members and 1 Guest are viewing this topic.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Analog Clock Demo
« on: September 30, 2018, 12:52:17 am »
I'm not sure how many of you may be following the sprite library revisited thread on the site but I wanted to highlight the progress I have made so far.

Below is the entire code for the library to date with a demo built in of an analog clock. It uses three sprites and an image for the clock face. The clock window is resizable as well and the library's zoom feature adjusts the sprites according to the size of the window.

The library, in my estimation, is about half-way finished. I have most of the sprite related commands completed and need to start working on the game engine side of things now (path following, physics, maze generation, etc..)

You'll need the two images supplied below to run the clock demo. Let me know what you think so far. The old library looks like child's play to this new sprite library I am cooking up. Lots of fun!

Oh, one other thing. When you first run the code a file called "hands73x533.rot" will be created. This is a file that holds all of the rotational data for the sprite sheet. It's ok to delete the file, the library simply recreates it if necessary. (which reminds me, I need to incorporate Steve's saving/loading routine in place of mine.)

Code: QB64: [Select]
  1. '** NOTES **
  2.  
  3.  
  4.  
  5. ' Ideas to add
  6. '
  7. ' if SL_EVENT_TRIGGER then 'check for event that was sent (add event triggers)
  8. ' - possible link sounds to events
  9. ' add gravity, attraction, repulsion  SL_SET_PHYSICS
  10. ' add mass, elasticity (bounciness?)   ^  ^  ^
  11. ' add arc calculator for things like a swinging vine or radar scope
  12. ' ability to link sprites, when one moves the other moves, break apart when collision happens SL_LINK_SPRITE
  13. ' give sprites path-following ability (bezier curves?) SL_FOLLOW_PATH
  14. ' divide work space into cells and detect when sprites enter/leave a cell
  15. ' stand-alone program to develop sprite sheets (inform)        \
  16. ' stand-alone program to develop celled work spaces (inform)   /  combine these into one program?
  17. ' when sprite interact their mass, elascticity, etc. govern the way the move and fall
  18. ' - I will need help from a math major for this
  19.  
  20. ' Planned additions
  21. '
  22. ' get sprite width and height (both actual and collision box) SL_GET_ACTUAL_WIDTH, SL_GET_ACTUAL_HEIGHT, SL_GET_COLLISION_WIDTH, SL_GET_COLLISION_HEIGHT
  23. ' set Z depth of sprite for different planes/layers (possibly incorporate this into zoom?)
  24. ' - need to figure out how to rotate collision box along with sprites, not too hard
  25. ' - this will require line segment intersection algorithms for collision detection, yikes! hard, probably need help
  26. ' - possibly link sounds to collisions SL_LINK_COLLIDE_SOUND
  27. ' Parallaxing layers  SL_CREATE_PARALLAX, SL_UPDATE_PARALLAX
  28. ' Game font printing
  29. ' Sprite tiling, square for sure, isometric?
  30.  
  31. ' Things to improve
  32. '
  33. ' Naming convention of constants and their values
  34. ' Use integers wherever possible
  35. ' allow SINGLE value rotation angles for accuracy but convert to integer before sprite rotation
  36. ' - using only integer now, may not be precise enough for future improvements
  37.  
  38. ' Investigate
  39. '
  40. ' Use of _MAPTRIANGLE for 3D rotation   SL_ROTATE_3D
  41. ' _HARDWARE vs _HARDWARE1
  42.  
  43. ' Remember
  44. '
  45. ' Any code added that is OS dependant needs to detect the OS running first
  46. ' - try to create routines that are OS dependant for all OS'
  47.  
  48.  
  49.  
  50. OPTION _EXPLICIT ' need to remove before publishing library!!
  51.  
  52. '*
  53. '* constant declarations
  54. '*
  55.  
  56. '      CONSTANT NAME                   DESCRIPTION                                                       FUNCTIONS / SUBROUTINES THAT MAY USE THIS CONSTANT
  57. ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  58. CONST SL_RESET = -32767 '   reset a function or subroutine              SL_ROTATE_SPRITE, SL_FLIP_SPRITE, SL_ZOOM_SPRITE, SL_SET_ZOOM, SL_CHANGE_AUTOROTATION, SL_CHANGE_AUTOMOTION, SL_CHANGE_ROTATION_SPEED, SL_SET_COLLISION
  59. CONST SL_NOFLIP = 0 '       sprite will use no flipping                 SL_FLIP_SPRITE
  60. CONST SL_HORIZONTAL = 1 '   sprite will be flipped horizontally         SL_FLIP_SPRITE
  61. CONST SL_VERTICAL = 2 '     sprite will be flipped vertically           SL_FLIP_SPRITE
  62. CONST SL_FLIPBOTH = 3 '     sprite will be flipped both direction       SL_FLIP_SPRITE
  63. CONST SL_USESHEET = -1 '    use sheet's transparency info (.PNG)        SL_NEW_SHEET
  64. CONST SL_SET = 0 '          manually set transparency                   SL_NEW_SHEET
  65. CONST SL_NONE = 1 '         don't use transparency with sheet           SL_NEW_SHEET
  66. CONST SL_NOSAVE = 0 '       sprite will not save background             SL_NEW_SPRITE, SL_SET_SOFTWARE
  67. CONST SL_SAVE = -1 '        sprite will save background                 SL_NEW_SPRITE, SL_SET_SOFTWARE
  68. CONST SL_HARDWARE = 0 '     sprite in hardware mode                     SL_NEW_SPRITE, SL_update_auto_sprites
  69. CONST SL_SOFTWARE = -1 '    sprite in software mode                     SL_NEW_SPRITE, SL_update_auto_sprites
  70. CONST SL_START = -1 '       enable auto motion / rotation               SL_CHANGE_AUTOMOTION, SL_CHANGE_AUTOROTATION, SL_SET_AUTOANIMATION, SL_SET_ANIMATION, SL_SET_MOTION, SL_SET_ROTATION
  71. CONST SL_STOP = 0 '         disable auto motion / rotation              SL_CHANGE_AUTOMOTION, SL_CHANGE_AUTOROTATION, SL_SET_AUTOANIMATION, SL_SET_ANIMATION, SL_SET_MOTION, SL_SET_ROTATION, SL_CHANGE_ROTATION_SPEED
  72. CONST SL_FORWARD = 0 '      animation cells proceed forward             SL_SET_ANIMATION
  73. CONST SL_BACKWARD = 1 '     animation cells proceed backwards           SL_SET_ANIMATION
  74. CONST SL_BACKFORTH = 2 '    animation cells toggle forward/backward     SL_SET_ANIMATION
  75. CONST SL_CURRENTCELL = -1 ' use current cell as starting cell           SL_SET_ANIMATION, SL_CHANGE_ANIMATION_CELLS
  76. CONST SL_SHOW = -1 '        sprite will be shown on screen              SL_SET_SPRITE_VISIBLE, SL_SET_LAYER_VISIBLE
  77. CONST SL_HIDE = 0 '         sprite will not be shown on screen          SL_SET_SPRITE_VISIBLE, SL_SET_LAYER_VISIBLE
  78. CONST SL_NODETECT = 0 '     sprite uses no collision detection          SL_SET_COLLISION
  79. CONST SL_BOXDETECT = 1 '    sprite uses box collision detect            SL_SET_COLLISION
  80. CONST SL_ROUNDDETECT = 2 '  sprite uses round collision detect '        SL_SET_COLLISION
  81. CONST SL_PIXELDETECT = 3 '  sprite uses pixel perfect collision detect  SL_SET_COLLISION
  82. CONST SL_ALL = -1 '         check for all sprites                       SL_GET_COLLISION, SL_GET_MOUSE, SL_CLEAR_LAYER
  83. CONST SL_NOMOUSE = 0 '      no mouse interaction with sprite            SL_GET_MOUSE
  84. CONST SL_HOVER = 1 '        mouse pointer hovering over sprite          SL_GET_MOUSE
  85. CONST SL_LEFTCLICK = 2 '    left mouse button clicked on sprite         SL_GET_MOUSE
  86. CONST SL_RIGHTCLICK = 3 '   right mouse button clicked on sprite        SL_GET_MOUSE
  87. CONST SL_CENTERCLICK = 4 '  center mouse button clicked on sprite       SL_GET_MOUSE
  88.  
  89. '*
  90. '* type declarations
  91. '*
  92.  
  93. TYPE SL_SHEET ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ SPRITE SHEET DATABASE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  94.     software AS LONG '                  software sprite image
  95.     mask AS LONG '                      software mask image
  96.     swidth AS INTEGER '                 width of sprite
  97.     sheight AS INTEGER '                height of sprite
  98.     transparency AS INTEGER '           -1 (TRUE) if sheet uses transparency
  99.     clearcolor AS _UNSIGNED LONG '      transparent color of image
  100. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  101.  
  102. TYPE SL_XY ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ X,Y LOCATIONS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  103.     real AS SINGLE '                    single values of sprite x,y center point
  104.     int AS INTEGER '                    integer values of sprite x,y center point
  105.     actual AS INTEGER '                 integer values of sprite upper left x,y location
  106.     back AS INTEGER '                   integer values of sprite's background image x,y location
  107.     dir AS SINGLE '                     single values of sprite x,y motion vectors
  108. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  109.  
  110. TYPE SL_IMAGE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ IMAGES ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  111.     hardware AS LONG '                  hardware sprite image
  112.     software AS LONG '                  software sprite image
  113.     mask AS LONG '                      software sprite mask image
  114.     back AS LONG '                      software sprite saved background image
  115. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  116.  
  117. TYPE SL_ANIM ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ANIMATION SETTINGS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  118.     cell AS INTEGER '                   current animation cell
  119.     cellfrom AS INTEGER '               starting animation cell
  120.     cellto AS INTEGER '                 ending animation cell
  121.     dir AS INTEGER '                    animation direction
  122.     mode AS INTEGER '                   animation mode (forward, backward, back/forth)
  123.     framerate AS INTEGER '              sprite animation frame rate
  124.     frame AS INTEGER '                  animation frame counter
  125.     skip AS INTEGER '                   how often to skip a frame to achieve framerate
  126.     auto AS INTEGER '                   auto-animation on/off
  127. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  128.  
  129. TYPE SL_MOTION ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ MOTION SETTINGS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  130.     auto AS INTEGER '                   -1 (TRUE) if auto-motion turned on
  131.     speed AS SINGLE '                   speed of sprite during motion
  132.     angle AS INTEGER '                  direction of sprite during motion (0 - 359)
  133. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  134.  
  135. TYPE SL_ROTATION ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ROTATION SETTINGS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  136.     auto AS INTEGER '                   -1 (TRUE) if auto-rotation turned on
  137.     speed AS INTEGER '                  spin rate in degrees of sprite (0 - 359)
  138.     angle AS INTEGER '                  current rotation angle of sprite
  139. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  140.  
  141. TYPE SL_COLLISION ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ COLLISION SETTINGS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  142.     detect AS INTEGER '                 type of detection this sprite uses (box, round, ellipse, pixel)
  143.     box AS INTEGER '                    -1 (TRUE) if a box collision detected
  144.     round AS INTEGER '                  -1 (TRUE) if a round collision detected
  145.     pixel AS INTEGER '                  -1 (TRUE) if a pixel perfect collision detected
  146.     with AS INTEGER '                   the sprite collision happened with
  147.     radius AS INTEGER '                 radius of round collision area
  148.     x1 AS INTEGER '                     collision box upper left x
  149.     x2 AS INTEGER '                     collision box lower right x
  150.     y1 AS INTEGER '                     collision box upper left y
  151.     y2 AS INTEGER '                     collision box lower right y
  152.     cwidth AS INTEGER '                 width of collision box
  153.     cheight AS INTEGER '                height of collision box
  154.     xpoint AS INTEGER '                 x location of collision
  155.     ypoint AS INTEGER '                 y location of collision
  156. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  157.  
  158. TYPE SL_MOUSE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ MOUSE SETTINGS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  159.     event AS INTEGER '                  last event on sprite (hover, click, etc)
  160.     x AS INTEGER '                      x location of mouse on sprite
  161.     y AS INTEGER '                      y location of mouse on sprite
  162.     xa AS INTEGER '                     x location of mouse on screen
  163.     ya AS INTEGER '                     y location of mouse on screen
  164. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  165.  
  166. TYPE SL_SPRITE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ SPRITE DATABASE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  167.     inuse AS INTEGER '                  this array index in use
  168.     x AS SL_XY '                        x coordinate locations
  169.     y AS SL_XY '                        y coordinate locations
  170.     gfx AS SL_IMAGE '                   image graphics
  171.     animation AS SL_ANIM '              animation settings
  172.     motion AS SL_MOTION '               motion settings
  173.     rotation AS SL_ROTATION '           rotation settings
  174.     collision AS SL_COLLISION '         collision settings
  175.     mouse AS SL_MOUSE '                 mouse interaction settings
  176.     sheet AS INTEGER '                  sheet sprite belongs to
  177.     cell AS INTEGER '                   current sprite cell
  178.     swidth AS INTEGER '                 width of sprite
  179.     sheight AS INTEGER '                height of sprite
  180.     restore AS INTEGER '                -1 (TRUE) if sprite restores background
  181.     flip AS INTEGER '                   flip horizontally, vertically, or both
  182.     transparency AS INTEGER '           -1 (TRUE) if sprite uses transparency
  183.     zoom AS INTEGER '                   zoom level of sprite (1% - x%)
  184.     software AS INTEGER '               -1 (TRUE) if sprite is to be treated as software image
  185.     score AS INTEGER '                  point score of sprite
  186.     visible AS INTEGER '                -1 (TRUE) if sprite visible
  187.     layer AS INTEGER '                  the layer the sprite belongs to
  188. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  189.  
  190. TYPE SL_ANGLE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ROTATION ANGLE & COLLISION BOX DATABASE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  191.     x1 AS INTEGER '                     collision box upper left x
  192.     x2 AS INTEGER '                     collision box lower right x
  193.     y1 AS INTEGER '                     collision box upper left y
  194.     y2 AS INTEGER '                     collision box lower right y
  195.     cwidth AS INTEGER '                 collision box width
  196.     cheight AS INTEGER '                collision box height
  197.     radius AS INTEGER '                 collision circle radius
  198.     rwidth AS INTEGER '                 rotated sprite width
  199.     rheight AS INTEGER '                rotated sprite height
  200.     px0 AS INTEGER '                    rectangular rotation coordinates
  201.     px1 AS INTEGER
  202.     px2 AS INTEGER
  203.     px3 AS INTEGER
  204.     py0 AS INTEGER
  205.     py1 AS INTEGER
  206.     py2 AS INTEGER
  207.     py3 AS INTEGER
  208. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  209.  
  210. TYPE SL_LAYERS ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ LAYER DATABASE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  211.     image AS LONG '                     software image of screen layer
  212.     visible AS INTEGER '                -1 (TRUE) if layer is visible
  213. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  214.  
  215. TYPE SL_GLOBAL ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ GLOBALS DATABASE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  216.     layer AS INTEGER '                  active layer
  217.     swidth AS INTEGER '                 screen width
  218.     sheight AS INTEGER '                screen height
  219.     framerate AS INTEGER '              global frame rate
  220.     source AS INTEGER '                 current source layer
  221.     destination AS INTEGER '            current destination layer
  222. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  223.  
  224. '*
  225. '* global dynamic array declarations
  226. '*
  227.  
  228. REDIM SL_sheet(1, 1) AS SL_SHEET '      sheet#, cell# - master sheet array
  229. REDIM SL_angle(1, 1, 359) AS SL_ANGLE ' sheet#, cell#, angle# - master sheet precalculated angle array
  230. REDIM SL_sprite(1) AS SL_SPRITE '       master working sprite array
  231. REDIM SL_layer(1) AS SL_LAYERS '        image layer array
  232.  
  233. '
  234. '*
  235. '* global variable declarations
  236. '*
  237.  
  238. DIM SL_global AS SL_GLOBAL
  239.  
  240. '*
  241. '* main code (for testing)
  242. '*
  243.  
  244.  
  245. DIM handsheet AS INTEGER '      clock hand sprite sheet
  246. DIM hour AS INTEGER '           hour hand sprite
  247. DIM minute AS INTEGER '         minute hand sprite
  248. DIM second AS INTEGER '         second hand sprite
  249. DIM face AS LONG '              clock face image
  250. DIM h, m, s AS INTEGER '        current hour. minute, second values
  251. DIM current, temp AS LONG '     current SL_SCREEN and a temp screen
  252. DIM square, center AS INTEGER ' width, height, and center of screen
  253. DIM zoom AS INTEGER '           zoom level of sprites
  254. DIM frame AS INTEGER '          frame counter
  255. DIM olds AS INTEGER '           the previous second
  256.  
  257. square = 551
  258. center = 276
  259. SL_SCREEN square, square, 1 '                                                                           set window size and layers
  260. _DELAY .2 '                                                                                             need to wait for _RESIZE below
  261. temp = _RESIZE '                                                                                        clear resize flag
  262. _TITLE "Sprite Library Clock Demo" '                                                                    give window a title
  263. handsheet = SL_NEW_SHEET("hands73x533.png", 73, 533, SL_SET, _RGB32(255, 0, 255)) '                     load the clock hands
  264. hour = SL_NEW_SPRITE(1, handsheet, 2, SL_HARDWARE, SL_NOSAVE) '                                         get the hour hand
  265. minute = SL_NEW_SPRITE(1, handsheet, 1, SL_HARDWARE, SL_NOSAVE) '                                       get the minute hand
  266. second = SL_NEW_SPRITE(1, handsheet, 3, SL_HARDWARE, SL_NOSAVE) '                                       get the second hand
  267. face = _LOADIMAGE("face.png", 32) '                                                                     load the clock face
  268. _PUTIMAGE , face '                                                                                      display the clock face
  269. SL_SET_FRAMERATE 6 '                                                                                    set the global frame rate (must be 6 FPS)
  270.     _LIMIT SL_GET_FRAMERATE '                                                                           maintain global frame rate
  271.     h = VAL(TIME$) '                                                                                    get current hour value
  272.     IF h > 11 THEN h = h - 12 '                                                                         keep a 12 hour clock
  273.     m = VAL(MID$(TIME$, 4, 2)) '                                                                        get current minute value
  274.     s = VAL(MID$(TIME$, 7, 2)) '                                                                        get current second value
  275.     frame = frame + 1 '                                                                                 increment frame counter
  276.     IF s <> olds THEN '                                                                                 new second?
  277.         frame = 0 '                                                                                     yes, reset frame counter
  278.         olds = s '                                                                                      remember this second value
  279.     END IF
  280.     SL_ROTATE_SPRITE hour, 30 * h + m \ 2 '                                                             rotate hour hand into position
  281.     SL_ROTATE_SPRITE minute, 6 * m + s \ 10 '                                                           rotate minute hand into position
  282.     SL_ROTATE_SPRITE second, 6 * s + frame '                                                            rotate second hand into position
  283.     SL_PUT_SPRITE center, center, hour '                                                                display the hour hand
  284.     SL_PUT_SPRITE center, center, minute '                                                              display the minute hand
  285.     SL_PUT_SPRITE center, center, second '                                                              display the second hand
  286.     IF _RESIZE THEN '                                                                                   did user resize screen?
  287.         current = _SOURCE '                                                                             yes, get the current screen pointer
  288.         temp = _COPYIMAGE(_SOURCE, 32) '                                                                make a copy of the current screen
  289.         SCREEN temp '                                                                                   make the copy active
  290.         _FREEIMAGE current '                                                                            free the old current screen
  291.         SL_SCREEN _RESIZEWIDTH, _RESIZEWIDTH, 1 '                                                       create the new current screen (square _RESIZEWIDTH)
  292.         _PUTIMAGE (0, 0)-(_WIDTH(_SOURCE) - 1, _HEIGHT(_SOURCE) - 1), face '                            stretch the clock face onto it
  293.         _FREEIMAGE temp '                                                                               no longer need copy of old current screen
  294.         zoom = _WIDTH(_SOURCE) / square * 100 '                                                         calculate sprite zoom level
  295.         SL_SET_ZOOM hour, zoom '                                                                        zoom the sprites to match new dimensions
  296.         SL_SET_ZOOM minute, zoom
  297.         SL_SET_ZOOM second, zoom
  298.         center = _WIDTH(_SOURCE) \ 2 '                                                                  new center point for clock hands
  299.     END IF
  300.     SL_DISPLAY '                                                                                        merge layers and display
  301. LOOP UNTIL _KEYHIT '                                                                                    leave when key hit
  302. SL_FREE_SPRITE hour '                                                                                   free sprites from memory
  303. SL_FREE_SPRITE minute
  304. SL_FREE_SPRITE second
  305. 'SL_FREE_SHEET handsheet '                                                                              free sprite sheet images (coming soon)
  306. SYSTEM '                                                                                                return to OS
  307.  
  308.  
  309. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  310. '                                                                       ----------==========                ==========----------
  311. '                                                                       ----------========== LAYER ROUTINES ==========----------
  312. '                                                                       ----------==========                ==========----------
  313. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  314.  
  315. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  316. SUB SL_SCREEN (swidth AS INTEGER, sheight AS INTEGER, layers AS INTEGER) '                                                                                                                    SL_SCREEN
  317.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  318.  
  319.     ' declare global variables
  320.  
  321.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  322.     SHARED SL_global AS SL_GLOBAL '     common globals array
  323.  
  324.     ' declare local variables
  325.  
  326.     DIM layer AS INTEGER '              layer counter
  327.  
  328.     ' perform error checks
  329.  
  330.     IF layers < 1 THEN '                                                                                creating at least one layer?
  331.         SL_error "SL_SCREEN", 26, "" '                                                                  no, report error to programmer
  332.     END IF
  333.  
  334.     REDIM SL_layer(layers) AS SL_LAYERS '                                                               increase layer array to match requested number of layers
  335.     SL_global.swidth = swidth '                                                                         set screen width
  336.     SL_global.sheight = sheight '                                                                       set screen height
  337.     layer = 0 '                                                                                         reset layer counter
  338.  
  339.     DO '                                                                                                cycle through layers
  340.         SL_layer(layer).image = _NEWIMAGE(swidth, sheight, 32) '                                        create layer software image
  341.         SL_layer(layer).visible = -1 '                                                          (TRUE)  layer is visible
  342.         layer = layer + 1 '                                                                             increment layer counter
  343.     LOOP UNTIL layer = UBOUND(SL_layer) + 1 '                                                           leave when all layers created
  344.  
  345.     SL_SET_DESTINATION_LAYER 1 '                                                                        set destination layer
  346.     SL_SET_SOURCE_LAYER 1 '                                                                             set source layer
  347.     SCREEN SL_layer(0).image '                                                                          initialize layer 0 working screen
  348.  
  349.  
  350. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  351. SUB SL_DISPLAY () '                                                                                                                                                                          SL_DISPLAY
  352.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  353.  
  354.     ' declare global variables
  355.  
  356.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  357.     SHARED SL_global AS SL_GLOBAL '     common globals array
  358.  
  359.     ' declare local variables
  360.  
  361.     DIM layer AS INTEGER '              layer counter
  362.     DIM odest AS INTEGER '              original destination
  363.     DIM merge AS LONG '                 software image to merge all layers onto
  364.     DIM hardware AS LONG '              hardware image of merged layers to place on working screen
  365.  
  366.     SL_update_auto_sprites -1 '                                                          (SL_SOFTWARE)  update all software automatic sprites
  367.     'odest = _DEST '                                                                                     save original destination
  368.     _DEST SL_layer(0).image '                                                                           working screen is destination
  369.     _SOURCE SL_layer(0).image
  370.     merge = _NEWIMAGE(SL_global.swidth, SL_global.sheight, 32) '                                        create screen to merge layers
  371.     layer = UBOUND(SL_layer) '                                                                          reset layer counter
  372.  
  373.     DO '                                                                                                cycle through layers backwards (high to low)
  374.         IF SL_layer(layer).visible THEN '                                                               is this layer visible?
  375.             _PUTIMAGE , SL_layer(layer).image, merge '                                                  merge this layer
  376.         END IF
  377.         layer = layer - 1 '                                                                             decrement layer counter
  378.     LOOP UNTIL layer = 0 '                                                                              leave when all layers merged
  379.  
  380.     hardware = _COPYIMAGE(merge, 33) '                                                                  create hardware image of merged layers
  381.     _PUTIMAGE , hardware '                                                                              place hardware image on working screen
  382.     _FREEIMAGE merge '                                                                                  merged software image no longer needed
  383.     _FREEIMAGE hardware '                                                                               merged hardware image no longer needed
  384.     SL_update_auto_sprites 0 '                                                           (SL_HARDWARE)  update all hardware automatic sprites
  385.  
  386.     '_DEST odest '                                                                                       restore original destination
  387.     _DISPLAY '                                                                                          update display screen with changes
  388.  
  389.  
  390. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  391. SUB SL_SET_DESTINATION_LAYER (layer AS INTEGER) '                                                                                                                              SL_SET_DESTINATION_LAYER
  392.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  393.  
  394.     ' declare global variables
  395.  
  396.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  397.     SHARED SL_global AS SL_GLOBAL '     common globals array
  398.  
  399.     ' perform error checks
  400.  
  401.     IF layer <> -32767 THEN '                                                               (SL_RESET)  reset to working image?
  402.         IF NOT SL_VALID_LAYER(layer) THEN '                                                             no, valid layer?
  403.             SL_error "SL_SET_DESTINATION_LAYER", 25, "" '                                               no, report error to programmer
  404.         ELSE '                                                                                          yes, valid layer
  405.             _DEST SL_layer(layer).image '                                                               set destination as layer software image
  406.             SL_global.destination = layer '                                                             save new destination layer
  407.         END IF
  408.     ELSE '                                                                                              yes, reset layer
  409.         _DEST SL_layer(1).image '                                                                       set destination as layer 1 software image
  410.         SL_global.destination = 1 '                                                                     save new destination layer
  411.     END IF
  412.  
  413.  
  414. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  415. SUB SL_SET_SOURCE_LAYER (layer AS INTEGER) '                                                                                                                                        SL_SET_SOURCE_LAYER
  416.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  417.  
  418.     ' declare global variables
  419.  
  420.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  421.     SHARED SL_global AS SL_GLOBAL '     common globals array
  422.  
  423.     ' perform error checks
  424.  
  425.     IF layer <> -32767 THEN '                                                               (SL_RESET)  reset to working image?
  426.         IF NOT SL_VALID_LAYER(layer) THEN '                                                             no, valid layer?
  427.             SL_error "SL_SET_SOURCE_LAYER", 25, "" '                                                    no, report error to programmer
  428.         ELSE '                                                                                          yes, valid layer
  429.             _SOURCE SL_layer(layer).image '                                                             set source as layer software image
  430.             SL_global.source = layer '                                                                  save new source layer
  431.         END IF
  432.     ELSE '                                                                                              yes, reset layer
  433.         _SOURCE SL_layer(1).image '                                                                     set source as layer 1 software image
  434.         SL_global.source = 1 '                                                                          save new source layer
  435.     END IF
  436.  
  437.  
  438. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  439. FUNCTION SL_GET_DESTINATION_LAYER () '                                                                                                                                         SL_GET_DESTINATION_LAYER
  440.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  441.  
  442.     ' declare global variables
  443.  
  444.     SHARED SL_global AS SL_GLOBAL '     common globals array
  445.  
  446.     SL_GET_DESTINATION_LAYER = SL_global.destination '                                                  return current destination layer
  447.  
  448.  
  449. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  450. FUNCTION SL_GET_SOURCE_LAYER () '                                                                                                                                                   SL_GET_SOURCE_LAYER
  451.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  452.  
  453.     ' declare global variables
  454.  
  455.     SHARED SL_global AS SL_GLOBAL '     common globals array
  456.  
  457.     SL_GET_SOURCE_LAYER = SL_global.source '                                                            return current source layer
  458.  
  459.  
  460. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  461. SUB SL_CLEAR_LAYER (layer AS INTEGER) '                                                                                                                                                  SL_CLEAR_LAYER
  462.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  463.  
  464.     ' declare global variables
  465.  
  466.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  467.     SHARED SL_global AS SL_GLOBAL '     common globals array
  468.  
  469.     ' declare local variables
  470.  
  471.     DIM layers AS INTEGER '             layer counter
  472.  
  473.     ' perform error checks
  474.  
  475.     IF layer <> -1 THEN '                                                                     (SL_ALL)  clear all layers?
  476.         IF NOT SL_VALID_LAYER(layer) THEN '                                                             no, valid layer?
  477.             SL_error "SL_CLEAR_LAYER", 25, "" '                                                         no, report error to programmer
  478.         END IF
  479.         _FREEIMAGE SL_layer(layer).image '                                                              free the layer's software image from memory
  480.         SL_layer(layer).image = _NEWIMAGE(SL_global.swidth, SL_global.sheight, 32) '                    create a new software layer
  481.     ELSE '                                                                                              yes, clear all layers
  482.         layers = 0 '                                                                                    reset layer counter
  483.         DO
  484.             layers = layers + 1 '                                                                       increment layer counter
  485.             _FREEIMAGE SL_layer(layers).image '                                                         free the layer's software image from memory
  486.             SL_layer(layers).image = _NEWIMAGE(SL_global.swidth, SL_global.sheight, 32) '               create a new software layer
  487.         LOOP UNTIL layers = UBOUND(SL_layer) '                                                          leave when all layers cleared
  488.     END IF
  489.  
  490.  
  491. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  492. FUNCTION SL_VALID_LAYER (layer AS INTEGER) '                                                                                                                                             SL_VALID_LAYER
  493.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  494.  
  495.     ' declare global variables
  496.  
  497.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  498.  
  499.     IF layer < 1 OR layer > UBOUND(SL_layer) THEN '                                                     valid layer?
  500.         SL_VALID_LAYER = 0 '                                                                   (FALSE)  no, return invalid
  501.     ELSE '                                                                                              yes
  502.         SL_VALID_LAYER = -1 '                                                                   (TRUE)  return valid
  503.     END IF
  504.  
  505.  
  506. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  507. FUNCTION SL_SCREEN_WIDTH () '                                                                                                                                                           SL_SCREEN_WIDTH
  508.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  509.  
  510.     ' declare global variables
  511.  
  512.     SHARED SL_global AS SL_GLOBAL '     common globals array
  513.  
  514.     SL_SCREEN_WIDTH = SL_global.swidth '                                                                return screen width
  515.  
  516.  
  517. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  518. FUNCTION SL_SCREEN_HEIGHT () '                                                                                                                                                         SL_SCREEN_HEIGHT
  519.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  520.  
  521.     ' declare global variables
  522.  
  523.     SHARED SL_global AS SL_GLOBAL '     common globals array
  524.  
  525.     SL_SCREEN_HEIGHT = SL_global.sheight '                                                              return screen height
  526.  
  527.  
  528. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  529. SUB SL_SET_LAYER_VISBILE (layer AS INTEGER, visible AS INTEGER) '                                                                                                                  SL_SET_LAYER_VISIBLE
  530.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  531.  
  532.     ' declare global variables
  533.  
  534.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  535.  
  536.     ' perform error checks
  537.  
  538.     IF NOT SL_VALID_LAYER(layer) THEN '                                                                 no, valid layer?
  539.         SL_error "SL_SET_LAYER_VISIBLE", 25, "" '                                                       no, report error to programmer
  540.     END IF
  541.     IF (visible < -1) OR (visible > 0) THEN '                                      (SL_SHOW & SL_HIDE)  valid visible behavior requested?
  542.         SL_error "SL_SET_LAYER_VISIBLE", 20, "" '                                                       no, report error to programmer
  543.     END IF
  544.  
  545.     SL_layer(layer).visible = visible '                                                                 set layer visibility
  546.  
  547.  
  548. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  549. '                                                                       ----------==========                ==========----------
  550. '                                                                       ----------========== MOUSE ROUTINES ==========----------
  551. '                                                                       ----------==========                ==========----------
  552. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  553.  
  554. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  555. FUNCTION SL_GET_MOUSE (handle AS INTEGER) '                                                                                                                                                SL_GET_MOUSE
  556.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  557.  
  558.     ' declare global variables
  559.  
  560.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  561.  
  562.     ' declare local variables
  563.  
  564.     DIM sprite AS INTEGER '             sprite counter to cycle through array
  565.     DIM event AS INTEGER '              -1 (TRUE) if an event was recorded
  566.  
  567.     ' perform error checks
  568.  
  569.     IF handle <> -1 THEN '                                                                    (SL_ALL)  check all sprites for mouse interaction?
  570.         IF NOT SL_VALID_SPRITE(handle) THEN '                                                           no, is this a valid sprite?
  571.             SL_error "SL_GET_MOUSE", 1, "" '                                                            no, report error to programmer
  572.         END IF
  573.         IF NOT SL_sprite(handle).visible THEN '                                                         is sprite visible?
  574.             EXIT FUNCTION '                                                                             no, leave function
  575.         END IF
  576.     END IF
  577.     IF handle = -1 THEN '                                                                     (SL_ALL)  check all sprites?
  578.         sprite = 1 '                                                                                    yes, start with first index
  579.     ELSE '                                                                                              no, check a single sprite
  580.         sprite = handle '                                                                               start with that sprite
  581.     END IF
  582.  
  583.     DO '                                                                                                cycle through sprite array
  584.         IF SL_sprite(handle).inuse AND SL_sprite(handle).visible THEN '                                 is sprite in use and visible?
  585.             SL_sprite(handle).mouse.event = 0 '                                                         yes, reset mouse settings
  586.             SL_sprite(handle).mouse.x = 0
  587.             SL_sprite(handle).mouse.y = 0
  588.             SL_sprite(handle).mouse.xa = 0
  589.             SL_sprite(handle).mouse.ya = 0
  590.             WHILE _MOUSEINPUT: WEND '                                                                   get latest mouse information
  591.             IF _MOUSEX >= SL_sprite(sprite).collision.x1 THEN '                                         is mouse pointer on sprite?
  592.                 IF _MOUSEX <= SL_sprite(sprite).collision.x2 THEN
  593.                     IF _MOUSEY >= SL_sprite(sprite).collision.y1 THEN
  594.                         IF _MOUSEY <= SL_sprite(sprite).collision.y2 THEN
  595.                             event = -1 '                                                                yes, remember that an event occurred
  596.                             SL_sprite(sprite).mouse.xa = _MOUSEX '                                      screen location of mouse x
  597.                             SL_sprite(sprite).mouse.ya = _MOUSEY '                                      screen location of mouse y
  598.                             SL_sprite(sprite).mouse.x = _MOUSEX - SL_sprite(sprite).x.actual '          sprite location of mouse x
  599.                             SL_sprite(sprite).mouse.y = _MOUSEY - SL_sprite(sprite).y.actual '          sprite location of mouse y
  600.                             IF _MOUSEBUTTON(1) THEN '                                                   is left button clicked?
  601.                                 SL_GET_MOUSE = 2 '                                      (SL_LEFTCLICK)  yes, return value
  602.                                 SL_sprite(sprite).mouse.event = 2 '                     (SL_LEFTCLICK)  record mouse event
  603.                             ELSEIF _MOUSEBUTTON(2) THEN '                                               no, is right button clicked?
  604.                                 SL_GET_MOUSE = 3 '                                     (SL_RIGHTCLICK)  yes, return value
  605.                                 SL_sprite(sprite).mouse.event = 3 '                    (SL_RIGHTCLICK)  record mouse event
  606.                             ELSEIF _MOUSEBUTTON(3) THEN '                                               no, is center button clicked?
  607.                                 SL_GET_MOUSE = 4 '                                    (SL_CENTERCLICK)  yes, return value
  608.                                 SL_sprite(sprite).mouse.event = 4 '                   (SL_CENTERCLICK)  record mouse event
  609.                             ELSE '                                                                      no, mouse is just hovering
  610.                                 SL_GET_MOUSE = 1 '                                          (SL_HOVER)  return value
  611.                                 SL_sprite(sprite).mouse.event = 1 '                         (SL_HOVER)  record mouse event
  612.                             END IF
  613.                         END IF
  614.                     END IF
  615.                 END IF
  616.             END IF
  617.         END IF
  618.         sprite = sprite + 1 '                                                                           increment sprite counter
  619.     LOOP UNTIL sprite = (UBOUND(SL_sprite) + 1) OR (handle = -1) '                                      leave when full array or single sprite checked
  620.  
  621.     IF handle = -1 THEN '                                                                     (SL_ALL)  were all sprites checked?
  622.         IF event THEN '                                                                                 yes, was there an event with any of them?
  623.             SL_GET_MOUSE = -1 '                                                                 (TRUE)  return that an event occurred
  624.         ELSE '                                                                                          no events recorded
  625.             SL_GET_MOUSE = 0 '                                                                 (FALSE)  return that no events occurred
  626.         END IF
  627.     END IF
  628.  
  629.  
  630. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  631. FUNCTION SL_GET_MOUSE_EVENT (handle AS INTEGER) '                                                                                                                                    SL_GET_MOUSE_EVENT
  632.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  633.  
  634.     ' declare global variables
  635.  
  636.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  637.  
  638.     ' perform error checks
  639.  
  640.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  641.         SL_error "SL_GET_MOUSE_EVENT", 1, "" '                                                          no, report error to programmer
  642.     END IF
  643.  
  644.     SL_GET_MOUSE_EVENT = SL_sprite(handle).mouse.event '                                                return mouse event
  645.     SL_sprite(handle).mouse.event = 0 '                                                                 reset now that value retrieved
  646.  
  647.  
  648. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  649. FUNCTION SL_GET_MOUSE_SPRITEX (handle AS INTEGER) '                                                                                                                                SL_GET_MOUSE_SPRITEX
  650.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  651.  
  652.     ' declare global variables
  653.  
  654.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  655.  
  656.     ' perform error checks
  657.  
  658.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  659.         SL_error "SL_GET_MOUSE_SPRITEX", 1, "" '                                                        no, report error to programmer
  660.     END IF
  661.  
  662.     SL_GET_MOUSE_SPRITEX = SL_sprite(handle).mouse.x '                                                  return x value of mouse on sprite
  663.     SL_sprite(handle).mouse.x = 0 '                                                                     reset now that value retrieved
  664.  
  665.  
  666. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  667. FUNCTION SL_GET_MOUSE_SPRITEY (handle AS INTEGER) '                                                                                                                                SL_GET_MOUSE_SPRITEY
  668.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  669.  
  670.     ' declare global variables
  671.  
  672.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  673.  
  674.     ' perform error checks
  675.  
  676.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  677.         SL_error "SL_GET_MOUSE_SPRITEY", 1, "" '                                                        no, report error to programmer
  678.     END IF
  679.  
  680.     SL_GET_MOUSE_SPRITEY = SL_sprite(handle).mouse.y '                                                  return y value of mouse on sprite
  681.     SL_sprite(handle).mouse.y = 0 '                                                                     reset now that value retrieved
  682.  
  683.  
  684. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  685. FUNCTION SL_GET_MOUSE_ACTUALX (handle AS INTEGER) '                                                                                                                                SL_GET_MOUSE_ACTUALX
  686.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  687.  
  688.     ' declare global variables
  689.  
  690.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  691.  
  692.     ' perform error checks
  693.  
  694.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  695.         SL_error "SL_GET_MOUSE_ACTUALX", 1, "" '                                                        no, report error to programmer
  696.     END IF
  697.  
  698.     SL_GET_MOUSE_ACTUALX = SL_sprite(handle).mouse.xa '                                                 return x value of mouse on screen
  699.     SL_sprite(handle).mouse.xa = 0 '                                                                    reset now that value retrieved
  700.  
  701.  
  702. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  703. FUNCTION SL_GET_MOUSE_ACTUALY (handle AS INTEGER) '                                                                                                                                SL_GET_MOUSE_ACTUALY
  704.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  705.  
  706.     ' declare global variables
  707.  
  708.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  709.  
  710.     ' perform error checks
  711.  
  712.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  713.         SL_error "SL_GET_MOUSE_ACTUALY", 1, "" '                                                        no, report error to programmer
  714.     END IF
  715.  
  716.     SL_GET_MOUSE_ACTUALY = SL_sprite(handle).mouse.ya '                                                 return y value of mouse on screen
  717.     SL_sprite(handle).mouse.ya = 0 '                                                                    reset now that value retrieved
  718.  
  719.  
  720. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  721. '                                                                     ----------==========                    ==========----------
  722. '                                                                     ----------========== COLLISION ROUTINES ==========----------
  723. '                                                                     ----------==========                    ==========----------
  724. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  725.  
  726. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  727. FUNCTION SL_GET_COLLISION (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                                   SL_GET_COLLISION
  728.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  729.  
  730.     ' declare global variables
  731.  
  732.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  733.  
  734.     ' declare local variables
  735.  
  736.     DIM sprite AS INTEGER '             sprite counter in loop
  737.  
  738.     ' perform error checks
  739.  
  740.     IF NOT SL_VALID_SPRITE(handle1) THEN '                                                              is this a valid sprite?
  741.         SL_error "SL_GET_COLLISION", 1, "" '                                                            no, report error to programmer
  742.     END IF
  743.     IF handle2 <> -1 THEN '                                                                   (SL_ALL)  check for collision with all sprites?
  744.         IF NOT SL_VALID_SPRITE(handle2) THEN '                                                          no, is this a valid sprite?
  745.             SL_error "SL_GET_COLLISION", 1, "" '                                                        no, report error to programmer
  746.         END IF
  747.         IF SL_sprite(handle2).collision.detect = 0 THEN '                                               collision detection turned on?
  748.             SL_error "SL_GET_COLLISION", 22, "" '                                                       no, report error to programmer
  749.         END IF
  750.         'IF SL_sprite(handle1).collision.detect <> SL_sprite(handle2).collision.detect THEN '            both sprites use same detection method?
  751.         '    SL_error "SL_GET_COLLISION", 23, "" '                                                       no, report error to programmer
  752.         'END IF
  753.     END IF
  754.     IF SL_sprite(handle1).collision.detect = 0 THEN '                                                   collision detection turned on?
  755.         SL_error "SL_GET_COLLISION", 21, "" '                                                           no, report error to programmer
  756.     END IF
  757.  
  758.     SELECT CASE SL_sprite(handle1).collision.detect
  759.         CASE 1 '                                                                              (SL_BOX)  box detection
  760.             IF handle2 <> -1 THEN '                                                           (SL_ALL)  check all sprites for collision?
  761.                 SL_sprite(handle1).collision.box = SL_box_collision(SL_sprite(handle1).collision.x1,_
  762.                                                                     SL_sprite(handle1).collision.y1,_
  763.                                                                     SL_sprite(handle1).collision.cwidth,_
  764.                                                                     SL_sprite(handle1).collision.cheight,_
  765.                                                                     SL_sprite(handle2).collision.x2,_
  766.                                                                     SL_sprite(handle2).collision.y2,_
  767.                                                                     SL_sprite(handle2).collision.cwidth,_
  768.                                                                     SL_sprite(handle2).collision.cheight) ' no, check for a box collision of two sprites
  769.                 IF SL_sprite(handle1).collision.box THEN '                                              was there a collision?
  770.                     SL_sprite(handle1).collision.with = handle2 '                                       yes, record sprite that was collided with
  771.                     SL_sprite(handle2).collision.with = handle1 '                                       tell the other sprite who it collided with
  772.                     SL_GET_COLLISION = handle2 '                                                (TRUE)  return that a collision happened
  773.                 END IF
  774.             ELSE '                                                                                      yes, check all sprites
  775.                 sprite = 0 '                                                                            reset sprite counter
  776.                 DO '                                                                                    cycle through sprite array
  777.                     sprite = sprite + 1 '                                                               increment sprite counter
  778.                     IF SL_sprite(sprite).inuse AND SL_sprite(sprite).collision.detect THEN '            is sprite in use and using collision detection?
  779.                         SL_sprite(handle1).collision.box = SL_box_collision(SL_sprite(handle1).collision.x1,_
  780.                                                                             SL_sprite(handle1).collision.y1,_
  781.                                                                             SL_sprite(handle1).collision.cwidth,_
  782.                                                                             SL_sprite(handle1).collision.cheight,_
  783.                                                                             SL_sprite(sprite).collision.x2,_
  784.                                                                             SL_sprite(sprite).collision.y2,_
  785.                                                                             SL_sprite(sprite).collision.cwidth,_
  786.                                                                             SL_sprite(sprite).collision.cheight) ' yes, check for a box collision of two sprites
  787.                         IF SL_sprite(handle1).collision.box THEN '                                      box collision detected?
  788.                             SL_sprite(handle1).collision.with = sprite '                                yes, record sprite that was collided with
  789.                             SL_sprite(sprite).collision.with = handle1 '                                tell the other sprite who it collided with
  790.                             SL_GET_COLLISION = sprite '                                         (TRUE)  return that collision happened
  791.                             sprite = UBOUND(SL_sprite) '                                                no need to check further
  792.                         END IF
  793.                     END IF
  794.                 LOOP UNTIL sprite = UBOUND(SL_sprite) '                                                 leave when end of array reached
  795.             END IF
  796.         CASE 2 '                                                                            (SL_ROUND)  round collision
  797.             IF handle2 <> -1 THEN '                                                           (SL_ALL)  check all sprites for collision?
  798.                 SL_sprite(handle1).collision.round = sl_round_collision(SL_sprite(handle1).x.int,_
  799.                                                                         SL_sprite(handle1).y.int,_
  800.                                                                         SL_sprite(handle1).collision.radius,_
  801.                                                                         SL_SPRITE(handle2).x.int,_
  802.                                                                         SL_sprite(handle2).y.int,_
  803.                                                                         SL_sprite(handle2).collision.radius) ' no, check for a round collision of two sprites
  804.                 IF SL_sprite(handle1).collision.round THEN '                                            was there a collision?
  805.                     SL_sprite(handle1).collision.with = handle2 '                                       yes, record sprite that was collided with
  806.                     SL_sprite(handle2).collision.with = handle1 '                                       tell the other sprite who it collided with
  807.                     SL_GET_COLLISION = handle2 '                                                (TRUE)  return that a collision happened
  808.                 END IF
  809.             ELSE '                                                                                      yes, check all sprites
  810.                 sprite = 0 '                                                                            reset sprite counter
  811.                 DO '                                                                                    cycle through sprite array
  812.                     sprite = sprite + 1 '                                                               increment sprite counter
  813.                     IF SL_sprite(sprite).inuse AND SL_sprite(sprite).collision.detect THEN '            is sprite in use and using collision detection?
  814.                         SL_sprite(handle1).collision.round = sl_round_collision(SL_sprite(handle1).x.int,_
  815.                                                                                 SL_sprite(handle1).y.int,_
  816.                                                                                 SL_sprite(handle1).collision.radius,_
  817.                                                                                 SL_sprite(sprite).x.int,_
  818.                                                                                 SL_sprite(sprite).y.int,_
  819.                                                                                 SL_sprite(sprite).collision.radius) ' yes, check for a round collision of two sprites
  820.                         IF SL_sprite(handle1).collision.round THEN '                                    round collision detected?
  821.                             SL_sprite(handle1).collision.with = sprite '                                yes, record sprite that was collided with
  822.                             SL_sprite(sprite).collision.with = handle1 '                                tell the other sprite who it collided with
  823.                             SL_GET_COLLISION = sprite '                                         (TRUE)  return that collision happened
  824.                             sprite = UBOUND(SL_sprite) '                                                no need to check further
  825.                         END IF
  826.                     END IF
  827.                 LOOP UNTIL sprite = UBOUND(SL_sprite) '                                                 leave when end of array reached
  828.             END IF
  829.         CASE 3 '                                                                            (SL_PIXEL)  pixel perfect collision
  830.             IF handle2 <> -1 THEN '                                                           (SL_ALL)  check all sprites for collision?
  831.                 SL_sprite(handle1).collision.pixel = SL_PIXEL_COLLISION(handle1, handle2) '             yes, check for a pixel collision of two sprites
  832.                 IF SL_sprite(handle1).collision.pixel THEN '                                            pixel collision detected?
  833.                     SL_sprite(handle1).collision.with = handle2 '                                       yes, record sprite that was collided with
  834.                     SL_sprite(handle2).collision.with = handle1 '                                       tell the other sprite who it collided with
  835.                     SL_GET_COLLISION = handle2 '                                                (TRUE)  return that collision happened
  836.                 END IF
  837.             ELSE '                                                                                      yes, check all sprites
  838.                 sprite = 0 '                                                                            reset sprite counter
  839.                 DO '                                                                                    cycle through sprite array
  840.                     sprite = sprite + 1 '                                                               increment sprite counter
  841.                     IF SL_sprite(sprite).inuse AND SL_sprite(sprite).collision.detect THEN '            is sprite in use and using collision detection? (may need to see if mask available too) <--------------- LOOK
  842.                         SL_sprite(handle1).collision.pixel = SL_PIXEL_COLLISION(handle1, sprite) '      yes, check for a pixel collision of two sprites
  843.                         IF SL_sprite(handle1).collision.pixel THEN '                                    pixel collision detected?
  844.                             SL_sprite(handle1).collision.with = sprite '                                yes, record sprite that was collided with
  845.                             SL_sprite(sprite).collision.with = handle1 '                                tell the other sprite who it collided with
  846.                             SL_GET_COLLISION = sprite '                                         (TRUE)  return that collision happened
  847.                             sprite = UBOUND(SL_sprite) '                                                no need to check further
  848.                         END IF
  849.                     END IF
  850.                 LOOP UNTIL sprite = UBOUND(SL_sprite) '                                                 leave when end of array reached
  851.             END IF
  852.     END SELECT
  853.  
  854.  
  855. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  856. FUNCTION SL_ROUND_COLLISION (x1 AS INTEGER, y1 AS INTEGER, r1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER, r2 AS INTEGER) '                                                             SL_ROUND_COLLISION
  857.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  858.  
  859.     IF SL_GET_DISTANCE_POINT_TO_POINT(x1, y1, x2, y2) < r1 + r2 THEN '                                  is distance less than both radii added together?
  860.         SL_ROUND_COLLISION = -1 '                                                               (TRUE)  yes, return a collision
  861.     END IF
  862.  
  863.  
  864. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  865. FUNCTION SL_BOX_COLLISION (x1 AS INTEGER, y1 AS INTEGER, w1 AS INTEGER, h1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER, w2 AS INTEGER, h2 AS INTEGER) '                                   SL_BOX_COLLISION
  866.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  867.  
  868.     IF x1 <= x2 + w2 THEN '                                                                             is x1 within box 2's width?
  869.         IF x1 + w1 >= x2 THEN '                                                                         yes, is x2 within box 1's width?
  870.             IF y1 <= y2 + h2 THEN '                                                                     yes, is y1 within box 2's height?
  871.                 IF y1 + h1 >= y2 THEN '                                                                 yes, is y2 within box 1's height?
  872.                     SL_BOX_COLLISION = -1 '                                                     (TRUE)  yes, return a collision
  873.                 END IF
  874.             END IF
  875.         END IF
  876.     END IF
  877.  
  878.  
  879. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  880. FUNCTION SL_PIXEL_COLLISION (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                               SL_PIXEL_COLLISION
  881.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  882.  
  883.     ' declare global variables
  884.  
  885.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  886.  
  887.     ' declare local variables
  888.  
  889.     DIM leftx AS INTEGER '              upper left x location of box collision area
  890.     DIM rightx AS INTEGER '             lower right x location of box collision area
  891.     DIM topy AS INTEGER '               upper left y location of box collision area
  892.     DIM bottomy AS INTEGER '            lower right y location of box collision area
  893.     DIM masks AS LONG '                 box collision area image to place masks
  894.     DIM h1x AS INTEGER '                center point x offset for first sprite mask image
  895.     DIM h2x AS INTEGER '                center point x offset for second sprite mask image
  896.     DIM h1y AS INTEGER '                center point y offset for first sprite mask image
  897.     DIM h2y AS INTEGER '                center point y offset for second sprite mask image
  898.     DIM odest AS LONG '                 original destination
  899.     DIM osource AS LONG '               original source
  900.     DIM x AS INTEGER '                  counter to cycle through width of mask image
  901.     DIM y AS INTEGER '                  counter to cycle throuogh height of mask image
  902.  
  903.     ' perform error checks
  904.  
  905.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  906.         SL_error "SL_PIXEL_COLLISION", 1, "" '                                                          no, report error to programmer
  907.     END IF
  908.  
  909.     ' if there is no box collision then no need to check for pixel collision
  910.  
  911.     IF  SL_box_collision(SL_sprite(handle1).collision.x1, SL_sprite(handle1).collision.y1,_
  912.                            SL_sprite(handle1).collision.cwidth, SL_sprite(handle1).collision.cheight,_
  913.                            SL_sprite(handle2).collision.x2, SL_sprite(handle2).collision.y2,_
  914.                            SL_sprite(handle2).collision.cwidth, SL_sprite(handle2).collision.cheight) THEN 'is there a box collision?
  915.         leftx = SL_max(SL_sprite(handle1).collision.x1, SL_sprite(handle2).collision.x1) '              yes, get collision area coordinates
  916.         rightx = SL_min(SL_sprite(handle1).collision.x1 + SL_sprite(handle1).collision.cwidth,_
  917.                         SL_sprite(handle2).collision.x1 + SL_sprite(handle2).collision.cwidth)
  918.         topy = SL_max(SL_sprite(handle1).collision.y1, SL_sprite(handle2).collision.y1)
  919.         bottomy = SL_min(SL_sprite(handle1).collision.y1 + SL_sprite(handle1).collision.cheight,_
  920.                          SL_sprite(handle2).collision.y1 + SL_sprite(handle2).collision.cheight)
  921.  
  922.         odest = _DEST '                                                                                 save original destination
  923.         osource = _SOURCE '                                                                             save original source
  924.         masks = _NEWIMAGE(rightx - leftx, bottomy - topy, 32) '                                         create image of same size to hold image masks
  925.         h1x = SL_sprite(handle1).x.int - leftx '                                                        get image mask center point offsets from collision area upper left x,y
  926.         h1y = SL_sprite(handle1).y.int - topy
  927.         h2x = SL_sprite(handle2).x.int - leftx
  928.         h2y = SL_sprite(handle2).y.int - topy
  929.         _DEST masks '                                                                                   masks are to be drawn on new image
  930.         _SOURCE masks '                                                                                 pixels are to be examined on new image
  931.         _PUTIMAGE (-h1x, -h1y), SL_sprite(handle1).gfx.mask '                                           draw first sprite mask onto image
  932.         _PUTIMAGE (-h2x, -h2y), SL_sprite(handle2).gfx.mask '                                           draw second sprite mask onto image
  933.         x = 0 '                                                                                         reset width couonter
  934.  
  935.         DO '                                                                                            cycle through width of image
  936.             y = 0 '                                                                                     reset height counter
  937.             DO '                                                                                        cycle through height of image
  938.                 IF POINT(x, y) = _RGBA32(0, 0, 0, 0) THEN '                                             is this a black pixel? <----------------------------------- used saved clearcolor instead?  LOOK
  939.                     SL_sprite(handle1).collision.with = handle2 '                                       yes, record sprite that was collided with
  940.                     SL_sprite(handle2).collision.with = handle1 '                                       tell the other sprite who it collided with
  941.                     SL_PIXEL_COLLISION = handle2 '                                              (TRUE)  return that collision happened
  942.                     y = _HEIGHT(masks) - 1 '                                                            no need to continue loop
  943.                     x = _WIDTH(masks) - 1 '                                                             no need to continue loop
  944.                 END IF
  945.                 y = y + 1 '                                                                             increment height counter
  946.             LOOP UNTIL y = _HEIGHT(masks) '                                                             leave when full height cycled
  947.             x = x + 1 '                                                                                 increment width counter
  948.         LOOP UNTIL x = _WIDTH(masks) '                                                                  leave when full width cycled
  949.  
  950.         _SOURCE osource '                                                                               restore original source
  951.         _DEST odest '                                                                                   restore original destination
  952.         _FREEIMAGE masks '                                                                              mask image no longer needed
  953.     END IF
  954.  
  955.  
  956. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  957. SUB SL_SET_COLLISION (handle AS INTEGER, method AS INTEGER) '                                                                                                                          SL_SET_COLLISION
  958.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  959.  
  960.     ' declare global variables
  961.  
  962.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  963.  
  964.     ' perform error checks
  965.  
  966.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  967.         SL_error "SL_SET_COLLISION", 1, "" '                                                            no, report error to programmer
  968.     END IF
  969.     IF method = -32767 THEN '                                                               (SL_RESET)  reset collision detection?
  970.         SL_sprite(handle).collision.detect = 0 '                                         (SL_NODETECT)  yes, reset detection
  971.     ELSEIF method < 0 OR method > 3 THEN ' (SL_NODETECT, SL_BOXDETECT, SL_ROUNDDETECT, SL_PIXELDETECT)  invalid mode?
  972.         SL_error "SL_SET_COLLISION", 24, "" '                                                           yes, report error to programmer
  973.     ELSE '                                                                                              no
  974.         SL_sprite(handle).collision.detect = method '                                                   set collision detection mode
  975.     END IF
  976.  
  977.  
  978. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  979. '                                                                     ----------==========                    ==========----------
  980. '                                                                     ----------========== ANIMATION ROUTINES ==========----------
  981. '                                                                     ----------==========                    ==========----------
  982. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  983.  
  984. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  985. SUB SL_SET_FRAMERATE (framerate AS INTEGER) '                                                                                                                                          SL_SET_FRAMERATE
  986.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  987.  
  988.     ' declare global variables
  989.  
  990.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  991.     SHARED SL_global AS SL_GLOBAL
  992.  
  993.     ' declare local variables
  994.  
  995.     DIM handle AS INTEGER '             counter to cycle through sprite handles
  996.  
  997.     ' perform error checks
  998.  
  999.     IF framerate < 1 THEN '                                                                             valid frame rate?
  1000.         SL_error "SL_SET_FRAMERATE", 10, "" '                                                           no, report error to programmer
  1001.     END IF
  1002.  
  1003.     ' set local variables
  1004.  
  1005.     SL_global.framerate = framerate '                                                                   set global frame rate
  1006.     handle = 0 '                                                                                        reset handle counter
  1007.  
  1008.     DO '                                                                                                update all available sprites
  1009.         handle = handle + 1 '                                                                           increment sprite pointer
  1010.         IF SL_sprite(handle).inuse THEN '                                                               is this sprite in use?
  1011.             IF SL_sprite(handle).animation.framerate THEN '                                             yes, does it contain an animation frame rate?
  1012.                 IF framerate < SL_sprite(handle).animation.framerate THEN '                             is new global frame rate less than sprite's frame rate?
  1013.                     SL_sprite(handle).animation.framerate = framerate '                                 yes, set sprite's frame rate to global frame rate
  1014.                 END IF
  1015.                 IF framerate = SL_sprite(handle).animation.framerate THEN '                             animation and global frame rates the same?
  1016.                     SL_sprite(handle).animation.skip = 0 '                                              yes, nothing needs to be done with frames
  1017.                 ELSEIF SL_sprite(handle).animation.framerate >= framerate \ 2 THEN '                    no, sprite frame rate 1/2 or less of master frame rate?
  1018.                     SL_sprite(handle).animation.skip = framerate \ (framerate - SL_sprite(handle).animation.framerate) ' yes, calculate every frame to skip
  1019.                 ELSE '                                                                                  no, sprite frame rate is greater than 1/2 of master frame rate
  1020.                     SL_sprite(handle).animation.skip = framerate \ SL_sprite(handle).animation.framerate ' calculate every frame to draw
  1021.                 END IF
  1022.             END IF
  1023.         END IF
  1024.     LOOP UNTIL handle = UBOUND(SL_sprite) '                                                             leave when all sprites updated
  1025.  
  1026.  
  1027. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1028. FUNCTION SL_GET_FRAMERATE () '                                                                                                                                                         SL_GET_FRAMERATE
  1029.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1030.  
  1031.     ' declare global variables
  1032.  
  1033.     SHARED SL_global AS SL_GLOBAL
  1034.  
  1035.     SL_GET_FRAMERATE = SL_global.framerate '                                                            return global frame rate
  1036.  
  1037.  
  1038. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1039. SUB SL_NEXT_ANIMATION_CELL (handle AS INTEGER) '                                                                                                                                 SL_NEXT_ANIMATION_CELL
  1040.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1041.  
  1042.     ' declare global variables
  1043.  
  1044.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1045.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  1046.  
  1047.     ' perform error checks
  1048.  
  1049.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1050.         SL_error "SL_NEXT_ANIMATION_CELL", 1, "" '                                                      no, report error to programmer
  1051.     END IF
  1052.     IF NOT SL_sprite(handle).animation.cellfrom THEN '                                                  has animation been assigned to this sprite?
  1053.         SL_error "SL_NEXT_ANIMATION_CELL", 15, "" '                                                     no, report error to programmer
  1054.     END IF
  1055.     IF SL_sprite(handle).animation.auto THEN '                                                          is this sprite under auto animation control?
  1056.         SL_error "SL_NEXT_ANIMATION_CELL", 18, "" '                                                     yes, report error to programmer
  1057.     END IF
  1058.  
  1059.     SELECT CASE SL_sprite(handle).animation.mode '                                                      which animation mode is this sprite using?
  1060.         CASE 0 '                                                                          (SL_FORWARD)  move forward through the cells
  1061.             SL_sprite(handle).animation.cell = SL_sprite(handle).animation.cell + 1 '                   increment animation cell
  1062.             IF SL_sprite(handle).animation.cell > SL_sprite(handle).animation.cellto THEN '             passed the last cell?
  1063.                 SL_sprite(handle).animation.cell = SL_sprite(handle).animation.cellfrom '               yes, go back to first cell
  1064.             END IF
  1065.         CASE 1 '                                                                         (SL_BACKWARD)  move backward through the cells
  1066.             SL_sprite(handle).animation.cell = SL_sprite(handle).animation.cell - 1 '                   decrement animation cell
  1067.             IF SL_sprite(handle).animation.cell < SL_sprite(handle).animation.cellfrom THEN '           passed the first cell?
  1068.                 SL_sprite(handle).animation.cell = SL_sprite(handle).animation.cellto '                 yes, go back to last cell
  1069.             END IF
  1070.         CASE 2 '                                                                        (SL_BACKFORTH)  ping-pong back and forth through the cells
  1071.             SL_sprite(handle).animation.cell = SL_sprite(handle).animation.cell + SL_sprite(handle).animation.dir ' increment/decrement animation cell
  1072.             IF SL_sprite(handle).animation.cell = SL_sprite(handle).animation.cellto OR _
  1073.                SL_sprite(handle).animation.cell = SL_sprite(handle).animation.cellfrom THEN '           is this the first or last cell?
  1074.                 SL_sprite(handle).animation.dir = -SL_sprite(handle).animation.dir '                    yes, reverse animation direction
  1075.             END IF
  1076.     END SELECT
  1077.     SL_sprite(handle).cell = SL_sprite(handle).animation.cell '                                         update current sprite cell
  1078.     IF SL_sprite(handle).rotation.angle AND (NOT SL_sprite(handle).rotation.auto) THEN '                is this animation currently rotated but not automatic?
  1079.         SL_ROTATE_SPRITE handle, SL_sprite(handle).rotation.angle '                                     yes, this new cell will need manually rotated as well
  1080.     ELSE '                                                                                              no rotation, but still needs image updated
  1081.         _FREEIMAGE SL_sprite(handle).gfx.software '                                                     remove current software image from memory
  1082.         SL_sprite(handle).gfx.software = _COPYIMAGE(SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).cell).software, 32) ' get new software image
  1083.         IF SL_sprite(handle).gfx.mask THEN '                                                            is there a mask with this image?
  1084.             _FREEIMAGE SL_sprite(handle).gfx.mask '                                                     yes, remove the software mask image from memory
  1085.             SL_sprite(handle).gfx.mask = _COPYIMAGE(SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).cell).mask, 32) ' get new software mask image
  1086.         END IF
  1087.     END IF
  1088.  
  1089.  
  1090. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1091. SUB SL_CHANGE_ANIMATION_CELLS (handle AS INTEGER, cellfrom AS INTEGER, cellto AS INTEGER) '                                                                                   SL_CHANGE_ANIMATION_CELLS
  1092.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1093.  
  1094.     ' declare global variables
  1095.  
  1096.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1097.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  1098.  
  1099.     ' perform error checks
  1100.  
  1101.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1102.         SL_error "SL_CHANGE_ANIMATION_CELLS", 1, "" '                                                   no, report error to programmer
  1103.     END IF
  1104.     IF NOT SL_sprite(handle).animation.cellfrom THEN '                                                  has animation been assigned to this sprite?
  1105.         SL_error "SL_CHANGE_ANIMATION_CELLS", 15, "" '                                                  no, report error to programmer
  1106.     END IF
  1107.     IF NOT SL_VALID_CELL(SL_sprite(handle).sheet, cellfrom) THEN '                                      no, is this a valid cell request?
  1108.         SL_error "SL_CHANGE_ANIMATION_CELLS", 13, "" '                                                  no, report error to rpogrammer
  1109.     END IF
  1110.     IF NOT SL_VALID_CELL(SL_sprite(handle).sheet, cellto) THEN '                                        is this valid cell request?
  1111.         SL_error "SL_CHANGE_ANIMATION_CELLS", 13, "" '                                                  no, report error to programmer
  1112.     END IF
  1113.  
  1114.     SL_sprite(handle).animation.cellfrom = cellfrom '                                                   set first cell in animation
  1115.     SL_sprite(handle).animation.cellto = cellto '                                                       set last cell in animation
  1116.     SL_sprite(handle).animation.cell = cellfrom '                                                       set current animation cell to first cell
  1117.     SL_sprite(handle).cell = cellfrom '                                                                 set current sprite cell to first cell
  1118.  
  1119.     IF SL_sprite(handle).animation.cellto < SL_sprite(handle).animation.cellfrom THEN '                 is cellto greater than cellfrom?
  1120.         SL_error "SL_CHANGE_ANIMATION_CELLS", 19, "" '                                                  no, report error to programmer
  1121.     END IF
  1122.  
  1123.     IF SL_sprite(handle).rotation.angle AND (NOT SL_sprite(handle).rotation.auto) THEN '                is this animation currently rotated but not automatic?
  1124.         SL_ROTATE_SPRITE handle, SL_sprite(handle).rotation.angle '                                     yes, this new cell will need manually rotated as well
  1125.     ELSE '                                                                                              no rotation, but still needs image updated
  1126.         _FREEIMAGE SL_sprite(handle).gfx.software '                                                     remove current software image from memory
  1127.         SL_sprite(handle).gfx.software = _COPYIMAGE(SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).cell).software, 32) ' get new software image
  1128.         IF SL_sprite(handle).gfx.mask THEN '                                                            is there a mask with this image?
  1129.             _FREEIMAGE SL_sprite(handle).gfx.mask '                                                     yes, remove the software mask image from memory
  1130.             SL_sprite(handle).gfx.mask = _COPYIMAGE(SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).cell).mask, 32) ' get new software mask image
  1131.         END IF
  1132.     END IF
  1133.  
  1134.  
  1135. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1136. SUB SL_CHANGE_ANIMATION_FRAMERATE (handle AS INTEGER, framerate AS INTEGER) '                                                                                             SL_CHANGE_ANIMATION_FRAMERATE
  1137.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1138.     ' declare global variables
  1139.  
  1140.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1141.     SHARED SL_global AS SL_GLOBAL '     common globals array
  1142.  
  1143.     ' perform error checks
  1144.  
  1145.     IF framerate < 1 OR framerate > SL_global.framerate THEN '                                          valid frame rate supplied?
  1146.         SL_error "SL_CHANGE_ANIMATION_FRAMERATE", 11, "" '                                              no, report error to programmer
  1147.     END IF
  1148.  
  1149.     SL_sprite(handle).animation.framerate = framerate '                                                 save sprite frame rate
  1150.     IF SL_global.framerate = framerate THEN '                                                           animation and global frame rates the same?
  1151.         SL_sprite(handle).animation.skip = 0 '                                                          yes, nothing needs to be done with frames
  1152.     ELSEIF framerate >= SL_global.framerate \ 2 THEN '                                                  no, sprite frame rate 1/2 or less of master frame rate?
  1153.         SL_sprite(handle).animation.skip = SL_global.framerate \ (SL_global.framerate - framerate) '    yes, calculate every frame to skip
  1154.     ELSE '                                                                                              no, sprite frame rate is greater than 1/2 of master frame rate
  1155.         SL_sprite(handle).animation.skip = SL_global.framerate \ framerate '                            calculate every frame to draw
  1156.     END IF
  1157.  
  1158.  
  1159. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1160. SUB SL_CHANGE_AUTOANIMATION (handle AS INTEGER, auto AS INTEGER) '                                                                                                              SL_CHANGE_AUTOANIMATION
  1161.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1162.  
  1163.     ' declare global variables
  1164.  
  1165.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1166.  
  1167.     ' perform error checks
  1168.  
  1169.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1170.         SL_error "SL_CHANGE_AUTOANIMATION", 1, "" '                                                     no, report error to programmer
  1171.     END IF
  1172.     IF auto < -1 OR auto > 0 THEN '                                                                     valid auto animation value?
  1173.         SL_error "SL_CHANGE_ANIMATION", 14, "" '                                                        no, report error to programmer
  1174.     END IF
  1175.  
  1176.     SL_sprite(handle).animation.auto = auto '                                     (SL_START & SL_STOP)  set auto-animation
  1177.  
  1178.  
  1179. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1180. SUB SL_SET_ANIMATION (handle AS INTEGER, cellfrom AS INTEGER, cellto AS INTEGER, mode AS INTEGER, framerate AS INTEGER, auto AS INTEGER) '                                             SL_SET_ANIMATION
  1181.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1182.  
  1183.     ' declare global variables
  1184.  
  1185.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1186.     SHARED SL_global AS SL_GLOBAL '     common globals array
  1187.  
  1188.     ' perform error checks
  1189.  
  1190.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1191.         SL_error "SL_SET_ANIMATION", 1, "" '                                                            no, report error to programmer
  1192.     END IF
  1193.     IF framerate < 1 OR framerate > SL_global.framerate THEN '                                          valid frame rate supplied?
  1194.         SL_error "SL_SET_ANIMATION", 11, "" '                                                           no, report error to programmer
  1195.     END IF
  1196.     IF mode < 0 OR mode > 2 THEN '                                                                      valid animation mode supplied?
  1197.         SL_error "SL_SET_ANIMATION", 12, "" '                                                           no, report error to programmer
  1198.     END IF
  1199.     IF cellfrom <> -1 THEN '                                                          (SL_CURRENTCELL)  is the current cell being requested for cellfrom?
  1200.         IF cellfrom < 1 OR (NOT SL_VALID_CELL(SL_sprite(handle).sheet, cellfrom)) THEN '                no, is this a valid cell request? <----------------------------- line need modified?   LOOK
  1201.             SL_error "SL_SET_ANIMATION", 13, "" '                                                       no, report error to rpogrammer
  1202.         END IF
  1203.     END IF
  1204.     IF cellto < 1 OR (NOT SL_VALID_CELL(SL_sprite(handle).sheet, cellto)) THEN '                        is this valid cell request?
  1205.         SL_error "SL_SET_ANIMATION", 13, "" '                                                           no, report error to programmer
  1206.     END IF
  1207.     IF auto < -1 OR auto > 0 THEN '                                                                     valid auto animation value?
  1208.         SL_error "SL_SET_ANIMATION", 14, "" '                                                           no, report error to programmer
  1209.     END IF
  1210.  
  1211.     IF cellfrom = -1 THEN '                                                           (SL_CURRENTCELL)  use current cell as start cell?
  1212.         SL_sprite(handle).animation.cellfrom = SL_sprite(handle).animation.cell '                       yes, set first cell as current cell
  1213.     ELSE '                                                                                              no
  1214.         SL_sprite(handle).animation.cell = cellfrom '                                                   set starting cell
  1215.         SL_sprite(handle).animation.cellfrom = cellfrom '                                               set first cell in animation
  1216.     END IF
  1217.     SL_sprite(handle).animation.cellto = cellto '                                                       set last cell in animation
  1218.  
  1219.     IF cellto <= cellfrom THEN '                                                                        is cellto greater than cellfrom?
  1220.         SL_error "SL_SET_ANIMATION", 19, "" '                                                           no, report error to programmer
  1221.     END IF
  1222.  
  1223.     SL_sprite(handle).animation.framerate = framerate '                                                 save sprite frame rate
  1224.     IF SL_global.framerate = framerate THEN '                                                           animation and global frame rates the same?
  1225.         SL_sprite(handle).animation.skip = 0 '                                                          yes, nothing needs to be done with frames
  1226.     ELSEIF framerate >= SL_global.framerate \ 2 THEN '                                                  no, sprite frame rate 1/2 or less of master frame rate?
  1227.         SL_sprite(handle).animation.skip = SL_global.framerate \ (SL_global.framerate - framerate) '    yes, calculate every frame to skip
  1228.     ELSE '                                                                                              no, sprite frame rate is greater than 1/2 of master frame rate
  1229.         SL_sprite(handle).animation.skip = SL_global.framerate \ framerate '                            calculate every frame to draw
  1230.     END IF
  1231.     SL_sprite(handle).animation.frame = 0 '                                                             reset skip frame counter
  1232.     SL_sprite(handle).animation.mode = mode '                (SL_FORWARD & SL_BACKWARD & SL_BACKFORTH)  set animation mode
  1233.     IF mode = 0 OR mode = 2 THEN '                                        (SL_FORWARD or SL_BACKFORTH)  forward or back and forth?
  1234.         SL_sprite(handle).animation.dir = 1 '                                                           yes, set animation direction forward
  1235.     ELSE '                                                                               (SL_BACKWARD)  no, backward
  1236.         SL_sprite(handle).animation.dir = -1 '                                                          set animation direction backward
  1237.     END IF
  1238.     SL_sprite(handle).animation.auto = auto '                                     (SL_START & SL_STOP)  set auto-animation
  1239.  
  1240.  
  1241. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1242. FUNCTION SL_GET_CELL (handle AS INTEGER) '                                                                                                                                                  SL_GET_CELL
  1243.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1244.  
  1245.     ' declare global variables
  1246.  
  1247.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1248.  
  1249.     ' perform error checks
  1250.  
  1251.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1252.         SL_error "SL_GET_CELL", 1, "" '                                                                 no, report error to programmer
  1253.     END IF
  1254.  
  1255.     SL_GET_CELL = SL_sprite(handle).animation.cell '                                                    return animation cell of this sprite < --------------------- animation or sprite cell?   LOOK
  1256.  
  1257.  
  1258. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1259. FUNCTION SL_VALID_CELL (sheet AS INTEGER, cell AS INTEGER) '                                                                                                                              SL_VALID_CELL
  1260.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1261.  
  1262.     ' declare global variables
  1263.  
  1264.     SHARED SL_sheet() AS SL_SHEET '    master sprite sheet array
  1265.  
  1266.     IF NOT SL_VALID_SHEET(sheet) THEN '                                                                 is this a valid sheet?
  1267.         SL_error "SL_VALID_CELL", 5, "" '                                                               no, report error to programmer
  1268.     END IF
  1269.  
  1270.     IF (cell < 1) OR (cell > UBOUND(SL_sheet, 2)) THEN '                                                is cell withing range of cells on sheet?
  1271.         SL_VALID_CELL = 0 '                                                                    (FALSE)  no, return false for invalid cell
  1272.     ELSE '                                                                                              yes, within total cells
  1273.         SL_VALID_CELL = -1 '                                                                    (TRUE)  return true for valid cell
  1274.     END IF
  1275.  
  1276.  
  1277. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  1278. '                                                                       ----------==========                 ==========----------
  1279. '                                                                       ----------========== MOTION ROUTINES ==========----------
  1280. '                                                                       ----------==========                 ==========----------
  1281. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  1282.  
  1283. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1284. SUB SL_REVERSE_MOTIONX (handle AS INTEGER) '                                                                                                                                         SL_REVERSE_MOTIONX
  1285.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1286.  
  1287.     ' declare global variables
  1288.  
  1289.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1290.  
  1291.     ' perform error checks
  1292.  
  1293.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1294.         SL_error "SL_REVERSE_MOTIONX", 1, "" '                                                          no, report error to programmer
  1295.     END IF
  1296.  
  1297.     SL_sprite(handle).x.dir = -SL_sprite(handle).x.dir '                                                reverse x motion direction
  1298.  
  1299.  
  1300. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1301. SUB SL_REVERSE_MOTIONY (handle AS INTEGER) '                                                                                                                                         SL_REVERSE_MOTIONY
  1302.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1303.  
  1304.     ' declare global variables
  1305.  
  1306.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1307.  
  1308.     ' perform error checks
  1309.  
  1310.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1311.         SL_error "SL_REVERSE_MOTIONY", 1, "" '                                                          no, report error to programmer
  1312.     END IF
  1313.  
  1314.     SL_sprite(handle).y.dir = -SL_sprite(handle).y.dir '                                                reverse y motion direction
  1315.  
  1316.  
  1317. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1318. FUNCTION SL_GET_MOTIONX (handle AS INTEGER) '                                                                                                                                            SL_GET_MOTIONX
  1319.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1320.  
  1321.     ' declare global variables
  1322.  
  1323.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1324.  
  1325.     ' perform error checks
  1326.  
  1327.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1328.         SL_error "SL_GET_MOTIONX", 1, "" '                                                              no, report error to programmer
  1329.     END IF
  1330.  
  1331.     SL_GET_MOTIONX = SL_sprite(handle).x.dir '                                                          return x motion direction
  1332.  
  1333.  
  1334. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1335. FUNCTION SL_GET_MOTIONY (handle AS INTEGER) '                                                                                                                                            SL_GET_MOTIONY
  1336.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1337.  
  1338.     ' declare global variables
  1339.  
  1340.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1341.  
  1342.     ' perform error checks
  1343.  
  1344.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1345.         SL_error "SL_GET_MOTIONY", 1, "" '                                                              no, report error to programmer
  1346.     END IF
  1347.  
  1348.     SL_GET_MOTIONY = SL_sprite(handle).y.dir '                                                          return y motion direction
  1349.  
  1350.  
  1351. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1352. SUB SL_SET_MOTIONX (handle AS INTEGER, xdir AS SINGLE) '                                                                                                                                 SL_SET_MOTIONX
  1353.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1354.     ' declare global variables
  1355.  
  1356.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1357.  
  1358.     ' perform error checks
  1359.  
  1360.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1361.         SL_error "SL_SET_MOTIONX", 1, "" '                                                              no, report error to programmer
  1362.     END IF
  1363.  
  1364.     SL_sprite(handle).x.dir = xdir '                                                                    set x motion direction
  1365.  
  1366.  
  1367. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1368. SUB SL_SET_MOTIONY (handle AS INTEGER, ydir AS SINGLE) '                                                                                                                                 SL_SET_MOTIONY
  1369.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1370.  
  1371.     ' declare global variables
  1372.  
  1373.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1374.  
  1375.     ' perform error checks
  1376.  
  1377.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1378.         SL_error "SL_SET_MOTIONY", 1, "" '                                                              no, report error to programmer
  1379.     END IF
  1380.  
  1381.     SL_sprite(handle).y.dir = ydir '                                                                    set y motion direction
  1382.  
  1383.  
  1384. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1385. SUB SL_UPDATE_MOTION (handle AS INTEGER) '                                                                                                                                             SL_UPDATE_MOTION
  1386.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1387.  
  1388.     ' declare global variables
  1389.  
  1390.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1391.  
  1392.     ' perform error checks
  1393.  
  1394.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1395.         SL_error "SL_UPDATE_MOTION", 1, "" '                                                            no, report error to programmer
  1396.     END IF
  1397.     IF SL_sprite(handle).motion.auto THEN '                                                             attempt to move sprite under automatic control?
  1398.         SL_error "SL_UPDATE_MOTION", 16, "" '                                                           yes, report error to programmer
  1399.     END IF
  1400.  
  1401.     SL_sprite(handle).x.real = SL_sprite(handle).x.real + SL_sprite(handle).x.dir '                     update x location
  1402.     SL_sprite(handle).y.real = SL_sprite(handle).y.real + SL_sprite(handle).y.dir '                     update y location
  1403.     SL_PUT_SPRITE SL_sprite(handle).x.real, SL_sprite(handle).y.real, handle '                          update sprite location
  1404.  
  1405.  
  1406. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1407. SUB SL_SET_MOTION (handle AS INTEGER, degrees AS INTEGER, speed AS SINGLE, auto AS INTEGER) '                                                                                            SL_SET_MOTION
  1408.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1409.  
  1410.     ' declare global variables
  1411.  
  1412.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1413.  
  1414.     ' perform error checks
  1415.  
  1416.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1417.         SL_error "SL_SET_MOTION", 1, "" '                                                               no, report error to programmer
  1418.     END IF
  1419.     IF auto < -1 OR auto > 0 THEN '                                               (SL_START & SL_STOP)  valid on/off switch supplied?
  1420.         SL_error "SL_SET_MOTION", 7, "" '                                                               no, report error to programmer
  1421.     END IF
  1422.  
  1423.     SL_sprite(handle).motion.speed = speed '                                                            set motion speed of sprite
  1424.     SL_CHANGE_MOTION_DIRECTION handle, SL_FIX_DEGREES(degrees) '                                        set motion angle of sprite
  1425.     SL_sprite(handle).motion.auto = auto '                                        (SL_START & SL_STOP)  set auto-motion of sprite
  1426.  
  1427.  
  1428. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1429. SUB SL_CHANGE_MOTION_DIRECTION (handle AS INTEGER, degrees AS INTEGER) '                                                                                                     SL_CHANGE_MOTION_DIRECTION
  1430.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1431.  
  1432.     ' declare global variables
  1433.  
  1434.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1435.  
  1436.     ' delcare local variables
  1437.  
  1438.     DIM degree AS INTEGER '             degree angle passed in
  1439.  
  1440.     ' perform error checks
  1441.  
  1442.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1443.         SL_error "SL_CHANGE_MOTION_DIRECTION", 1, "" '                                                  no, report error to programmer
  1444.     END IF
  1445.  
  1446.     degree = SL_FIX_DEGREES(degrees) '                                                                  get degree angle passed in
  1447.     SL_sprite(handle).motion.angle = degree '                                                           set motion degree angle
  1448.     SL_sprite(handle).x.dir = SIN(degree * .017453292) * SL_sprite(handle).motion.speed '               calculate x vector
  1449.     SL_sprite(handle).y.dir = -COS(degree * .017453292) * SL_sprite(handle).motion.speed '              calculate y vector
  1450.  
  1451.  
  1452. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1453. FUNCTION SL_GET_MOTION_DIRECTION (handle AS INTEGER) '                                                                                                                          SL_GET_MOTION_DIRECTION
  1454.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1455.  
  1456.     ' declare global variables
  1457.  
  1458.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1459.  
  1460.     ' perform error checks
  1461.  
  1462.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1463.         SL_error "SL_GET_MOTION_DIRECTION", 1, "" '                                                     no, report error to programmer
  1464.     END IF
  1465.  
  1466.     SL_GET_MOTION_DIRECTION = SL_sprite(handle).motion.angle '                                          return direction sprite currently set to
  1467.  
  1468.  
  1469. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1470. SUB SL_CHANGE_MOTION_SPEED (handle AS INTEGER, speed AS SINGLE) '                                                                                                                SL_CHANGE_MOTION_SPEED
  1471.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1472.  
  1473.     ' declare global variables
  1474.  
  1475.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1476.  
  1477.     ' perform error checks
  1478.  
  1479.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1480.         SL_error "SL_CHANGE_MOTION_SPEED", 1, "" '                                                      no, report error to programmer
  1481.     END IF
  1482.  
  1483.     SL_sprite(handle).motion.speed = speed '                                                            set sprite motion speed
  1484.     SL_sprite(handle).x.dir = SIN(SL_sprite(handle).motion.angle * .017453292) * speed '                calculate x vector
  1485.     SL_sprite(handle).y.dir = -COS(SL_sprite(handle).motion.angle * .017453292) * speed '               calculate y vector
  1486.  
  1487.  
  1488. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1489. FUNCTION SL_GET_MOTION_SPEED (handle AS INTEGER) '                                                                                                                                  SL_GET_MOTION_SPEED
  1490.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1491.  
  1492.     ' declare global variables
  1493.  
  1494.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1495.  
  1496.     ' perform error checks
  1497.  
  1498.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1499.         SL_error "SL_GET_MOTION_SPEED", 1, "" '                                                         no, report error to programmer
  1500.     END IF
  1501.  
  1502.     SL_GET_MOTION_SPEED = SL_sprite(handle).motion.speed '                                              return current sprite motion speed
  1503.  
  1504.  
  1505. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1506. SUB SL_CHANGE_AUTOMOTION (handle AS INTEGER, auto AS INTEGER) '                                                                                                                    SL_CHANGE_AUTOMOTION
  1507.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1508.  
  1509.     ' declare global variables
  1510.  
  1511.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1512.  
  1513.     ' perform error checks
  1514.  
  1515.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1516.         SL_error "SL_CHANGE_AUTOMOTION", 1, "" '                                                        no, report error to programmer
  1517.     END IF
  1518.     IF auto = -32767 THEN '                                                                 (SL_RESET)  reset auto motion?
  1519.         SL_sprite(handle).motion.auto = 0 '                                                  (SL_STOP)  yes, turn auto motion off
  1520.     ELSEIF auto < -1 OR auto > 0 THEN '                                           (SL_START & SL_STOP)  valid on/off switch supplied?
  1521.         SL_error "SL_CHANGE_AUTOMOTION", 7, "" '                                                        no, report error to programmer
  1522.     ELSE '                                                                                              yes
  1523.         SL_sprite(handle).motion.auto = auto '                                          (TRUE & FALSE)  set auto motion status
  1524.     END IF
  1525.  
  1526.  
  1527. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1528. FUNCTION SL_GET_AUTOMOTION (handle AS INTEGER) '                                                                                                                                      SL_GET_AUTOMOTION
  1529.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1530.  
  1531.     ' declare global variables
  1532.  
  1533.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1534.  
  1535.     ' perform error checks
  1536.  
  1537.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1538.         SL_error "SL_GET_AUTOMOTION", 1, "" '                                                           no, report error to programmer
  1539.     END IF
  1540.  
  1541.     SL_GET_AUTOMOTION = SL_sprite(handle).motion.auto '                                 (TRUE & FALSE)  return auto motion status
  1542.  
  1543.  
  1544. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  1545. '                                                                      ----------==========                   ==========----------
  1546. '                                                                      ----------========== ROTATION ROUTINES ==========----------
  1547. '                                                                      ----------==========                   ==========----------
  1548. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  1549.  
  1550. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1551. SUB SL_UPDATE_ROTATION (handle AS INTEGER) '                                                                                                                                         SL_UPDATE_ROTATION
  1552.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1553.  
  1554.     ' declare global variables
  1555.  
  1556.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1557.  
  1558.     ' perform error checks
  1559.  
  1560.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1561.         SL_error "SL_UPDATE_ROTATION", 1, "" '                                                          no, report error to programmer
  1562.     END IF
  1563.     IF SL_sprite(handle).rotation.auto THEN '                                                           attempt to rotate sprite under automatic control?
  1564.         SL_error "SL_UPDATE_ROTATION", 17, "" '                                                         yes, report error to programmer
  1565.     END IF
  1566.  
  1567.     SL_ROTATE_SPRITE handle, SL_sprite(handle).rotation.angle + SL_sprite(handle).rotation.speed '      rotate sprite to next degree angle
  1568.     SL_PUT_SPRITE SL_sprite(handle).x.real, SL_sprite(handle).y.real, handle '                          update sprite rotation
  1569.  
  1570.  
  1571.  
  1572. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1573. SUB SL_SET_ROTATION (handle AS INTEGER, degrees AS INTEGER, speed AS INTEGER, auto AS INTEGER) '                                                                                        SL_SET_ROTATION
  1574.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1575.  
  1576.     ' declare global variables
  1577.  
  1578.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1579.  
  1580.     ' perform error checks
  1581.  
  1582.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1583.         SL_error "SL_SET_ROTATION", 1, "" '                                                             no, report error to programmer
  1584.     END IF
  1585.     IF auto < -1 OR auto > 0 THEN '                                               (SL_START & SL_STOP)  valid on/off switch supplied?
  1586.         SL_error "SL_SET_ROTATION", 8, "" '                                                             no, report error to programmer
  1587.     END IF
  1588.     IF ABS(degrees) > 359 THEN '                                                                        degree requested between -359 and 359?
  1589.         SL_error "SL_SET_ROTATION", 9, "" '                                                             no, report error to programmer
  1590.     END IF
  1591.  
  1592.     SL_sprite(handle).rotation.speed = speed '                                                          set rotation speed
  1593.     SL_ROTATE_SPRITE handle, degrees '                                                                  set start angle
  1594.     SL_sprite(handle).rotation.auto = auto '                                                            set auto-rotation
  1595.  
  1596.  
  1597. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1598. SUB SL_CHANGE_AUTOROTATION (handle AS INTEGER, auto AS INTEGER) '                                                                                                                SL_CHANGE_AUTOROTATION
  1599.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1600.  
  1601.     ' declare global variables
  1602.  
  1603.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1604.  
  1605.     ' perform error checks
  1606.  
  1607.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1608.         SL_error "SL_CHANGE_AUTOROTATION", 1, "" '                                                      no, report error to programmer
  1609.     END IF
  1610.     IF auto = -32767 THEN '                                                                 (SL_RESET)  reset auto rotate?
  1611.         SL_sprite(handle).rotation.auto = 0 '                                                  (FALSE)  yes, turn auto rotation off
  1612.     ELSEIF auto < -1 OR auto > 0 THEN '                                           (SL_START & SL_STOP)  valid on/off switch supplied?
  1613.         SL_error "SL_CHANGE_AUTOROTATION", 8, "" '                                                      no, report error to programmer
  1614.     ELSE '                                                                                              yes
  1615.         SL_sprite(handle).rotation.auto = auto '                                        (TRUE & FALSE)  set auto rotation status
  1616.     END IF
  1617.  
  1618.  
  1619. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1620. FUNCTION SL_GET_AUTOROTATION (handle AS INTEGER) '                                                                                                                                  SL_GET_AUTOROTATION
  1621.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1622.  
  1623.     ' declare global variables
  1624.  
  1625.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1626.  
  1627.     ' perform error checks
  1628.  
  1629.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1630.         SL_error "SL_GET_AUTOROTATION", 1, "" '                                                         no, report error to programmer
  1631.     END IF
  1632.  
  1633.     SL_GET_AUTOROTATION = SL_sprite(handle).rotation.auto '                             (TRUE & FALSE)  return auto rotation status
  1634.  
  1635.  
  1636. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1637. SUB SL_CHANGE_ROTATION_SPEED (handle AS INTEGER, degrees AS INTEGER) '                                                                                                         SL_CHANGE_ROTATION_SPEED
  1638.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1639.  
  1640.     ' declare global variables
  1641.  
  1642.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1643.  
  1644.     ' perform error checks
  1645.  
  1646.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1647.         SL_error "SL_CHANGE_ROTATION_SPEED", 1, "" '                                                    no, report error to programmer
  1648.     END IF
  1649.     IF degrees = -32767 THEN '                                                              (SL_RESET)  reset requested?
  1650.         SL_sprite(handle).rotation.speed = 0 '                                               (SL_STOP)  turn auto spin off
  1651.     ELSEIF ABS(degrees) > 359 THEN '                                                                    degree requested between -359 and 359?
  1652.         SL_error "SL_CHANGE_ROTATION_SPEED", 9, "" '                                                    no, report error to programmer
  1653.     ELSE '                                                                                              yes
  1654.         SL_sprite(handle).rotation.speed = degrees '                                                    set sprite spin rate
  1655.     END IF
  1656.  
  1657.  
  1658. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1659. FUNCTION SL_GET_ROTATION_SPEED (handle AS INTEGER) '                                                                                                                              SL_GET_ROTATION_SPEED
  1660.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1661.  
  1662.     ' declare global variables
  1663.  
  1664.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1665.  
  1666.     ' perform error checks
  1667.  
  1668.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1669.         SL_error "SL_GET_ROTATION_SPEED", 1, "" '                                                       no, report error to programmer
  1670.     END IF
  1671.  
  1672.     SL_GET_ROTATION_SPEED = SL_sprite(handle).rotation.speed '                                          return current sprite spin rate
  1673.  
  1674.  
  1675. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1676. SUB SL_ROTATE_SPRITE (handle AS INTEGER, degrees AS INTEGER) '                                                                                                                         SL_ROTATE_SPRITE
  1677.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1678.  
  1679.     ' declare global variables
  1680.  
  1681.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  1682.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1683.     SHARED SL_angle() AS SL_ANGLE '     master rotation array
  1684.  
  1685.     ' declare local variables
  1686.  
  1687.     DIM sw AS INTEGER '                 width of sprite to be drawn
  1688.     DIM sh AS INTEGER '                 height of sprite to be drawn
  1689.     DIM rw AS INTEGER '                 precalculated rotated sprite width
  1690.     DIM rh AS INTEGER '                 precalculated rotated sprite height
  1691.     DIM px0 AS INTEGER '                precalculated triangular coordinates
  1692.     DIM px1 AS INTEGER
  1693.     DIM px2 AS INTEGER
  1694.     DIM px3 AS INTEGER
  1695.     DIM py0 AS INTEGER
  1696.     DIM py1 AS INTEGER
  1697.     DIM py2 AS INTEGER
  1698.     DIM py3 AS INTEGER
  1699.     DIM image AS LONG '                 software sprite image
  1700.     DIM mask AS LONG '                  software sprite image mask
  1701.     DIM degree AS INTEGER '             angle of rotation
  1702.  
  1703.     ' perform error checks
  1704.  
  1705.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1706.         SL_error "SL_ROTATE_SPRITE", 1, "" '                                                            no, report error to programmer
  1707.     END IF
  1708.  
  1709.     ' check if rotation necessary
  1710.  
  1711.     degree = SL_FIX_DEGREES(degrees) '                                                                  correct degree angle if needed
  1712.  
  1713.     ' get default images and dimensions from sprite sheet
  1714.  
  1715.     image = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).cell).software '                        get image from sprite sheet
  1716.     mask = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).cell).mask '                             get mask from sprite sheet
  1717.     sw = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).cell).swidth '                             get default sprite width from sprite sheet
  1718.     sh = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).cell).sheight '                            get default sprite height from sprite sheet
  1719.  
  1720.     ' free existing images from memory
  1721.  
  1722.     _FREEIMAGE SL_sprite(handle).gfx.software '                                                         free software sprite image
  1723.     IF SL_sprite(handle).gfx.mask THEN _FREEIMAGE SL_sprite(handle).gfx.mask '                          free software mask image
  1724.  
  1725.     ' remove rotation (reset) if requested
  1726.  
  1727.     IF degrees = -32767 OR degree = 0 THEN '                                                (SL_RESET)  reset sprite rotation?
  1728.         SL_sprite(handle).rotation.angle = 0 '                                                          yes, reset rotation angle
  1729.         SL_sprite(handle).swidth = sw '                                                                 save sprite's width
  1730.         SL_sprite(handle).sheight = sh '                                                                save prite's height
  1731.         SL_sprite(handle).gfx.software = _COPYIMAGE(image, 32) '                                        copy software image from sprite sheet
  1732.         IF SL_sprite(handle).transparency THEN '                                                        does this sprite have a mask?
  1733.             SL_sprite(handle).gfx.mask = _COPYIMAGE(mask, 32) '                                         yes, copy software mask from sprite sheet
  1734.         END IF
  1735.         EXIT SUB '                                                                                      no rotation needed, leave subroutine
  1736.     END IF
  1737.  
  1738.     ' rotate sprite
  1739.  
  1740.     rw = SL_angle(SL_sprite(handle).sheet, SL_sprite(handle).cell, degree).rwidth '                     get precalculated rotated sprite width
  1741.     rh = SL_angle(SL_sprite(handle).sheet, SL_sprite(handle).cell, degree).rheight '                    get precalculated rotated sprite height
  1742.     px0 = SL_angle(SL_sprite(handle).sheet, SL_sprite(handle).cell, degree).px0 '                       get precalculated triangular coordinates
  1743.     px1 = SL_angle(SL_sprite(handle).sheet, SL_sprite(handle).cell, degree).px1
  1744.     px2 = SL_angle(SL_sprite(handle).sheet, SL_sprite(handle).cell, degree).px2
  1745.     px3 = SL_angle(SL_sprite(handle).sheet, SL_sprite(handle).cell, degree).px3
  1746.     py0 = SL_angle(SL_sprite(handle).sheet, SL_sprite(handle).cell, degree).py0
  1747.     py1 = SL_angle(SL_sprite(handle).sheet, SL_sprite(handle).cell, degree).py1
  1748.     py2 = SL_angle(SL_sprite(handle).sheet, SL_sprite(handle).cell, degree).py2
  1749.     py3 = SL_angle(SL_sprite(handle).sheet, SL_sprite(handle).cell, degree).py3
  1750.  
  1751.     SL_sprite(handle).gfx.software = _NEWIMAGE(rw, rh, 32) '                                            create new software sprite image
  1752.     _MAPTRIANGLE (0, 0)-(0, sh - 1)-(sw - 1, sh - 1), image TO(px0, py0)-(px1, py1)-(px2, py2), SL_sprite(handle).gfx.software ' map rotated sprite onto image
  1753.     _MAPTRIANGLE (0, 0)-(sw - 1, 0)-(sw - 1, sh - 1), image TO(px0, py0)-(px3, py3)-(px2, py2), SL_sprite(handle).gfx.software
  1754.     IF SL_sprite(handle).transparency THEN '                                                            does this sprite have a mask?
  1755.         SL_sprite(handle).gfx.mask = _NEWIMAGE(rw, rh, 32) '                                            yes, create new software mask image
  1756.         _MAPTRIANGLE (0, 0)-(0, sh - 1)-(sw - 1, sh - 1), mask TO(px0, py0)-(px1, py1)-(px2, py2), SL_sprite(handle).gfx.mask '  map rotated mask onto image
  1757.         _MAPTRIANGLE (0, 0)-(sw - 1, 0)-(sw - 1, sh - 1), mask TO(px0, py0)-(px3, py3)-(px2, py2), SL_sprite(handle).gfx.mask
  1758.     END IF
  1759.     SL_sprite(handle).swidth = rw '                                                                     save sprite's rotated width
  1760.     SL_sprite(handle).sheight = rh '                                                                    save sprite's rotated height
  1761.     SL_sprite(handle).rotation.angle = degree '                                                         save sprite's degree of rotation
  1762.  
  1763.  
  1764.  
  1765. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1766. FUNCTION SL_GET_ROTATION_ANGLE (handle AS INTEGER) '                                                                                                                              SL_GET_ROTATION_ANGLE
  1767.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1768.  
  1769.     ' declare global variables
  1770.  
  1771.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1772.  
  1773.     ' perform error checks
  1774.  
  1775.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1776.         SL_error "SL_GET_ROTATION_ANGLE", 1, "" '                                                       no, report error to programmer
  1777.     END IF
  1778.  
  1779.     SL_GET_ROTATION_ANGLE = SL_sprite(handle).rotation.angle '                                          return current angle of rotation
  1780.  
  1781.  
  1782. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1783. FUNCTION SL_FIX_DEGREES (degrees AS INTEGER) '                                                                                                                                           SL_FIX_DEGREES
  1784.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1785.  
  1786.     ' Credits: this function uses code contriibuted by codeguy
  1787.     '          https://www.qb64.org/forum/index.php?topic=537.15
  1788.  
  1789.     'declare local variables
  1790.  
  1791.     DIM degree AS INTEGER '             degree angle passed in
  1792.  
  1793.     ' set local variables
  1794.  
  1795.     degree = degrees MOD 360 '                                                                          get -359 to 359
  1796.     IF degree < 0 THEN '                                                                                need to make positive?
  1797.         SL_FIX_DEGREES = degree + 360 '                                                                 yes, correct value and return degree angle
  1798.     ELSE
  1799.         SL_FIX_DEGREES = degree '                                                                       no correction needed, return degree angle
  1800.     END IF
  1801.  
  1802.  
  1803.  
  1804. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  1805. '                                                                      ----------==========                   ==========----------
  1806. '                                                                      ----------========== LOCATION ROUTINES ==========----------
  1807. '                                                                      ----------==========                   ==========----------
  1808. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  1809.  
  1810.  
  1811. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1812. FUNCTION SL_GET_REALX (handle AS INTEGER) '                                                                                                                                                SL_GET_REALX
  1813.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1814.  
  1815.     ' declare global variables
  1816.  
  1817.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1818.  
  1819.     ' perform error checks
  1820.  
  1821.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1822.         SL_error "SL_GET_REALX", 1, "" '                                                                no, report error to programmer
  1823.     END IF
  1824.  
  1825.     SL_GET_REALX = SL_sprite(handle).x.real '                                                           return real number center point x
  1826.  
  1827.  
  1828. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1829. FUNCTION SL_GET_REALY (handle AS INTEGER) '                                                                                                                                                SL_GET_REALY
  1830.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1831.  
  1832.     ' declare global variables
  1833.  
  1834.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1835.  
  1836.     ' perform error checks
  1837.  
  1838.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1839.         SL_error "SL_GET_REALY", 1, "" '                                                                no, report error to programmer
  1840.     END IF
  1841.  
  1842.     SL_GET_REALY = SL_sprite(handle).y.real '                                                           return real number center point y
  1843.  
  1844.  
  1845. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1846. FUNCTION SL_GET_INTX (handle AS INTEGER) '                                                                                                                                                  SL_GET_INTX
  1847.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1848.  
  1849.     ' declare global variables
  1850.  
  1851.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1852.  
  1853.     ' perform error checks
  1854.  
  1855.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1856.         SL_error "SL_GET_INTX", 1, "" '                                                                 no, report error to programmer
  1857.     END IF
  1858.  
  1859.     SL_GET_INTX = SL_sprite(handle).x.int '                                                             return integer number center point x
  1860.  
  1861.  
  1862. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1863. FUNCTION SL_GET_INTY (handle AS INTEGER) '                                                                                                                                                  SL_GET_INTY
  1864.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1865.  
  1866.     ' declare global variables
  1867.  
  1868.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1869.  
  1870.     ' perform error checks
  1871.  
  1872.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1873.         SL_error "SL_GET_INTY", 1, "" '                                                                 no, report error to programmer
  1874.     END IF
  1875.  
  1876.     SL_GET_INTY = SL_sprite(handle).y.int '                                                             return integer number center point x
  1877.  
  1878.  
  1879. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1880. FUNCTION SL_GET_ACTUALX (handle AS INTEGER) '                                                                                                                                            SL_GET_ACTUALX
  1881.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1882.  
  1883.     ' declare global variables
  1884.  
  1885.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1886.  
  1887.     ' perform error checks
  1888.  
  1889.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1890.         SL_error "SL_GET_ACTUALX", 1, "" '                                                              no, report error to programmer
  1891.     END IF
  1892.  
  1893.     SL_GET_ACTUALX = SL_sprite(handle).x.actual '                                                       return integer number upper left point x
  1894.  
  1895.  
  1896. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1897. FUNCTION SL_GET_ACTUALY (handle AS INTEGER) '                                                                                                                                            SL_GET_ACTUALY
  1898.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1899.  
  1900.     ' declare global variables
  1901.  
  1902.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1903.  
  1904.     ' perform error checks
  1905.  
  1906.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1907.         SL_error "SL_GET_ACTUALY", 1, "" '                                                              no, report error to programmer
  1908.     END IF
  1909.  
  1910.     SL_GET_ACTUALY = SL_sprite(handle).y.actual '                                                       return integer number upper left point y
  1911.  
  1912.  
  1913. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1914. FUNCTION SL_GET_DISTANCE_POINT_TO_POINT (x1 AS INTEGER, y1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER) '                                                                   SL_GET_DISTANCE_POINT_TO_POINT
  1915.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1916.  
  1917.     'declare local variables
  1918.  
  1919.     DIM a AS INTEGER '                  side a of triangle
  1920.     DIM b AS INTEGER '                  side b of triangle
  1921.  
  1922.     'solve for c (hypotenuse)
  1923.  
  1924.     a = x1 - x2 '                                                                                       get length of side a
  1925.     b = y1 = y2 '                                                                                       get length of side b
  1926.  
  1927.     SL_GET_DISTANCE_POINT_TO_POINT = INT(SQR(a * a + b * b)) '                                          return length of side c
  1928.  
  1929.  
  1930. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1931. FUNCTION SL_GET_DISTANCE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                 SL_GET_DISTANCE_TO_SPRITE
  1932.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1933.  
  1934.     ' declare global variables
  1935.  
  1936.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1937.  
  1938.     'perform error checks
  1939.  
  1940.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  1941.         SL_error "SL_GET_DISTANCE_TO_SPRITE", 1, "" '                                                   no, report error to programmer
  1942.     END IF
  1943.  
  1944.     SL_GET_DISTANCE_TO_SPRITE = SL_GET_DISTANCE_POINT_TO_POINT(SL_sprite(handle1).x.int, SL_sprite(handle1).y.int, _
  1945.                                                                SL_sprite(handle2).x.int, SL_sprite(handle2).y.int) '  return distance to sprite 2
  1946.  
  1947.  
  1948. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1949. FUNCTION SL_GET_DISTANCE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                                                            SL_GET_DISTANCE_TO_POINT
  1950.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1951.  
  1952.     ' declare global variables
  1953.  
  1954.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1955.  
  1956.     'perform error checks
  1957.  
  1958.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1959.         SL_error "SL_GET_DISTANCE_TO_POINT", 1, "" '                                                    no, report error to programmer
  1960.     END IF
  1961.  
  1962.     SL_GET_DISTANCE_TO_POINT = SL_GET_DISTANCE_POINT_TO_POINT(SL_sprite(handle).x.int, SL_sprite(handle).y.int, x, y) ' return distance to point
  1963.  
  1964.  
  1965. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1966. FUNCTION SL_GET_ANGLE_POINT_TO_POINT (x1 AS INTEGER, y1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER) '                                                                         SL_GET_ANGLE_POINT_TO_POINT
  1967.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1968.  
  1969.     'declare local variables
  1970.  
  1971.     DIM angle AS INTEGER '              angle from first x,y location to second x,y location
  1972.  
  1973.     IF y1 = y2 THEN '                                                                                   both y values same?
  1974.         IF x1 = x2 THEN '                                                                               yes, both x values same?
  1975.             EXIT FUNCTION '                                                                             yes, there is no angle (0), leave
  1976.         END IF
  1977.         IF x2 > x1 THEN '                                                                               is second x to the right of first x?
  1978.             SL_GET_ANGLE_POINT_TO_POINT = 90 '                                                          yes, the angle must be 90 degrees
  1979.         ELSE '                                                                                          no, second x is to the left of first x
  1980.             SL_GET_ANGLE_POINT_TO_POINT = 270 '                                                         the angle must be 270 degrees
  1981.         END IF
  1982.         EXIT FUNCTION '                                                                                 leave function, angle computed
  1983.     END IF
  1984.     IF x1 = x2 THEN '                                                                                   both x values same?
  1985.         IF y2 > y1 THEN '                                                                               yes, is second y lower than first y?
  1986.             SL_GET_ANGLE_POINT_TO_POINT = 180 '                                                         yes, the angle must be 180
  1987.         END IF
  1988.         EXIT FUNCTION '                                                                                 leave function, angle computed (angle is 0 if no calculation done)
  1989.     END IF
  1990.     angle = ATN((x2 - x1) / (y2 - y1)) * -57.2957795131 '                                               calculate initial angle
  1991.     IF y2 < y1 THEN '                                                                                   is second y higher than first y?
  1992.         IF x2 > x1 THEN '                                                                               yes, is second x to right of first x?
  1993.             SL_GET_ANGLE_POINT_TO_POINT = angle '                                                       yes, angle needs no adjustment
  1994.         ELSE '                                                                                          no, second x is to left of first x
  1995.             SL_GET_ANGLE_POINT_TO_POINT = angle + 360 '                                                 adjust angle accordingly
  1996.         END IF
  1997.     ELSE '                                                                                              no, second y is lower than first y
  1998.         SL_GET_ANGLE_POINT_TO_POINT = angle + 180 '                                                     adjust angle accordingly
  1999.     END IF
  2000.  
  2001.  
  2002. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2003. FUNCTION SL_GET_ANGLE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                       SL_GET_ANGLE_TO_SPRITE
  2004.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2005.  
  2006.     ' declare global variables
  2007.  
  2008.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2009.  
  2010.     'perform error checks
  2011.  
  2012.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  2013.         SL_error "SL_GET_ANGLE_TO_SPRITE", 1, "" '                                                      no, report error to programmer
  2014.     END IF
  2015.  
  2016.     SL_GET_ANGLE_TO_SPRITE = SL_GET_ANGLE_POINT_TO_POINT(SL_sprite(handle1).x.int, SL_sprite(handle1).y.int, _
  2017.                                                          SL_sprite(handle2).x.int, SL_sprite(handle2).y.int) ' return angle to sprite 2
  2018.  
  2019.  
  2020. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2021. FUNCTION SL_GET_ANGLE_FROM_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                   SL_GET_ANGLE_FROM_SPRITE
  2022.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2023.  
  2024.     ' declare global variables
  2025.  
  2026.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2027.  
  2028.     'perform error checks
  2029.  
  2030.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  2031.         SL_error "SL_GET_ANGLE_FROM_SPRITE", 1, "" '                                                    no, report error to programmer
  2032.     END IF
  2033.  
  2034.     SL_GET_ANGLE_FROM_SPRITE = SL_GET_ANGLE_POINT_TO_POINT(SL_sprite(handle2).x.int, SL_sprite(handle2).y.int, _
  2035.                                                            SL_sprite(handle1).x.int, SL_sprite(handle1).y.int) '  return angle from sprite 2
  2036.  
  2037.  
  2038. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2039. FUNCTION SL_GET_ANGLE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                                                                  SL_GET_ANGLE_TO_POINT
  2040.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2041.  
  2042.     ' declare global variables
  2043.  
  2044.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2045.  
  2046.     'perform error checks
  2047.  
  2048.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  2049.         SL_error "SL_GET_ANGLE_TO_POINT", 1, "" '                                                       no, report error to programmer
  2050.     END IF
  2051.  
  2052.     SL_GET_ANGLE_TO_POINT = SL_GET_ANGLE_POINT_TO_POINT(SL_sprite(handle).x.int, SL_sprite(handle).y.int, x, y) ' return angle to point x,y
  2053.  
  2054.  
  2055. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2056. FUNCTION SL_GET_ANGLE_FROM_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                                                              SL_GET_ANGLE_FROM_POINT
  2057.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2058.  
  2059.     ' declare global variables
  2060.  
  2061.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2062.  
  2063.     'perform error checks
  2064.  
  2065.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  2066.         SL_error "SL_GET_ANGLE_FROM_POINT", 1, "" '                                                     no, report error to programmer
  2067.     END IF
  2068.  
  2069.     SL_GET_ANGLE_FROM_POINT = SL_GET_ANGLE_POINT_TO_POINT(x, y, SL_sprite(handle).x.int, SL_sprite(handle).y.int) 'return angle from point x,y
  2070.  
  2071.  
  2072. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  2073. '                                                                       ----------==========                 ==========----------
  2074. '                                                                       ----------========== SPRITE ROUTINES ==========----------
  2075. '                                                                       ----------==========                 ==========----------
  2076. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  2077.  
  2078. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2079. SUB SL_SET_SPRITE_VISIBLE (handle AS INTEGER, visible AS INTEGER) '                                                                                                               SL_SET_SPRITE_VISIBLE
  2080.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2081.  
  2082.     ' declare global variables
  2083.  
  2084.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2085.  
  2086.     ' perform error checks
  2087.  
  2088.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  2089.         SL_error "SL_SET_SPRITE_VISIBLE", 1, "" '                                                       no, report error to programmer
  2090.     END IF
  2091.     IF (visible < -1) OR (visible > 0) THEN '                                      (SL_SHOW & SL_HIDE)  valid visible behavior requested?
  2092.         SL_error "SL_SET_SPRITE_VISIBLE", 20, "" '                                                      no, report error to programmer
  2093.     END IF
  2094.  
  2095.     SL_sprite(handle).visible = visible '                                          (SL_SHOW & SL_HIDE)  set visible mode
  2096.  
  2097.  
  2098. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2099. FUNCTION SL_COPY_SPRITE (handle AS INTEGER) '                                                                                                                                            SL_COPY_SPRITE
  2100.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2101.  
  2102.     ' declare global variables
  2103.  
  2104.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2105.  
  2106.     ' declare local variables
  2107.  
  2108.     DIM newhandle AS INTEGER '          handle of copied sprite
  2109.  
  2110.     ' perform error checks
  2111.  
  2112.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  2113.         SL_error "SL_COPY_SPRITE", 1, "" '                                                              no, report error to programmer
  2114.     END IF
  2115.  
  2116.     newhandle = 0 '                                                                                     initialize new handle counter
  2117.  
  2118.     ' increase sprite array's size if needed
  2119.  
  2120.     DO '                                                                                                look for next available handle
  2121.         newhandle = newhandle + 1 '                                                                     increment to next handle value
  2122.     LOOP UNTIL (NOT SL_sprite(newhandle).inuse) OR newhandle = UBOUND(SL_sprite) '                      stop looking when valid handle found
  2123.     IF SL_sprite(newhandle).inuse THEN '                                                                is the last array element in use?
  2124.         newhandle = newhandle + 1 '                                                                     yes, increment to next handle value
  2125.         REDIM _PRESERVE SL_sprite(newhandle) AS SL_SPRITE '                                             increase the size of the sprite array
  2126.     END IF
  2127.  
  2128.     ' copy new sprite
  2129.  
  2130.     SL_sprite(newhandle) = SL_sprite(handle) '                                                          copy entire sprite contents
  2131.     SL_sprite(newhandle).gfx.hardware = _COPYIMAGE(SL_sprite(handle).gfx.hardware, 33) '                create an actual copy of the hardware sprite
  2132.     SL_sprite(newhandle).gfx.software = _COPYIMAGE(SL_sprite(handle).gfx.software, 32) '                create an actual copy of the software image
  2133.     IF SL_sprite(handle).gfx.mask THEN '                                                                does the original contain a mask image?
  2134.         SL_sprite(newhandle).gfx.mask = _COPYIMAGE(SL_sprite(handle).gfx.mask, 32) '                    yes, create an actual copy of the software mask image
  2135.     END IF
  2136.  
  2137.     SL_COPY_SPRITE = newhandle '                                                                        return new sprite's handle pointer
  2138.  
  2139.  
  2140. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2141. SUB SL_STAMP_SPRITE (layer AS INTEGER, x AS INTEGER, y AS INTEGER, sheet AS INTEGER, cell AS INTEGER, degrees AS INTEGER, flip AS INTEGER, zoom AS INTEGER) '                           SL_STAMP_SPRITE
  2142.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2143.  
  2144.     ' declare global variables
  2145.  
  2146.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  2147.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2148.  
  2149.     ' declare local variables
  2150.  
  2151.     DIM tempsprite AS LONG '            temporary sprite to stamp
  2152.  
  2153.     ' perform error checks
  2154.  
  2155.     IF NOT SL_VALID_SHEET(sheet) THEN '                                                                 is this a valid sheet?
  2156.         SL_error "SL_STAMP_SPRITE", 5, "" '                                                             no, report error to programmer
  2157.     END IF
  2158.     IF NOT SL_VALID_CELL(sheet, cell) THEN '                                                            valid cell?
  2159.         SL_error "SL_STAMP_SPRITE", 13, "" '                                                            no, report error to programmer
  2160.     END IF
  2161.     IF flip < 0 OR flip > 3 THEN '                                                                      valid flip behavior requested?
  2162.         SL_error "SL_STAMP_SPRITE", 3, "" '                                                             no, report error to programmer
  2163.     END IF
  2164.     IF zoom < 1 THEN '                                                                                  valid zoom level requested?
  2165.         SL_error "SL_STAMP_SPRITE", 4, "" '                                                             no, report error to programmer
  2166.     END IF
  2167.     IF NOT SL_VALID_LAYER(layer) THEN '                                                                 valid layer?
  2168.         SL_error "SL_STAMP_SPRITE", 25, "" '                                                            no, report error to programmer
  2169.     END IF
  2170.  
  2171.     tempsprite = SL_NEW_SPRITE(layer, sheet, cell, 0, 0) '                                              create new temporary software sprite
  2172.     SL_sprite(tempsprite).rotation.speed = SL_FIX_DEGREES(degrees) '                                    set speed of rotation
  2173.     SL_sprite(tempsprite).flip = flip '                                                                 set flipping behavior
  2174.     SL_sprite(tempsprite).zoom = zoom '                                                                 set zoom level
  2175.     SL_PUT_SPRITE x, y, tempsprite '                                                                    place sprite on current destination
  2176.     SL_FREE_SPRITE tempsprite '                                                                         temporary sprite no longer needed
  2177.  
  2178.  
  2179.  
  2180. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2181. SUB SL_SET_SOFTWARE (handle AS INTEGER, restores AS INTEGER) '                                                                                                                          SL_SET_SOFTWARE
  2182.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2183.  
  2184.     ' declare global variables
  2185.  
  2186.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2187.  
  2188.     'perform error checks
  2189.  
  2190.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  2191.         SL_error "SL_SET_SOFTWARE", 1, "" '                                                             no, report error to programmer
  2192.     END IF
  2193.     IF restores < -1 OR restores > 0 THEN '                                                             valid background restoration behavior requested?
  2194.         SL_error "SL_SET_SOFTWARE", 2, "" '                                                             no, report error to programmer
  2195.     END IF
  2196.  
  2197.     SL_sprite(handle).software = -1 '                                                    (SL_SOFTWARE)  set sprite to software mode
  2198.     SL_sprite(handle).restore = restores '                                       (SL_SAVE & SL_NOSAVE)  set background saving behavior
  2199.  
  2200.  
  2201. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2202. SUB SL_SET_HARDWARE (handle AS INTEGER) '                                                                                                                                               SL_SET_HARDWARE
  2203.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2204.  
  2205.     ' declare global variables
  2206.  
  2207.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2208.  
  2209.     'perform error checks
  2210.  
  2211.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  2212.         SL_error "SL_SET_HARDWARE", 1, "" '                                                             no, report error to programmer
  2213.     END IF
  2214.  
  2215.     SL_sprite(handle).software = 0 '                                                     (SL_HARDWARE)  set sprite to hardware mode
  2216.  
  2217.  
  2218. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2219. SUB SL_SET_ZOOM (handle AS INTEGER, zoom AS INTEGER) '                                                                                                                                      SL_SET_ZOOM
  2220.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2221.  
  2222.     ' declare global variables
  2223.  
  2224.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2225.  
  2226.     ' perform error checks
  2227.  
  2228.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  2229.         SL_error "SL_SET_ZOOM", 1, "" '                                                                 no, report error to programmer
  2230.     END IF
  2231.     IF zoom = -32767 THEN '                                                                 (SL_RESET)  reset zoom level?
  2232.         SL_sprite(handle).zoom = 100 '                                                                  yes, reset level to normal
  2233.     ELSEIF zoom < 1 THEN '                                                                              valid zoom level requested?
  2234.         SL_error "SL_SET_ZOOM", 4, "" '                                                                 no, report error to programmer
  2235.     ELSE '                                                                                              yes
  2236.         SL_sprite(handle).zoom = zoom '                                                                 set zoom level
  2237.     END IF
  2238.  
  2239.  
  2240. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2241. SUB SL_FLIP_SPRITE (handle AS INTEGER, flip AS INTEGER) '                                                                                                                                SL_FLIP_SPRITE
  2242.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2243.  
  2244.     ' declare global variables
  2245.  
  2246.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2247.  
  2248.     ' perform error checks
  2249.  
  2250.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  2251.         SL_error "SL_FLIP_SPRITE", 1, "" '                                                              no, report error to programmer
  2252.     END IF
  2253.     IF flip = -32767 THEN '                                                                 (SL_RESET)  reset flipping behavior?
  2254.         SL_sprite(handle).flip = 0 '                                                       (SL_NOFLIP)  yes, reset flip value
  2255.     ELSEIF flip < 0 OR flip > 3 THEN '                                                                  valid flip behavior requested?
  2256.         SL_error "SL_FLIP_SPRITE", 3, "" '                                                              no, report error to programmer
  2257.     ELSE '                                                                                              yes
  2258.         SL_sprite(handle).flip = flip '           (SL_NOFLIP, SL_HORIZONTAL, SL_VERTICAL, SL_FLIPBOTH)  set flipping behavior
  2259.     END IF
  2260.  
  2261.  
  2262. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2263. SUB SL_PUT_SPRITE (x AS SINGLE, y AS SINGLE, handle AS INTEGER) '                                                                                                                         SL_PUT_SPRITE
  2264.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2265.  
  2266.     ' declare global variables
  2267.  
  2268.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2269.     SHARED SL_angle() AS SL_ANGLE '     master rotation array
  2270.  
  2271.     ' declare local variables
  2272.  
  2273.     DIM xa AS INTEGER '                 actual x location of sprite on screen
  2274.     DIM ya AS INTEGER '                 actual y location of sprite on screen
  2275.     DIM sw AS INTEGER '                 width of sprite to be drawn
  2276.     DIM sh AS INTEGER '                 height of sprite to be drawn
  2277.     DIM rw AS INTEGER '                 precalculated rotated sprite width
  2278.     DIM rh AS INTEGER '                 precalculated rotated sprite height
  2279.     DIM px0 AS INTEGER '                precalculated triangular coordinates
  2280.     DIM px1 AS INTEGER
  2281.     DIM px2 AS INTEGER
  2282.     DIM px3 AS INTEGER
  2283.     DIM py0 AS INTEGER
  2284.     DIM py1 AS INTEGER
  2285.     DIM py2 AS INTEGER
  2286.     DIM py3 AS INTEGER
  2287.     DIM image AS LONG '                 software sprite image
  2288.     DIM mask AS LONG '                  software sprite image mask
  2289.     DIM sprite AS LONG '                hardware sprite image
  2290.     DIM odest AS LONG '                 original destination layer
  2291.     DIM osource AS LONG '               original source layer
  2292.     DIM zoomfactor AS SINGLE '          zoom multiplication factor
  2293.     ' perform error checks
  2294.  
  2295.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  2296.         SL_error "SL_PUT_SPRITE", 1, "" '                                                               no, report error to programmer
  2297.     END IF
  2298.  
  2299.     'local variable setup
  2300.  
  2301.     'odest = _DEST '                                                                                     save original destination
  2302.     'osource = _SOURCE '                                                                                 save original source
  2303.     odest = SL_GET_DESTINATION_LAYER
  2304.     osource = SL_GET_SOURCE_LAYER
  2305.  
  2306.     SL_sprite(handle).x.real = x '                                                            (SINGLE)  save requested x center location
  2307.     SL_sprite(handle).y.real = y '                                                            (SINGLE)  save requested y center location
  2308.     SL_sprite(handle).x.int = INT(x) '                                                       (INTEGER)  save screen x center location
  2309.     SL_sprite(handle).y.int = INT(y) '                                                       (INTEGER)  save screen y center location
  2310.     sw = SL_sprite(handle).swidth '                                                                     get current sprite width
  2311.     sh = SL_sprite(handle).sheight '                                                                    get current sprite height
  2312.  
  2313.     'update hardware image
  2314.  
  2315.     _FREEIMAGE SL_sprite(handle).gfx.hardware '                                                         free previous hardware sprite image
  2316.     SL_sprite(handle).gfx.hardware = _COPYIMAGE(SL_sprite(handle).gfx.software, 33) '                   create new hardware sprite of image
  2317.  
  2318.     IF SL_sprite(handle).restore THEN '                                                                 is sprite holding a background image?
  2319.         IF SL_sprite(handle).gfx.back THEN '                                                            yes, has a background image been saved yet?
  2320.             SL_SET_DESTINATION_LAYER SL_sprite(handle).layer '                                          yes, set destination layer
  2321.             _PUTIMAGE (SL_sprite(handle).x.back, SL_sprite(handle).y.back), SL_sprite(handle).gfx.back 'replace background with image
  2322.             _FREEIMAGE SL_sprite(handle).gfx.back '                                                     free hardware background image
  2323.         END IF
  2324.         IF NOT SL_sprite(handle).software THEN '                                                        was the sprite type changed?
  2325.             SL_sprite(handle).restore = 0 '                                                (SL_NOSAVE)  yes, stop saving background
  2326.         END IF
  2327.     END IF
  2328.  
  2329.     'adjust zoom level if needed
  2330.  
  2331.     IF SL_sprite(handle).zoom <> 100 THEN '                                                             zoom sprite in/out?
  2332.         zoomfactor = SL_sprite(handle).zoom / 100
  2333.         'sw = sw * SL_sprite(handle).zoom * .01 '\ 100 '                                                        yes, calculate new zoom width
  2334.         'sh = sh * SL_sprite(handle).zoom * .01 '\ 100 '                                                        calculate new zoom height
  2335.         sw = sw * zoomfactor '                                                                          yes, calculate new zoom width
  2336.         sh = sh * zoomfactor '                                                                          calculate new zoom height
  2337.     ELSE
  2338.         zoomfactor = 1
  2339.     END IF
  2340.  
  2341.     'calculate actual sprite screen coordinates
  2342.  
  2343.     xa = SL_sprite(handle).x.int - sw \ 2 '                                                             calculate actual screen x location from center
  2344.     ya = SL_sprite(handle).y.int - sh \ 2 '                                                             calculate actual screen y location from center
  2345.     SL_sprite(handle).x.actual = xa '                                                        (INTEGER)  save actual screen x location
  2346.     SL_sprite(handle).y.actual = ya '                                                        (INTEGER)  save actual screen y location
  2347.  
  2348.     ' update collision box location based on actual x,y location, radius, and zoom factor
  2349.  
  2350.     SL_sprite(handle).collision.x1 = xa + SL_angle(SL_sprite(handle).sheet, SL_sprite(handle).cell, SL_sprite(handle).rotation.angle).x1 * zoomfactor
  2351.     SL_sprite(handle).collision.x2 = xa + SL_angle(SL_sprite(handle).sheet, SL_sprite(handle).cell, SL_sprite(handle).rotation.angle).x2 * zoomfactor
  2352.     SL_sprite(handle).collision.y1 = ya + SL_angle(SL_sprite(handle).sheet, SL_sprite(handle).cell, SL_sprite(handle).rotation.angle).y1 * zoomfactor
  2353.     SL_sprite(handle).collision.y2 = ya + SL_angle(SL_sprite(handle).sheet, SL_sprite(handle).cell, SL_sprite(handle).rotation.angle).y2 * zoomfactor
  2354.     SL_sprite(handle).collision.radius = SL_angle(SL_sprite(handle).sheet, SL_sprite(handle).cell, SL_sprite(handle).rotation.angle).radius * zoomfactor
  2355.  
  2356.     'get background image before placing sprite if necessary
  2357.  
  2358.     IF SL_sprite(handle).restore THEN '                                                                 is this sprite storing background images?
  2359.         SL_sprite(handle).gfx.back = _NEWIMAGE(sw, sh, 32) '                                            yes, create background image
  2360.         SL_SET_SOURCE_LAYER SL_sprite(handle).layer '                                                   set the source layer
  2361.         _PUTIMAGE , _SOURCE, SL_sprite(handle).gfx.back, (xa, ya)-(xa + sw - 1, ya + sh - 1) '          get background area from current source layer
  2362.         SL_sprite(handle).x.back = xa '                                                                 record background x location
  2363.         SL_sprite(handle).y.back = ya '                                                                 record background y location
  2364.     END IF
  2365.  
  2366.     'use hardware or software image
  2367.  
  2368.     IF SL_sprite(handle).software THEN '                                                                is this a software sprite?
  2369.         sprite = SL_sprite(handle).gfx.software '                                                       yes, use the software image
  2370.         SL_SET_DESTINATION_LAYER SL_sprite(handle).layer '                                              set the destination layer
  2371.     ELSE '                                                                                              no
  2372.         sprite = SL_sprite(handle).gfx.hardware '                                                       use the hardware image
  2373.         SL_SET_DESTINATION_LAYER 1 '                                                                    set the destination layer to first as default
  2374.     END IF
  2375.  
  2376.     ' place sprite on the current destination with desired flip method
  2377.  
  2378.     IF SL_sprite(handle).visible THEN '                                            (SL_SHOW & SL_HIDE)  show this sprite?
  2379.         SELECT CASE SL_sprite(handle).flip '                                                            yes, which flipping style is selected?
  2380.             CASE 0 '                                                                       (SL_NOFLIP)  normal, no flipping
  2381.                 _PUTIMAGE (xa, ya)-(xa + sw - 1, ya + sh - 1), sprite '                                 draw normal sprite
  2382.             CASE 1 '                                                                   (SL_HORIZONTAL)  flip horizontally
  2383.                 _PUTIMAGE (xa + sw - 1, ya)-(xa, ya + sh - 1), sprite '                                 draw horizontally flipped sprite
  2384.             CASE 2 '                                                                     (SL_VERTICAL)  flip vertically
  2385.                 _PUTIMAGE (xa, ya + sh - 1)-(xa + sw - 1, ya), sprite '                                 draw vertically flipped sprite
  2386.             CASE 3 '                                                                     (SL_FLIPBOTH)  flip vertically and horizontally
  2387.                 _PUTIMAGE (xa + sw - 1, ya + sh - 1)-(xa, ya), sprite '                                 draw horizontally and vertically flipped sprite
  2388.         END SELECT
  2389.     END IF
  2390.  
  2391.     '_SOURCE osource '                                                                                   restore original source
  2392.     '_DEST odest '                                                                                       restore original destination
  2393.     SL_SET_SOURCE_LAYER osource
  2394.     SL_SET_DESTINATION_LAYER odest
  2395.  
  2396.  
  2397. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2398. FUNCTION SL_NEW_SPRITE (layer AS INTEGER, sheet AS INTEGER, cell AS INTEGER, software AS INTEGER, restores AS INTEGER) '                                                                  SL_NEW_SPRITE
  2399.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2400.  
  2401.     ' declare global variables
  2402.  
  2403.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  2404.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2405.  
  2406.     ' declare local variables
  2407.  
  2408.     DIM handle AS INTEGER '             handle (pointer) number of new sprite
  2409.  
  2410.     ' perform error checks
  2411.  
  2412.     IF NOT SL_VALID_SHEET(sheet) THEN '                                                                 is this a valid sprite sheet?
  2413.         SL_error "SL_NEW_SPRITE", 5, "" '                                                               no, report error to programmer
  2414.     END IF
  2415.     IF NOT SL_VALID_CELL(sheet, cell) THEN '                                                            valid cell?
  2416.         SL_error "SL_NEW_SPRITE", 13, "" '                                                              no, report error to programmer
  2417.     END IF
  2418.     IF NOT SL_VALID_LAYER(layer) THEN '                                                                 valid layer?
  2419.         SL_error "SL_NEW_SPRITE", 25, "" '                                                              no, report error to programmer
  2420.     END IF
  2421.     IF restores < -1 OR restores > 0 THEN '                                                             valid background restoration behavior requested?
  2422.         SL_error "SL_NEW_SPRITE", 2, "" '                                                               no, report error to programmer
  2423.     END IF
  2424.     IF software < -1 OR software > 0 THEN '                                                             valid hardware / software setting requested?
  2425.         SL_error "SL_NEW_SPRITE", 112, "" '                                                             no, report error to programmer
  2426.     END IF
  2427.     IF (NOT software) AND restores THEN '                                                               hardware image that restores background?
  2428.         SL_error "SL_NEW_SPRITE", 113, "" '                                                             yes, report error to programmer
  2429.     END IF
  2430.  
  2431.     ' local variable setup
  2432.  
  2433.     handle = 0 '                                                                                        initialize handle value
  2434.  
  2435.     ' increase sprite array's size if needed
  2436.  
  2437.     DO '                                                                                                look for next available handle
  2438.         handle = handle + 1 '                                                                           increment to next handle value
  2439.     LOOP UNTIL (NOT SL_sprite(handle).inuse) OR handle = UBOUND(SL_sprite) '                            stop looking when valid handle found
  2440.     IF SL_sprite(handle).inuse THEN '                                                                   is the last array element in use?
  2441.         handle = handle + 1 '                                                                           yes, increment to next handle value
  2442.         REDIM _PRESERVE SL_sprite(handle) AS SL_SPRITE '                                                increase the size of the sprite array
  2443.     END IF
  2444.  
  2445.     ' populate sprite array, general settings
  2446.  
  2447.     SL_sprite(handle).inuse = -1 '                                                              (TRUE)  mark array index as in use
  2448.     SL_sprite(handle).sheet = sheet '                                                                   point to sheet where sprite resides
  2449.     SL_sprite(handle).cell = cell '                                                                     cell sprite is located in on sheet
  2450.     SL_sprite(handle).software = software '                                (SL_SOFTWARE & SL_HARDWARE)  sprite treated as software or hardware image
  2451.     SL_sprite(handle).restore = restores '                                       (SL_SAVE & SL_NOSAVE)  background restore behavior of sprite
  2452.     SL_sprite(handle).swidth = SL_sheet(sheet, cell).swidth '                                           get width of sprite
  2453.     SL_sprite(handle).sheight = SL_sheet(sheet, cell).sheight '                                         get height of sprite
  2454.     SL_sprite(handle).flip = 0 '                                                                        no sprite flipping
  2455.     SL_sprite(handle).zoom = 100 '                                                                      zoom normal at 100%
  2456.     SL_sprite(handle).score = 0 '                                                                       no point score
  2457.     SL_sprite(handle).visible = -1 '                                                            (TRUE)  sprite visible on screen
  2458.     SL_sprite(handle).layer = layer '                                                                   set sprite's layer
  2459.  
  2460.  
  2461.     ' mouse settings
  2462.  
  2463.     SL_sprite(handle).mouse.event = 0 '(SL_NOMOUSE, SL_HOVER, SL_LEFTCLICK, SL_RIGHTCLICK, SL_CENTERCLICK) reset mouse interaction
  2464.     SL_sprite(handle).mouse.x = 0 '                                                                     reset mouse pointer locations
  2465.     SL_sprite(handle).mouse.y = 0
  2466.     SL_sprite(handle).mouse.xa = 0
  2467.     SL_sprite(handle).mouse.ya = 0
  2468.  
  2469.     ' collision settings
  2470.  
  2471.     SL_sprite(handle).collision.detect = 0 '                                                            reset collision detection method selected
  2472.     SL_sprite(handle).collision.box = 0 '                                                      (FALSE)  reset box collision detected
  2473.     SL_sprite(handle).collision.round = 0 '                                                    (FALSE)  reset round collision detected
  2474.     SL_sprite(handle).collision.pixel = 0 '                                                    (FALSE)  reset pixel perfect collision detected
  2475.     SL_sprite(handle).collision.with = 0 '                                                              reset collision detected
  2476.     SL_sprite(handle).collision.xpoint = 0 '                                                            reset collision x point
  2477.     SL_sprite(handle).collision.ypoint = 0 '                                                            reset collision y point
  2478.     SL_sprite(handle).collision.radius = 0 '                                                            reset round collision radius
  2479.     SL_sprite(handle).collision.x1 = 0 '                                                                reset sprite's collision box boundaries
  2480.     SL_sprite(handle).collision.y1 = 0
  2481.     SL_sprite(handle).collision.x2 = 0
  2482.     SL_sprite(handle).collision.y2 = 0
  2483.     SL_sprite(handle).collision.cwidth = 0 '                                                            reset collision box width
  2484.     SL_sprite(handle).collision.cheight = 0 '                                                           reset collision box height
  2485.  
  2486.     ' animation settings
  2487.  
  2488.     SL_sprite(handle).animation.cell = cell '                                                           the animation cell this sprite is in
  2489.     SL_sprite(handle).animation.cellfrom = 0 '                                                          reset sprite beginning animation cell
  2490.     SL_sprite(handle).animation.cellto = 0 '                                                            reset sprite ending animation cell
  2491.     SL_sprite(handle).animation.dir = 0 '                      (SL_FORWARD, SL_BACKWARD & SLBACKFORTH)  reset sprite animation direction
  2492.     SL_sprite(handle).animation.mode = 0 '                                                              reset sprite animation mode
  2493.     SL_sprite(handle).animation.frame = 0 '                                                             reset sprite animation frame counter
  2494.     SL_sprite(handle).animation.skip = 0 '                                                              reset sprite animation skip rate
  2495.     SL_sprite(handle).animation.auto = 0 '                                                     (FALSE)  sprite has no auto animation
  2496.  
  2497.     ' x,y location settings
  2498.  
  2499.     SL_sprite(handle).x.real = 0 '                                                                      reset x location of sprite (center x)
  2500.     SL_sprite(handle).y.real = 0 '                                                                      reset y location of sprite (center y)
  2501.     SL_sprite(handle).x.int = 0 '                                                                       reset x location of sprite on screen INT(xreal) (center x)
  2502.     SL_sprite(handle).y.int = 0 '                                                                       reset y location of sprite on screen INT(yreal) (center y)
  2503.     SL_sprite(handle).x.actual = 0 '                                                                    reset x location of sprite on screen (upper left x)
  2504.     SL_sprite(handle).y.actual = 0 '                                                                    reset y location of sprite on screen (upper left y)
  2505.     SL_sprite(handle).x.dir = 0 '                                                                       x direction during motion
  2506.     SL_sprite(handle).y.dir = 0 '                                                                       y direction during motion
  2507.  
  2508.     ' graphics image settings
  2509.  
  2510.     SL_sprite(handle).gfx.back = 0 '                                                                    no background image saved yet
  2511.     SL_sprite(handle).gfx.hardware = _COPYIMAGE(SL_sheet(sheet, cell).software, 33) '                   create hardware sprite image
  2512.     SL_sprite(handle).gfx.software = _COPYIMAGE(SL_sheet(sheet, cell).software, 32) '                   copy software sprite image from sheet
  2513.     IF SL_sheet(sheet, cell).transparency THEN '                                                        does this sprite use transparency?
  2514.         SL_sprite(handle).gfx.mask = _COPYIMAGE(SL_sheet(sheet, cell).mask, 32) '                       yes, copy software sprite mask image from sheet
  2515.         SL_sprite(handle).transparency = -1 '                                                   (TRUE)  remember this sprite has a transparency layer
  2516.     ELSE '                                                                                              no transparency
  2517.         SL_sprite(handle).gfx.mask = 0 '                                                                no mask will be brought in
  2518.         SL_sprite(handle).transparency = 0 '                                                   (FALSE)  remember this sprite has no transparency layer
  2519.     END IF
  2520.  
  2521.     ' rotation settings
  2522.  
  2523.     SL_sprite(handle).rotation.angle = 0 '                                                              no sprite rotation angle
  2524.     SL_sprite(handle).rotation.speed = 0 '                                                              no spin rate
  2525.     SL_sprite(handle).rotation.auto = 0 '                                                      (FALSE)  auto rotation disabled
  2526.  
  2527.     ' motion settings
  2528.  
  2529.     SL_sprite(handle).motion.speed = 0 '                                                                speed during motion
  2530.     SL_sprite(handle).motion.angle = 0 '                                                                direction during motion (0 - 359)
  2531.     SL_sprite(handle).motion.auto = 0 '                                                        (FALSE)  auto motion disabled
  2532.  
  2533.     SL_NEW_SPRITE = handle '                                                                            return pointer value of new sprite
  2534.  
  2535.  
  2536. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2537. SUB SL_FREE_SPRITE (handle AS INTEGER) '                                                                                                                                                 SL_FREE_SPRITE
  2538.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2539.  
  2540.     ' declare global variables
  2541.  
  2542.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2543.  
  2544.     ' check for errors
  2545.  
  2546.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  2547.         SL_error "SL_FREE_SPRITE", 1, "" '                                                              no, report error to programmer
  2548.     END IF
  2549.  
  2550.     ' restore background if this sprite saving background
  2551.  
  2552.     IF SL_sprite(handle).restore THEN '                                                                 is there a background image to restore?
  2553.         _PUTIMAGE (SL_sprite(handle).x.back, SL_sprite(handle).y.back), SL_sprite(handle).gfx.back '    yes, restore the image
  2554.         _FREEIMAGE SL_sprite(handle).gfx.back '                                                         free background image
  2555.     END IF
  2556.  
  2557.     ' free all image data associated with sprite
  2558.  
  2559.     IF SL_sprite(handle).gfx.back THEN _FREEIMAGE SL_sprite(handle).gfx.back '                          free background image if present
  2560.     IF SL_sprite(handle).gfx.mask THEN _FREEIMAGE SL_sprite(handle).gfx.mask '                          free sprite mask image if present
  2561.     _FREEIMAGE SL_sprite(handle).gfx.hardware '                                                         free hardware sprite image
  2562.     _FREEIMAGE SL_sprite(handle).gfx.software '                                                         free software sprite image
  2563.  
  2564.     IF (handle = UBOUND(sl_sprite)) AND (handle <> 1) THEN '                                            is handle the last element in array?
  2565.         REDIM _PRESERVE SL_sprite(handle - 1) AS SL_SPRITE '                                            yes, remove index and resize array
  2566.     ELSE '                                                                                              no, index somewhere else
  2567.         SL_sprite(handle).inuse = 0 '                                                          (FALSE)  mark index as usable later
  2568.     END IF
  2569.  
  2570.  
  2571. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2572. FUNCTION SL_VALID_SPRITE (handle AS INTEGER) '                                                                                                                                         SL_VALID_SPRITE
  2573.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2574.  
  2575.     ' declare global variables
  2576.  
  2577.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2578.  
  2579.     IF (handle > UBOUND(SL_SPRITE)) OR (NOT SL_sprite(handle).inuse) OR (handle < 1) THEN '              is this a valid sprite handle?
  2580.         SL_VALID_SPRITE = 0 '                                                                   (FALSE)  no, return 0
  2581.     ELSE '                                                                                               yes, it is valid
  2582.         SL_VALID_SPRITE = -1 '                                                                   (TRUE)  return -1
  2583.     END IF
  2584.  
  2585.  
  2586. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2587. SUB SL_SET_SCORE (handle AS INTEGER, score AS INTEGER) '                                                                                                                                   SL_SET_SCORE
  2588.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2589.  
  2590.     ' declare global variables
  2591.  
  2592.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2593.  
  2594.     ' perform error checks
  2595.  
  2596.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  2597.         SL_error "SL_SET_SCORE", 1, "" '                                                                no, report error to programmer
  2598.     END IF
  2599.  
  2600.     SL_sprite(handle).score = score '                                                                   set sprite score
  2601.  
  2602.  
  2603. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2604. FUNCTION SL_GET_SCORE (handle AS INTEGER) '                                                                                                                                                SL_GET_SCORE
  2605.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2606.  
  2607.     ' declare global variables
  2608.  
  2609.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2610.  
  2611.     ' perform error checks
  2612.  
  2613.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  2614.         SL_error "SL_GET_SCORE", 1, "" '                                                                no, report error to programmer
  2615.     END IF
  2616.  
  2617.     SL_GET_SCORE = SL_sprite(handle).score '                                                            return sprite score
  2618.  
  2619.  
  2620.  
  2621. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  2622. '                                                                       ----------==========                ==========----------
  2623. '                                                                       ----------========== SHEET ROUTINES ==========----------
  2624. '                                                                       ----------==========                ==========----------
  2625. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  2626.  
  2627.  
  2628. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2629. FUNCTION SL_NEW_SHEET (filename AS STRING, swidth AS INTEGER, sheight AS INTEGER, transparency AS INTEGER, transcolor AS _UNSIGNED LONG) '                                                 SL_NEW_SHEET
  2630.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2631.  
  2632.     ' The saving/loading of rotational data file added from an idea by Bplus
  2633.     ' https://www.qb64.org/forum/index.php?topic=537.30
  2634.  
  2635.     ' declare global variables
  2636.  
  2637.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  2638.     SHARED SL_angle() AS SL_ANGLE '     precalculated rotation table
  2639.  
  2640.     ' declare local variables
  2641.  
  2642.     DIM handle AS INTEGER '             handle (pointer) number of new sprite sheet
  2643.     DIM x AS INTEGER '                  generic counter to cycle through sheet sprite columns
  2644.     DIM y AS INTEGER '                  generic counter to cycle through sheet sprite rows
  2645.     DIM osource AS LONG '               original source image before this function was called
  2646.     DIM odest AS LONG '                 original destination image before this function was called
  2647.     DIM pixel AS _UNSIGNED LONG '       pixel color at each coordinate in sprite sheet
  2648.     DIM alpha AS _UNSIGNED LONG '       alpha level of current pixel
  2649.     DIM top AS INTEGER '                upper boundary of sprite image
  2650.     DIM bottom AS INTEGER '             lower boundary of sprite image
  2651.     DIM left AS INTEGER '               left boundary of sprite image
  2652.     DIM right AS INTEGER '              right boundary of sprite image
  2653.     DIM sheetimage AS LONG '            sprite sheet image
  2654.     DIM sheetwidth AS INTEGER '         width of sprite sheet in pixels
  2655.     DIM sheetheight AS INTEGER '        height of sprite sheet in pixels
  2656.     DIM rows AS INTEGER '               number of sprite rows contained on sheet
  2657.     DIM columns AS INTEGER '            number of sprite columns contained on sheet
  2658.     DIM clearcolor AS _UNSIGNED LONG '  transcolor passed in will be modified
  2659.     DIM tempsprite AS LONG '            temporary sprite image
  2660.     DIM px(3) AS SINGLE '               polar x coordinates of maptriangle
  2661.     DIM py(3) AS SINGLE '               polar y coordinates of maptriangle
  2662.     DIM sinr AS SINGLE '                sin rotation calculation
  2663.     DIM cosr AS SINGLE '                cosine rotation calculation
  2664.     DIM bx1 AS SINGLE '                 boundaries of collision box
  2665.     DIM bx2 AS SINGLE
  2666.     DIM by1 AS SINGLE
  2667.     DIM by2 AS SINGLE
  2668.     DIM x2 AS SINGLE '                  new computed polar coordinates
  2669.     DIM y2 AS SINGLE
  2670.     DIM cells AS INTEGER '              total number of cells on sheet
  2671.     DIM cell AS INTEGER '               cell counter
  2672.     DIM degree AS INTEGER '             degree counter
  2673.     DIM polar AS INTEGER '              polar coordinate counter
  2674.     DIM xoffset AS INTEGER '            x offset to rotated center
  2675.     DIM yoffset AS INTEGER '            y offset to rotated center
  2676.     DIM xwidth AS INTEGER '             sprite width counter
  2677.     DIM yheight AS INTEGER '            sprite height counter
  2678.     DIM rotfile AS STRING '             name of rotation data file
  2679.     DIM preloaded AS INTEGER '          -1 (TRUE) if rotation data preloaded
  2680.     DIM filenum AS INTEGER '            FREEFILE number
  2681.  
  2682.     ' perform error checks
  2683.  
  2684.     IF NOT _FILEEXISTS(filename) THEN '                                                                 does the sprite sheet exist?
  2685.         SL_error "SL_NEW_SHEET", 100, filename '                                                        no, report error to programmer
  2686.     END IF
  2687.     IF ABS(transparency) > 1 THEN '                                                                     valid transparency setting?
  2688.         SL_error "SL_NEW_SHEET", 101, "" '                                                              no, report error to programmer
  2689.     END IF
  2690.     IF swidth < 1 OR sheight < 1 THEN '                                                                 valid sprite width/height supplied?
  2691.         SL_error "SL_NEW_SHEET", 102, "" '                                                              no, report error to programmer
  2692.     END IF
  2693.     IF transparency = -1 AND UCASE$(RIGHT$(filename, 4)) <> ".PNG" THEN '                               wrong file type for transparency?
  2694.         SL_error "SL_NEW_SHEET", 103, UCASE$(RIGHT$(filename, 4)) '                                     yes, report error to programmer
  2695.     END IF
  2696.  
  2697.     ' local variable setup
  2698.  
  2699.     sheetimage = _LOADIMAGE(filename, 32) '                                                             load sprite sheet file
  2700.     sheetwidth = _WIDTH(sheetimage) '                                                                   get width of sheet
  2701.     sheetheight = _HEIGHT(sheetimage) '                                                                 get height of sheet
  2702.     columns = sheetwidth \ swidth '                                                                     get number of whole columns of sprites
  2703.     rows = sheetheight \ sheight '                                                                      get number of whole rows of sprites
  2704.     cells = rows * columns '                                                                            calculate total number of cells on sheet
  2705.  
  2706.     IF columns < 1 OR rows < 1 THEN '                                                                   at least one sprite column and row on sheet?
  2707.         SL_error "SL_NEW_SHEET", 104, "" '                                                              no, report error to programmer
  2708.     END IF
  2709.  
  2710.     osource = _SOURCE '                                                                                 remember current source image
  2711.     odest = _DEST '                                                                                     remember current destination image
  2712.     handle = 0 '                                                                                        initialize handle value
  2713.     clearcolor = transcolor '                                                                           get background/transparent color passed in
  2714.  
  2715.     ' increase sheet array's 1st dimension if needed to create a new sprite sheet
  2716.  
  2717.     DO '                                                                                                look for the next available handle
  2718.         handle = handle + 1 '                                                                           increment the handle value
  2719.     LOOP UNTIL (NOT SL_sheet(handle, 0).software) OR handle = UBOUND(SL_sheet) '                        stop looking when valid handle value found
  2720.     IF SL_sheet(handle, 0).software = -1 THEN '                                                 (TRUE)  is the last array element in use?
  2721.         handle = handle + 1 '                                                                           yes, increment the handle value
  2722.         REDIM _PRESERVE SL_sheet(handle, UBOUND(SL_sheet, 2)) AS SL_SHEET '                             create new sheet in sprite array
  2723.         REDIM _PRESERVE SL_angle(handle, UBOUND(SL_angle, 2), 359) AS SL_ANGLE '                        increase rotation array to match
  2724.     END IF
  2725.  
  2726.     ' increase sheet array's 2nd dimension if needed to match number of cells
  2727.  
  2728.     IF cells > UBOUND(SL_sheet, 2) THEN '                                                               more cells in this sheet than others?
  2729.         REDIM _PRESERVE SL_sheet(handle, cells) AS SL_SHEET '                                           yes, increase the array's 2nd dimension to match
  2730.         REDIM _PRESERVE SL_angle(handle, cells, 359) AS SL_ANGLE '                                      increase rotation array to match
  2731.     END IF
  2732.  
  2733.     ' the variables in SL_sheet(x, 0) will serve a dual purpose
  2734.     ' SL_sheet(x, 0).image will contain either -1 (true) or 0 (false) to indicate the first dimension of the array is in use.
  2735.  
  2736.     SL_sheet(handle, 0).software = -1 '                                                         (TRUE)  mark as in use
  2737.  
  2738.     ' identify transparency of sprite sheet if requested
  2739.  
  2740.     IF transparency = -1 THEN '                                                          (SL_USESHEET)  sheet have alpha channel?
  2741.         x = 0 '                                                                                         yes, start at upper left x of sheet
  2742.         y = 0 '                                                                                         start at upper left y of sheet
  2743.         alpha = 255 '                                                                                   assume no alpha channel
  2744.         _SOURCE sheetimage '                                                                            set sprite sheet image as source image
  2745.         DO '                                                                                            start looping through the sheet's pixels
  2746.             pixel = POINT(x, y) '                                                                       get the pixel's color attributes
  2747.             alpha = _ALPHA32(pixel) '                                                                   get the alpha level (0 - 255)
  2748.             IF alpha = 0 THEN EXIT DO '                                                                 if it is transparent then leave the loop
  2749.             x = x + 1 '                                                                                 move right one pixel
  2750.             IF x > sheetwidth THEN '                                                                    have we gone off the sheet?
  2751.                 x = 0 '                                                                                 yes, reset back to the left beginning
  2752.                 y = y + 1 '                                                                             move down one pixel
  2753.             END IF
  2754.         LOOP UNTIL y > sheetheight '                                                                    don't stop until the entire sheet has been checked
  2755.         IF alpha = 0 THEN '                                                                             did we find a transparent pixel?
  2756.             tempsprite = _NEWIMAGE(1, 1, 32) '                                                          yes, create a temporary image         * why did I have to do
  2757.             _CLEARCOLOR pixel, tempsprite '                                                             set pixel found as transparent        * this hack to get
  2758.             clearcolor = _CLEARCOLOR(tempsprite) '                                                      get the transparent color from image  * clearcolor to come out
  2759.             _FREEIMAGE tempsprite '                                                                     temporary image no longer needed      * to the right value?
  2760.         ELSE '                                                                                          no transparency found within sheet
  2761.             transparency = 1 '                                                                          set sheet to having no alpha channel
  2762.         END IF
  2763.     ELSEIF transparency = 0 THEN '                                                            (SL_SET)  manually set alpha channel?
  2764.         _CLEARCOLOR clearcolor, sheetimage '                                                            yes, set color as transparent
  2765.         clearcolor = _CLEARCOLOR(sheetimage) '                                                          get the transparent color ************* again, why this hack?
  2766.     END IF
  2767.  
  2768.     ' preload rotational data if it exists
  2769.  
  2770.     rotfile = LEFT$(filename, INSTR(filename, ".") - 1) + ".rot" '                                      the name of the rotational data file
  2771.     IF _FILEEXISTS(rotfile) THEN '                                                                      does it exist?
  2772.         preloaded = -1 '                                                                                yes, remember that data has been preloaded
  2773.         filenum = FREEFILE
  2774.         OPEN rotfile FOR BINARY AS filenum '                                                            open it for reading
  2775.         FOR x = 1 TO cells '                                                                            cycle through all animation cells
  2776.             FOR y = 0 TO 359 '                                                                          and their associated rotational data
  2777.                 GET #1, , SL_angle(handle, x, y) '                                                      get the data
  2778.             NEXT y
  2779.         NEXT x
  2780.         CLOSE filenum '                                                                                 close the file
  2781.     END IF
  2782.  
  2783.     ' load sprites from sheet and place into sprite array
  2784.  
  2785.     x = 0 '                                                                                             reset column counter
  2786.     DO '                                                                                                cycle through sheet's columns
  2787.         x = x + 1 '                                                                                     increment column counter
  2788.         y = 0 '                                                                                         reset row counter
  2789.         DO '                                                                                            cycle through sheet's rows
  2790.             y = y + 1 '                                                                                 increment row counter
  2791.             cell = (y - 1) * columns + x '                                                              calculate current cell number
  2792.             SL_sheet(handle, cell).software = _NEWIMAGE(swidth, sheight, 32) '                          create software sprite image
  2793.  
  2794.             SL_sheet(handle, cell).swidth = swidth
  2795.             SL_sheet(handle, cell).sheight = sheight
  2796.  
  2797.  
  2798.             IF transparency < 1 THEN '                                                                  should a mask be created?
  2799.                 SL_sheet(handle, cell).mask = _NEWIMAGE(swidth, sheight, 32) '                          yes, create software sprite mask image
  2800.                 _DEST SL_sheet(handle, cell).mask '                                                     write to the mask image
  2801.             ELSE '                                                                                      no software mask image
  2802.                 SL_sheet(handle, cell).transparency = 0 '                                      (FALSE)  set sprite as having no transparency
  2803.             END IF
  2804.             _PUTIMAGE , sheetimage, SL_sheet(handle, cell).software,_
  2805.                 ((x - 1) * swidth, (y - 1) * sheight)-_
  2806.                 ((x - 1) * swidth + swidth - 1, (y - 1) * sheight + sheight - 1) '                      copy sprite from sheet and place in sprite image
  2807.  
  2808.             ' precalculate collision boundaries and update sprite mask if needed
  2809.  
  2810.             _SOURCE SL_sheet(handle, cell).software '                                                   work from the software sprite image
  2811.             top = sheight - 1 '                                                                         set initial collision boundary markers
  2812.             left = swidth - 1
  2813.             bottom = 0
  2814.             right = 0
  2815.  
  2816.             xwidth = 0 '                                                                                reset width counter
  2817.             DO '                                                                                        cycle through width of sprite
  2818.                 yheight = 0 '                                                                           reset height counter
  2819.                 DO '                                                                                    cycle through height of sprite
  2820.                     IF POINT(xwidth, yheight) <> clearcolor THEN '                                      is this pixel a transparent/background color?
  2821.                         IF xwidth < left THEN left = xwidth '                                           no, save position if left-most pixel
  2822.                         IF yheight < top THEN top = yheight '                                           save position if top-most pixel
  2823.                         IF xwidth > right THEN right = xwidth '                                         save position if right-most pixel
  2824.                         IF yheight > bottom THEN bottom = yheight '                                     save position if bbottom-most pixel
  2825.                     END IF
  2826.                     IF transparency < 1 THEN '                                                          update software sprite mask?
  2827.                         IF POINT(xwidth, yheight) = clearcolor THEN '                                   yes, is this pixel a transparent/background color?
  2828.                             PSET (xwidth, yheight), _RGB32(255, 255, 255) '                             yes, set as white on the mask image
  2829.                         END IF
  2830.                     END IF
  2831.                     yheight = yheight + 1 '                                                             increment height counter
  2832.                 LOOP UNTIL yheight = sheight '                                                          leave when height of sprite reached (-1)
  2833.                 xwidth = xwidth + 1 '                                                                   increment width counter
  2834.             LOOP UNTIL xwidth = swidth '                                                                leave when width of sprite reached (-1)
  2835.  
  2836.             SL_angle(handle, cell, 0).x1 = left '                                                       collision box top left x
  2837.             SL_angle(handle, cell, 0).y1 = top '                                                        collision box top left y
  2838.             SL_angle(handle, cell, 0).x2 = right '                                                      collision box bottom right x
  2839.             SL_angle(handle, cell, 0).y2 = bottom '                                                     collision box bottom right y
  2840.             SL_angle(handle, cell, 0).cwidth = right - left '                                           remember collision box width
  2841.             SL_angle(handle, cell, 0).cheight = bottom - top '                                          remember collision box height
  2842.             SL_angle(handle, cell, 0).radius = (SL_angle(handle, cell, 0).cwidth + SL_angle(handle, cell, 0).cheight) \ 4 ' calculate round collision radius
  2843.  
  2844.             IF NOT preloaded THEN
  2845.  
  2846.                 degree = 0 '                                                                            reset degree counter
  2847.                 DO '                                                                                    cycle from 1 to 359 degrees
  2848.                     degree = degree + 1 '                                                               increment degree counter
  2849.                     'px(0) = (-swidth + 1) / 2 '                                                         upper left  x polar coordinate of sprite
  2850.                     'py(0) = (-sheight + 1) / 2 '                                                        upper left  y polar coordinate of sprite
  2851.                     px(0) = -swidth / 2 '                                                               upper left  x polar coordinate of sprite
  2852.                     py(0) = -sheight / 2 '                                                              upper left  y polar coordinate of sprite
  2853.                     px(1) = px(0) '                                                                     lower left  x polar coordinate of sprite
  2854.                     'py(1) = (sheight -1) / 2 '                                                          lower left  y polar coordinate of sprite
  2855.                     'px(2) = (swidth - 1) / 2 '                                                          lower right x polar coordinate of sprite
  2856.                     py(1) = sheight / 2 '                                                               lower left  y polar coordinate of sprite
  2857.                     px(2) = swidth / 2 '                                                                lower right x polar coordinate of sprite
  2858.                     py(2) = py(1) '                                                                     lower right y polar coordinate of sprite
  2859.                     px(3) = px(2) '                                                                     upper right x polar coordinate of sprite
  2860.                     py(3) = py(0) '                                                                     upper right y polar coordinate of sprite
  2861.                     sinr = SIN(-degree / 57.2957795131) '                                               calculate the sin of rotation
  2862.                     cosr = COS(-degree / 57.2957795131) '                                               calculate the cosine of rotation
  2863.                     bx1 = 0 '                                                                           upper left x boundary of sprite
  2864.                     by1 = 0 '                                                                           upper left y boundary of sprite
  2865.                     bx2 = 0 '                                                                           lower right x boundary of sprite
  2866.                     by2 = 0 '                                                                           lower right y boundary of sprite
  2867.  
  2868.                     polar = 0 '                                                                         reset counter
  2869.                     DO '                                                                                cycle through all four polar coordinates (0 to 3)
  2870.                         x2 = (px(polar) * cosr + sinr * py(polar)) '                                    compute new polar coordinate location
  2871.                         y2 = (py(polar) * cosr - px(polar) * sinr) '                                    compute new polar coordinate location
  2872.                         px(polar) = x2 '                                                                save the new polar coordinate
  2873.                         py(polar) = y2 '                                                                save the new polar coordinate
  2874.                         IF px(polar) < bx1 THEN bx1 = px(polar) '                                       save lowest  x value seen \  NOTE: use for
  2875.                         IF px(polar) > bx2 THEN bx2 = px(polar) '                                       save highest x value seen  \ background image         <--------------------- LOOK
  2876.                         IF py(polar) < by1 THEN by1 = py(polar) '                                       save lowest  y value seen  / rectangle coordinates
  2877.                         IF py(polar) > by2 THEN by2 = py(polar) '                                       save highest y value seen /
  2878.                         polar = polar + 1 '                                                             increment counter
  2879.                     LOOP UNTIL polar = 4 '                                                              leave when all coordinates calculated
  2880.  
  2881.                     SL_angle(handle, cell, degree).rwidth = bx2 - bx1 + 1 '                             calculate width of rotated sprite
  2882.                     SL_angle(handle, cell, degree).rheight = by2 - by1 + 1 '                            calculate height of rotated sprite
  2883.                     xoffset = SL_angle(handle, cell, degree).rwidth \ 2 '                               calculate x offset
  2884.                     yoffset = SL_angle(handle, cell, degree).rheight \ 2 '                              calculate y offset
  2885.                     SL_angle(handle, cell, degree).px0 = px(0) + xoffset '                              add offsets to coordinates
  2886.                     SL_angle(handle, cell, degree).px1 = px(1) + xoffset
  2887.                     SL_angle(handle, cell, degree).px2 = px(2) + xoffset
  2888.                     SL_angle(handle, cell, degree).px3 = px(3) + xoffset
  2889.                     SL_angle(handle, cell, degree).py0 = py(0) + yoffset
  2890.                     SL_angle(handle, cell, degree).py1 = py(1) + yoffset
  2891.                     SL_angle(handle, cell, degree).py2 = py(2) + yoffset
  2892.                     SL_angle(handle, cell, degree).py3 = py(3) + yoffset
  2893.  
  2894.                     ' rotate image here to get rotated collision box info
  2895.  
  2896.                     tempsprite = _NEWIMAGE(SL_angle(handle, cell, degree).rwidth, SL_angle(handle, cell, degree).rheight, 32) ' create temp image using precalculated width/height
  2897.                 _MAPTRIANGLE (0, 0)-(0, sheight - 1)-(swidth - 1, sheight - 1), SL_sheet(handle, cell).software TO _
  2898.                              (SL_angle(handle, cell, degree).px0, SL_angle(handle, cell, degree).py0)-(SL_angle(handle, cell, degree).px1,_
  2899.                               SL_angle(handle, cell, degree).py1)-(SL_angle(handle, cell, degree).px2, SL_angle(handle, cell, degree).py2), tempsprite ' map rotated sprite onto temp image
  2900.                 _MAPTRIANGLE (0, 0)-(swidth - 1, 0)-(swidth - 1, sheight - 1), SL_sheet(handle, cell).software TO _
  2901.                              (SL_angle(handle, cell, degree).px0, SL_angle(handle, cell, degree).py0)-(SL_angle(handle, cell, degree).px3,_
  2902.                               SL_angle(handle, cell, degree).py3)-(SL_angle(handle, cell, degree).px2, SL_angle(handle, cell, degree).py2), tempsprite
  2903.  
  2904.                     ' precalculate rotated collision boundaries
  2905.  
  2906.                     _SOURCE tempsprite '                                                                work from the temp image
  2907.                     top = SL_angle(handle, cell, degree).rheight - 1 '                                  set initial collision boundary markers
  2908.                     left = SL_angle(handle, cell, degree).rwidth - 1
  2909.                     bottom = 0
  2910.                     right = 0
  2911.  
  2912.                     xwidth = 0 '                                                                        reset width counter
  2913.                     DO '                                                                                cycle through width of rotated sprite
  2914.                         yheight = 0 '                                                                   reset height counter
  2915.                         DO '                                                                            cycle through height of rotated sprite
  2916.                             IF POINT(xwidth, yheight) <> clearcolor THEN '                              is this pixel a transparent/background color?
  2917.                                 IF xwidth < left THEN left = xwidth '                                   no, save position if left-most pixel
  2918.                                 IF yheight < top THEN top = yheight '                                   save position if top-most pixel
  2919.                                 IF xwidth > right THEN right = xwidth '                                 save position if right-most pixel
  2920.                                 IF yheight > bottom THEN bottom = yheight '                             save position if bbottom-most pixel
  2921.                             END IF
  2922.                             yheight = yheight + 1 '                                                     increment height counter
  2923.                         LOOP UNTIL yheight = SL_angle(handle, cell, degree).rheight '                   leave when height of rotated sprite reached (-1)
  2924.                         xwidth = xwidth + 1 '                                                           increment width counter
  2925.                     LOOP UNTIL xwidth = SL_angle(handle, cell, degree).rwidth '                         leave when width of rotated sprite reached (-1)
  2926.  
  2927.                     _FREEIMAGE tempsprite '                                                             temp image no longer needed
  2928.                     SL_angle(handle, cell, degree).x1 = left '                                          collision box top left x
  2929.                     SL_angle(handle, cell, degree).y1 = top '                                           collision box top left y
  2930.                     SL_angle(handle, cell, degree).x2 = right '                                         collision box bottom right x
  2931.                     SL_angle(handle, cell, degree).y2 = bottom '                                        collision box bottom right y
  2932.                     SL_angle(handle, cell, degree).cwidth = right - left '                              remember collision box width
  2933.                     SL_angle(handle, cell, degree).cheight = bottom - top '                             remember collision box height
  2934.                     SL_angle(handle, cell, degree).radius = (SL_angle(handle, cell, degree).cwidth + SL_angle(handle, cell, degree).cheight) \ 4 ' calculate round collision radius
  2935.                 LOOP UNTIL degree = 359 '                                                               leave when all degree angles calculated
  2936.  
  2937.             END IF ' preloaded
  2938.  
  2939.         LOOP UNTIL y = rows '                                                                           leave when all rows processed
  2940.     LOOP UNTIL x = columns '                                                                            leave when all columns processed
  2941.  
  2942.     _FREEIMAGE sheetimage '                                                                             sprite sheet image no longer needed
  2943.  
  2944.     _SOURCE osource '                                                                                   return source to current
  2945.     _DEST odest '                                                                                       return destination to current
  2946.  
  2947.     IF NOT _FILEEXISTS(rotfile) THEN '                                                                  does it exist?
  2948.         filenum = FREEFILE
  2949.         OPEN rotfile FOR BINARY AS filenum '                                                            no, open it for writing
  2950.         FOR x = 1 TO cells '                                                                            cycle through all sprite cells
  2951.             FOR y = 0 TO 359 '                                                                          and their rotational angles
  2952.                 PUT #1, , SL_angle(handle, x, y) '                                                      put the data
  2953.             NEXT y
  2954.         NEXT x
  2955.         CLOSE filenum '                                                                                 close the file
  2956.     END IF
  2957.  
  2958.     SL_NEW_SHEET = handle '                                                                             return the handle number pointing to this sheet
  2959.  
  2960.  
  2961. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2962. FUNCTION SL_VALID_SHEET (sheet AS INTEGER) '                                                                                                                                             SL_VALID_SHEET
  2963.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2964.  
  2965.     ' declare global variables
  2966.  
  2967.     SHARED SL_sheet() AS SL_SHEET '    master sprite sheet array
  2968.  
  2969.     IF (sheet > UBOUND(SL_sheet)) OR (sheet < 1) THEN '                                                 is this a valid sheet?
  2970.         SL_VALID_SHEET = 0 '                                                                   (FALSE)  no, return false
  2971.     ELSEIF NOT SL_sheet(sheet, 0).software THEN '                                                       is sprite sheet in use?
  2972.         SL_VALID_SHEET = 0 '                                                                   (FALSE)  no, return false
  2973.     ELSE '                                                                                              everything checks out
  2974.         SL_VALID_SHEET = -1 '                                                                   (TRUE)  return true
  2975.     END IF
  2976.  
  2977.  
  2978.  
  2979. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  2980. '                                                                      ----------==========                   ==========----------
  2981. '                                                                      ----------========== INTERNAL USE ONLY ==========----------
  2982. '                                                                      ----------==========                   ==========----------
  2983. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  2984.  
  2985.  
  2986. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2987. SUB SL_update_auto_sprites (software AS INTEGER) '                                                                                                                               SL_update_auto_sprites
  2988.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2989.  
  2990.     ' declare global variables
  2991.  
  2992.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  2993.     SHARED SL_global AS SL_GLOBAL '     common globals array
  2994.  
  2995.     ' declare local variables
  2996.  
  2997.     DIM handle AS INTEGER '             handle of sprite
  2998.     DIM nextcell AS SINGLE '            draw (-1 TRUE) or skip (0 FALSE) next animation cell
  2999.  
  3000.     ' local variable setup
  3001.  
  3002.     handle = 0 '                                                                                        initialize handle counter
  3003.  
  3004.     DO '                                                                                                cycle through all sprite indexes
  3005.         handle = handle + 1 '                                                                           increment to next sprite handle
  3006.         IF SL_sprite(handle).software = software THEN '                                                 hardware or software type equal to requested type?
  3007.             IF SL_sprite(handle).inuse AND (SL_sprite(handle).motion.auto OR _
  3008.                                             SL_sprite(handle).rotation.auto OR _
  3009.                                             SL_sprite(handle).animation.auto) THEN '                    yes, is this sprite being used and automagically controlled?
  3010.  
  3011.                 ' auto motion
  3012.  
  3013.                 IF SL_sprite(handle).motion.auto THEN '                                                 yes, is auto motion enabled?
  3014.                     SL_sprite(handle).x.real = SL_sprite(handle).x.real + SL_sprite(handle).x.dir '     yes, update x location
  3015.                     SL_sprite(handle).y.real = SL_sprite(handle).y.real + SL_sprite(handle).y.dir '     update y location
  3016.                 END IF
  3017.  
  3018.  
  3019.                 ' auto animation
  3020.  
  3021.                 IF SL_sprite(handle).animation.auto THEN '                                              is auto animation enabled?
  3022.                     IF SL_sprite(handle).animation.skip = 0 THEN '                                      yes, always go to next cell?
  3023.                         nextcell = -1 '                                                         (TRUE)  yes, draw next cell
  3024.                     ELSE '                                                                              no
  3025.  
  3026.                         ' decide to draw or skip next cell
  3027.  
  3028.                         SL_sprite(handle).animation.frame = SL_sprite(handle).animation.frame + 1 '     increment frame counter
  3029.                         IF SL_sprite(handle).animation.skip = SL_sprite(handle).animation.frame THEN '  time to skip or go to next cell?
  3030.                             SL_sprite(handle).animation.frame = 0 '                                     yes, reset the frame counter
  3031.                             IF SL_sprite(handle).animation.framerate >= SL_global.framerate \ 2 THEN '  should this cell be skipped?
  3032.                                 nextcell = 0 '                                                 (FALSE)  yes, skip next cell
  3033.                             ELSE '                                                                      no
  3034.                                 nextcell = -1 '                                                 (TRUE)  go to next cell
  3035.                             END IF
  3036.                         ELSEIF SL_sprite(handle).animation.framerate >= SL_global.framerate \ 2 THEN '  no, is sprite frame rate equal or greater than half global frame rate?
  3037.                             nextcell = -1 '                                                             yes, go to next cell
  3038.                         END IF
  3039.                     END IF
  3040.  
  3041.                     ' draw next cell
  3042.  
  3043.                     IF nextcell THEN '                                                                  update animation cell?
  3044.                         SELECT CASE SL_sprite(handle).animation.mode '                                  which animation mode is this sprite using?
  3045.                             CASE 0 '                                                      (SL_FORWARD)  move forward through the cells
  3046.                                 SL_sprite(handle).animation.cell = SL_sprite(handle).animation.cell + 1 ' increment animation cell
  3047.                                 IF SL_sprite(handle).animation.cell > SL_sprite(handle).animation.cellto THEN ' passed the last cell?
  3048.                                     SL_sprite(handle).animation.cell = SL_sprite(handle).animation.cellfrom ' yes, go back to first cell
  3049.                                 END IF
  3050.                             CASE 1 '                                                     (SL_BACKWARD)  move backward through the cells
  3051.                                 SL_sprite(handle).animation.cell = SL_sprite(handle).animation.cell - 1 ' decrement animation cell
  3052.                                 IF SL_sprite(handle).animation.cell < SL_sprite(handle).animation.cellfrom THEN ' passed the first cell?
  3053.                                     SL_sprite(handle).animation.cell = SL_sprite(handle).animation.cellto ' yes, go back to last cell
  3054.                                 END IF
  3055.                             CASE 2 '                                                    (SL_BACKFORTH)  ping-pong back and forth through the cells
  3056.                                 SL_sprite(handle).animation.cell = SL_sprite(handle).animation.cell + SL_sprite(handle).animation.dir ' increment/decrement animation cell
  3057.                                 IF SL_sprite(handle).animation.cell = SL_sprite(handle).animation.cellto OR _
  3058.                                     SL_sprite(handle).animation.cell = SL_sprite(handle).animation.cellfrom THEN ' is this the first or last cell?
  3059.                                     SL_sprite(handle).animation.dir = -SL_sprite(handle).animation.dir 'yes, reverse animation direction
  3060.                                 END IF
  3061.                         END SELECT
  3062.                         SL_sprite(handle).cell = SL_sprite(handle).animation.cell '                     update current sprite cell
  3063.                         IF SL_sprite(handle).rotation.angle AND (NOT SL_sprite(handle).rotation.auto) THEN ' is this animation currently rotated but not automatic?
  3064.                             SL_ROTATE_SPRITE handle, SL_sprite(handle).rotation.angle '                 yes, this new cell will need manually rotated as well
  3065.                         END IF
  3066.                     END IF
  3067.                 END IF
  3068.  
  3069.                 ' auto rotation
  3070.  
  3071.                 IF SL_sprite(handle).rotation.auto THEN '                                               is auto rotation enabled?
  3072.                     SL_ROTATE_SPRITE handle, SL_sprite(handle).rotation.angle + SL_sprite(handle).rotation.speed ' yes, rotate sprite to next degree angle
  3073.                 END IF
  3074.  
  3075.                 SL_PUT_SPRITE SL_sprite(handle).x.real, SL_sprite(handle).y.real, handle '              update sprite motion location, rotation, and animation
  3076.             END IF
  3077.         END IF
  3078.     LOOP UNTIL handle = UBOUND(SL_sprite) '                                                             leave when all indexes checked
  3079.  
  3080.  
  3081. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  3082. FUNCTION SL_min (a AS INTEGER, b AS INTEGER) '                                                                                                                                                   SL_min
  3083.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  3084.  
  3085.     IF a < b THEN '                                                                                     is a the smaller number?
  3086.         SL_min = a '                                                                                    yes, return a
  3087.     ELSE '                                                                                              no, b is smaller number
  3088.         SL_min = b '                                                                                    return b (or a = b)
  3089.     END IF
  3090.  
  3091.  
  3092. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  3093. FUNCTION SL_max (a AS INTEGER, b AS INTEGER) '                                                                                                                                                   SL_max
  3094.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  3095.  
  3096.     IF a > b THEN '                                                                                     is a the larger number?
  3097.         SL_max = a '                                                                                    yes, return a
  3098.     ELSE '                                                                                              no, b is the larger number
  3099.         SL_max = b '                                                                                    return b (or a = b)
  3100.     END IF
  3101.  
  3102.  
  3103. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  3104. SUB SL_error (routine AS STRING, errno AS INTEGER, info AS STRING) '                                                                                                                           SL_error
  3105.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  3106.  
  3107.     SCREEN 0, 0, 0, 0 '                                                                                 go to a pure text screen
  3108.     _FONT 16 '                                                                                          set the standard screen 0 font
  3109.     IF _FULLSCREEN THEN _FULLSCREEN _OFF '                                                              turn off full screen if on
  3110.     _AUTODISPLAY '                                                                                      auto update the display
  3111.     CLS '                                                                                               clear the screen
  3112.     COLOR 10, 0
  3113.     PRINT "                   **************************************" '                                 print error header
  3114.     PRINT "                   ** Sprite Library Error Encountered **"
  3115.     PRINT "                   **************************************"
  3116.     PRINT
  3117.     COLOR 15, 0
  3118.     PRINT " "; routine;
  3119.     COLOR 7, 0
  3120.     PRINT " has reported error";
  3121.     COLOR 30, 0
  3122.     PRINT STR$(errno)
  3123.     COLOR 7, 0
  3124.     PRINT
  3125.     SELECT CASE errno '                                                                                 which error number is being reported?
  3126.  
  3127.         ' general purpose errors for all subs/functions
  3128.  
  3129.         CASE 1
  3130.             PRINT "- the requested sprite does not exist"
  3131.         CASE 2
  3132.             PRINT "- invalid background restore setting supplied - valid settings are"
  3133.             PRINT "- : -1 (constant SL_SAVE)"
  3134.             PRINT "- :  0 (constant SL_NOSAVE)"
  3135.         CASE 3
  3136.             PRINT "- invalid flip setting supplied - valid settings are"
  3137.             PRINT "- : 0 (constant SL_NOFLIP or SL_RESET)"
  3138.             PRINT "- : 1 (constant SL_HORIZONTAL)"
  3139.             PRINT "- : 2 (constant SL_VERTICAL)"
  3140.             PRINT "- : 3 (constant SL_FLIPBOTH)"
  3141.         CASE 4
  3142.             PRINT "- invalid zoom level setting supplied"
  3143.             PRINT "- zoom level must be greater than zero (0)"
  3144.         CASE 5
  3145.             PRINT "- the specified sprite sheet is not in use or does not exist"
  3146.         CASE 6
  3147.             PRINT "- invalid row or column selected for specified sprite sheet"
  3148.         CASE 7
  3149.             PRINT "- invalid auto motion behavior requested - valid settings are"
  3150.             PRINT "- : -1 (constant SL_START)"
  3151.             PRINT "- :  0 (constant SL_STOP)"
  3152.         CASE 8
  3153.             PRINT "- invalid auto rotation behavior requested - valid settings are"
  3154.             PRINT "- : -1 (constant SL_START)"
  3155.             PRINT "- :  0 (constant SL_STOP)"
  3156.         CASE 9
  3157.             PRINT "- rotation speed must be between -359 and 359 degrees"
  3158.         CASE 10
  3159.             PRINT "- frame rate must be greater than zero (0)"
  3160.         CASE 11
  3161.             PRINT "- frame rate must be greater than zero (0) and less than or equal"
  3162.             PRINT "- to the global frame rate"
  3163.         CASE 12
  3164.             PRINT "- incorrect animation direction mode setting - valid settings are"
  3165.             PRINT "- : 0 (constant SL_FORWARD)"
  3166.             PRINT "- : 1 (constant SL_BACKWARD)"
  3167.             PRINT "- : 2 (constant CL_BACKFORTH"
  3168.         CASE 13
  3169.             PRINT "- invalid cell value given - it must be greater than 0 and less"
  3170.             PRINT "- than or equal to the total number of animation cells on a sheet"
  3171.         CASE 14
  3172.             PRINT "- invalid auto animation behavior requested - valid settings are"
  3173.             PRINT "- : -1 (constant SL_START)"
  3174.             PRINT "- :  0 (constant SL_STOP)"
  3175.         CASE 15
  3176.             PRINT "- animation has not been assigned to this sprite - use"
  3177.             PRINT "- SL_SET_ANIMATION to assign animation to this sprite"
  3178.         CASE 16
  3179.             PRINT "- this srpite is already under auto motion control"
  3180.             PRINT "- use SL_CHANGE_AUTOMOTION to disable auto motion control"
  3181.         CASE 17
  3182.             PRINT "- this sprite is already under auto rotation control"
  3183.             PRINT "- use SL_CHANGE_AUTOROTATION to disable auto rotation control"
  3184.         CASE 18
  3185.             PRINT "- this sprite is already under auto animation control"
  3186.             PRINT "- use SL_CHNAGE_AUTOANIMATION to disable auto animation control"
  3187.         CASE 19
  3188.             PRINT "- the destination cell must be greater than the starting cell"
  3189.         CASE 20
  3190.             PRINT "- invalid visible setting reguested - valid setting are"
  3191.             PRINT "- : -1 (constant SL_SHOW)"
  3192.             PRINT "- :  0 (constant SL_HIDE)"
  3193.         CASE 21
  3194.             PRINT "- the sprite being checked for collisions has no collision detection"
  3195.             PRINT "- enabled - use SL_XXXXXXXXXX to turn on collision detection for"
  3196.             PRINT "- the sprite"
  3197.         CASE 22
  3198.             PRINT "- the sprite being checked for a collision with has no collision"
  3199.             PRINT "- detection enabled - use SL_XXXXXXX to turn on collision detection"
  3200.             PRINT "- for the sprite"
  3201.         CASE 23
  3202.             PRINT "- both sprites must have the same collision detection method"
  3203.         CASE 24
  3204.             PRINT "- invalid collision detection mode requested - valid settings are"
  3205.             PRINT "- : 0 (constant SL_NODETECT or SL_RESET)"
  3206.             PRINT "- : 1 (constant SL_BOXDETECT)"
  3207.             PRINT "- : 2 (constant SL_ROUNDDETECT)"
  3208.             PRINT "- : 3 (constant SL_PIXELDETECT)"
  3209.         CASE 25
  3210.             PRINT "- invalid layer requested - the layer does not exist"
  3211.         CASE 26
  3212.             PRINT "- you must create at least one (1) layer"
  3213.  
  3214.             ' errors belonging to SL_NEW_SHEET (100 - 109)
  3215.  
  3216.         CASE 100
  3217.             PRINT "- "; CHR$(34); info; CHR$(34); " sprite sheet does not exist"
  3218.             PRINT "- check path or spelling"
  3219.         CASE 101
  3220.             PRINT "- invalid transparency setting supplied - valid settings are"
  3221.             PRINT "- : -1 (constant SL_USESHEET)"
  3222.             PRINT "- :  0 (constant SL_SET)"
  3223.             PRINT "- :  1 (constant SL_NONE)"
  3224.         CASE 102
  3225.             PRINT "- sprite width and/or height must be greater than zero"
  3226.         CASE 103
  3227.             PRINT "- selecting to use a sheet's transparency only works with .PNG files"
  3228.             PRINT "- the function was passed a "; info; " file."
  3229.         CASE 104
  3230.             PRINT "- there must be at least one column and one row of sprites on sheet"
  3231.             PRINT "- the sheet being loaded does not meet these minimums"
  3232.  
  3233.             'errors belonging to SL_NEW_SPRITE (110 - 119)
  3234.  
  3235.             'CASE 110
  3236.             '    PRINT "- the specified sprite sheet is not in use or does not exist"
  3237.             'CASE 111
  3238.             '    PRINT "- invalid row or column selected for specified sprite sheet"
  3239.         CASE 112
  3240.             PRINT "- invalid hardware / software setting supplied - valid settings are"
  3241.             PRINT "- : -1 (constant SL_SOFTWARE)"
  3242.             PRINT "- :  0 (constant SL_HARDWARE)"
  3243.         CASE 113
  3244.             PRINT "- there is no need to restore the background with hardware sprites"
  3245.             PRINT "- change background restore setting to zero (0) (constant SL_NOSAVE)"
  3246.  
  3247.     END SELECT
  3248.     COLOR 12, 0
  3249.     PRINT
  3250.     PRINT " See sprite library doumentation for further explanation."
  3251.     COLOR 7, 0
  3252.     DO: LOOP UNTIL INKEY$ = "" '                                                                        clear the keyboard buffer
  3253.     END '                                                                                               end the program
  3254.  
face.png
* face.png (Filesize: 54.83 KB, Dimensions: 551x551, Views: 388)
hands73x533.png
* hands73x533.png (Filesize: 3.47 KB, Dimensions: 219x533, Views: 201)
In order to understand recursion, one must first understand recursion.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Analog Clock Demo
« Reply #1 on: September 30, 2018, 01:28:40 am »
Terry, if you need my help, I can provide you with a digital clock, in just 20 lines of code!

Cool! I was waiting to see this one. Wow, 3000+ lines of code, nice commitment. I would love to see TheBOB make a pocket watch png for it. He used to make custom images with bitmaps. Of course today, you can just use paint and grab something from the web. Anyway, don't you just love the feeling you get when you see a project come together as anticipated? I wish this stuff would run on Android; oh well. The only problem I have with it is it apparently only runs on RET, Roman Empire Time. Other than that, I love it. Oops, have to go, It's almost X-30 and past my bedtime. I have to get up early tomorrow to feed the lions.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Analog Clock Demo
« Reply #2 on: September 30, 2018, 01:35:07 am »
Thanks Pete, I'm having a ball writing this. I was away from QB64 for way too long. The new features and power of QB64 now available are making this nice and easy. I wrote the old library in 2011 using v0.954 SDL.

Yeah, the graphics are cheesy but I just snagged some random ones off the net. I was having some issues with my layer routines and needed a full running program to sort them out, hence the analog clock demo.

Even I was surprised at how easy and quickly I built the little demo. I'm hoping this library gets more use than the old one did.
In order to understand recursion, one must first understand recursion.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Analog Clock Demo
« Reply #3 on: September 30, 2018, 04:16:00 am »
Hi TerryRitchie,
 It's a great job, too big for me to know what do what. There are two things I noticed. The minute hand position is a little delayed (about ten seconds compared to system time) and the window is not redrawn when dragging the bottom. But even so it is a wonderful job.
« Last Edit: September 30, 2018, 04:17:07 am by Petr »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Analog Clock Demo
« Reply #4 on: September 30, 2018, 05:13:17 am »
Wow. Impressive amount of work! Well done! I personally would not have had the patience... Very nicely done!

J
Logic is the beginning of wisdom.

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Analog Clock Demo
« Reply #5 on: September 30, 2018, 07:19:09 am »
Lovely work Terry,

I watched it go around 4 or 5 times til I realized what I was actually doing... I realized it's still the weekend and there's no need to stare at the clock... (I reserve that activity for boredom at school.)

This effort of yours helped me reach somewhat of an epiphany with respect to beefy QB64 projects, especially those we want others to use. There seem to be two kinds of QB64 programmers: (i) those who openly use their own product, and (ii) those who don't. It *always* seems that the more successful works are "bulldogged" by the author, sometimes for a few years before becoming part of the local institutional knowledge. That all said, keep up the awesome work, and more importantly, keep up the bite-size demonstrations and tidbits that flex the muscles of this thing.
You're not done when it works, you're done when it's right.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Analog Clock Demo
« Reply #6 on: September 30, 2018, 08:15:26 am »
"An eye for an eye like a fish needs a bicycle" - Adolf Lincoln

Or... You can't tune a bicycle but you can tune-a-fish. - Ida Rather-Notsay
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

FellippeHeitor

  • Guest
Re: Analog Clock Demo
« Reply #7 on: September 30, 2018, 09:04:03 am »
A well-worked on library shows in the end-user code that uses it, as it'll be dead simple as you prove with this sample, Terry.

Your libraries have always set a standard, this one is no different.

Great job, as always.

Also: I agree 100% with STx. Keep the usage examples coming as the library matures as a whole. That keeps us all posted and maintains the fire lit.

Fellippe.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Analog Clock Demo
« Reply #8 on: September 30, 2018, 11:08:08 am »
Thanks for the feedback everyone, I really do appreciate it.

Quote
The minute hand position is a little delayed (about ten seconds compared to system time) and the window is not redrawn when dragging the bottom.

I noticed both of these two. I literally threw the program together in about 30 minutes so I didn't pay much attention to detail. The resize quirk in particular has me puzzled and is something I'll need to look into since I want to add resizing to the library for screen scaling.

Quote
keep up the bite-size demonstrations and tidbits that flex the muscles of this thing.

I'll need to do that more often now since full size programs are going to be required to debug the many interactions the library has internally. Do you guys remember Neko the Cat? A little cat that would chase your mouse around on the screen that first appeared in Windows 3.0 back in 1991? I'm working on that right now to highlight how automatic animation, automatic motion, and automatic rotation work together to bring a sprite to life. I may have that done later on today.
In order to understand recursion, one must first understand recursion.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Analog Clock Demo
« Reply #9 on: September 30, 2018, 02:56:17 pm »
That's the wrong use of the word, "two" marine. Drop and give me $50! And yes, that's the correct use of the dollar sign. Hey, push ups don't pay the bills, you know.

Cats? Try out the Animax program in the QB64 programs folder by TheBOB. I think you'll enjoy it.

Pete

Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Analog Clock Demo
« Reply #10 on: September 30, 2018, 04:31:23 pm »
I actually meant two, just forgot to finish the statement:

"I noticed both of these two as well.", as in two errors found. The English language is such a mess ... to, too, two, there, their, they're, affect, effect, compliment, complement, bear, bare, bar (WV variant) ... ugh.

Yeah, $50 would be about right for my age. I doubt I have 50 actual push-ups left in me. O.o
In order to understand recursion, one must first understand recursion.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Analog Clock Demo
« Reply #11 on: September 30, 2018, 05:43:58 pm »
Your write to Pete?

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Analog Clock Demo
« Reply #12 on: September 30, 2018, 06:28:27 pm »
In order to understand recursion, one must first understand recursion.