QB64.org Forum

Active Forums => Programs => Topic started by: TerryRitchie on September 06, 2018, 01:44:41 am

Title: Sprite Library Revisited
Post by: TerryRitchie on September 06, 2018, 01:44:41 am
[UPDATE:] This now contains the new sprite library work in progress.

Original post below

I'm currently in the process of updating my sprite library to take advantage of new features available in QB64 that were not present in 2012 when I wrote the library. I also want to enhance the collision detection routines (and finally get a fully working pixel perfect detection routine as well). One problem when working with sprite sheets is that every sprite needs to be the same size. As an example look below at the sprite sheet I created of a TR3B UFO a few days ago. Each sprite is 266x266 in size, however there is a lot of wasted space on many of them, especially the sprites in the middle. This not only takes up RAM but does not play well with collision detection as two dead spaces can trigger a collision when the images contained within did not actually touch. I purposely designed this sprite sheet to see if I could overcome these issues.

Below is some proof of concept code I wrote that detects the image within each sprite, cuts each individual sprite down to its minimum size, then saves an x,y offset value so the sprites can be successfully lined up later even though they are wildly different in size. This should allow rectangular collision detection to be much more accurate and the memory used by the sprites much less.

Keep in mind, the code is sloppy and will need to be cleaned up but I wanted to get other's opinion on this. Do you think I am on the right track or is there a better way of achieving this that I need to know about? Could my image detection routine be done simpler or in a better manner?

Code: QB64: [Select]
  1. '*
  2. '* constants used with SL_FLIP_SPRITE subroutine
  3. '*
  4.  
  5. CONST SL_NOFLIP = 0
  6. CONST SL_HORIZONTAL = 1
  7. CONST SL_VERTICAL = 2
  8. CONST SL_FLIPBOTH = 3
  9.  
  10. '*
  11. '* constants used with SL_NEW_SPRITE_SHEET function
  12. '*
  13.  
  14. CONST SL_SHEETTRANSPARENCY = -1 '       use sheet's transparency info (.PNG)
  15. CONST SL_SETTRANSPARENCY = 0 '          manually set transparency
  16. CONST SL_NOTRANSPARENCY = 1 '           don't use transparency with sheet
  17.  
  18. '*
  19. '* constants used with SL_NEW_SPRITE function
  20. '*
  21.  
  22. CONST SL_NOSAVE = 0 '                   sprite will not save background
  23. CONST SL_SAVE = -1 '                    sprite will save background
  24.  
  25.  
  26. '*
  27. '* type declarations
  28. '*
  29.  
  30. TYPE SL_SHEET ' *********************** sprite sheet database ***************************************
  31.     image AS LONG '                     software sprite image
  32.     mask AS LONG '                      software mask image
  33.     spritewidth AS INTEGER '            width of sprite
  34.     spriteheight AS INTEGER '           height of sprite
  35.     collx1 AS INTEGER '                 collision box top left x
  36.     colly1 AS INTEGER '                 collision box top left y
  37.     collx2 AS INTEGER '                 collision box bottom right x
  38.     colly2 AS INTEGER '                 collision box bottom right y
  39.     transparency AS INTEGER '           -1 (TRUE) if sheet uses transparency
  40.  
  41. TYPE SL_SPRITE ' ********************** sprite database *********************************************
  42.     inuse AS INTEGER '                  this array index in use
  43.     sheet AS INTEGER '                  sheet sprite belongs to
  44.     column AS INTEGER '                 the column on the sheet the sprite resides
  45.     row AS INTEGER '                    the row on the sheet the sprite resides
  46.     sprite AS LONG '                    hardware image
  47.     image AS LONG '                     software image
  48.     mask AS LONG '                      software mask image
  49.     spritewidth AS INTEGER '            width of sprite
  50.     spriteheight AS INTEGER '           height of sprite
  51.     rsprite AS LONG '                   rotated sprite hardware image
  52.     rimage AS LONG '                    rotated sprite software image
  53.     rmask AS LONG '                     rotated sprite mask software image
  54.     rspritewidth AS INTEGER '           rotated sprite image width
  55.     rspriteheight AS INTEGER '          rotated sprite image height
  56.     background AS LONG '                background image behind sprite
  57.     xreal AS SINGLE '                   x location of sprite (center point)
  58.     yreal AS SINGLE '                   y location of sprite (center point)
  59.     xint AS INTEGER '                   x location of sprite on screen INT(xreal) (center point)
  60.     yint AS INTEGER '                   y location of sprite on screen INT(yreal) (center point)
  61.     xactual AS INTEGER '                x location of sprite on screen (upper left x)
  62.     yactual AS INTEGER '                y location of sprite on screen (upper left y)
  63.     restore AS INTEGER '                -1 (true) if sprite restores background
  64.     collx1 AS INTEGER '                 collision box top left x
  65.     colly1 AS INTEGER '                 collision box top left y
  66.     collx2 AS INTEGER '                 collision box bottom right x
  67.     colly2 AS INTEGER '                 collision box bottom right y
  68.     flip AS INTEGER '                   flip horizontally, vertically, or both
  69.     rotation AS SINGLE '                rotation angle of sprite (0 - 359.999)
  70.     transparency AS INTEGER '           -1 (TRUE) if sprite uses transparency
  71.  
  72. TYPE SL_ROTATE '*********************** precalculated rotation table ********************************
  73.     rwidth AS INTEGER '                 width of rotated sprite
  74.     rheight AS INTEGER '                height of rotated sprite
  75.     px0 AS INTEGER '                    rectangular rotation coordinates
  76.     px1 AS INTEGER
  77.     px2 AS INTEGER
  78.     px3 AS INTEGER
  79.     py0 AS INTEGER
  80.     py1 AS INTEGER
  81.     py2 AS INTEGER
  82.     py3 AS INTEGER
  83.  
  84. '*
  85. '* defined arrays
  86. '*
  87.  
  88. REDIM SL_sheet(1, 1, 1) AS SL_SHEET '   master sprite sheet array
  89. REDIM SL_sprite(1) AS SL_SPRITE '       master working sprite array
  90. REDIM SL_rotate(1, 359) AS SL_ROTATE '  precalculated rotation values
  91.  
  92. '*
  93. '* main code (for testing)
  94. '*
  95.  
  96. kongsheet = SL_NEW_SPRITE_SHEET("dkong.png", 64, 64, SL_SETTRANSPARENCY, _RGB32(255, 0, 255))
  97. mysprite% = SL_NEW_SPRITE(kongsheet, 1, 1, SL_NOSAVE)
  98. mysprite2% = SL_NEW_SPRITE(kongsheet, 1, 1, SL_NOSAVE)
  99.  
  100. 'SL_FLIP_SPRITE mysprite%, SL_NOFLIP
  101.  
  102. SCREEN _NEWIMAGE(640, 480, 32)
  103.  
  104.     _LIMIT 120
  105.     SL_PUT_SPRITE 128, 128, mysprite2%
  106.     angle = angle + 1: IF angle = 360 THEN angle = 0
  107.     SL_ROTATE_SPRITE mysprite%, angle
  108.     CIRCLE (128, 128), 64, _RGB32(255, 255, 255)
  109.     SL_PUT_SPRITE 128, 128, mysprite%
  110.     _DISPLAY
  111.  
  112.  
  113.  
  114.  
  115. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  116. SUB SL_ROTATE_SPRITE (handle AS INTEGER, degrees AS INTEGER) '                                                                                                                         SL_ROTATE_SPRITE
  117.     'ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  118.     '³                    °°°±±±²²²ÛÛÛ COMMAND DESCRIPTION AND USAGE ÛÛÛ²²²±±±°°°                     ³                                °°°±±±²²²ÛÛÛ NOTES ÛÛÛ²²²±±±°°°                                ³
  119.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  120.     '³                                                                                                ³                                                                                               ³
  121.     '³                                                                                                ³                                                                                               ³
  122.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  123.     '³                            °°°±±±²²²ÛÛÛ KNOWN ISSUES ÛÛÛ²²²±±±°°°                              ³                               °°°±±±²²²ÛÛÛ CREDITS ÛÛÛ²²²±±±°°°                               ³
  124.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  125.     '³                                                                                                ³ Portions of this subroutine have code based off of Galleon's RotoZoom subroutine in the QB64  ³
  126.     '³                                                                                                ³ documentation at http://[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/wiki/index.php?title=MAPTRIANGLE (link no longer works)      ³
  127.     '³                                                                                                ³                                                                                               ³
  128.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  129.     '³                                                                          °°°±±±²²²ÛÛÛ THEORY OF OPERATION ÛÛÛ²²²±±±°°°                                                                         ³
  130.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  131.     '³                                                                                                                                                                                                ³
  132.     '³                                                                                                                                                                                                ³
  133.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  134.     '³                                                                                °°°±±±²²²ÛÛÛ HISTORY ÛÛÛ²²²±±±°°°                                                                               ³
  135.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  136.     '³ Date: 09/11/18 by Terry Ritchie                                                                                                                                                                ³
  137.     '³     : Initial writing of code.                                                                                                                                                                 ³
  138.     '³                                                                                                                                                                                                ³
  139.     'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  140.  
  141.     ' declare global variables
  142.  
  143.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  144.     SHARED SL_rotate() AS SL_ROTATE '   precalculated rotation table
  145.  
  146.     'declare local variables
  147.  
  148.     DIM px0 AS INTEGER '                precalculated polar coordinates
  149.     DIM px1 AS INTEGER
  150.     DIM px2 AS INTEGER
  151.     DIM px3 AS INTEGER
  152.     DIM py0 AS INTEGER
  153.     DIM py1 AS INTEGER
  154.     DIM py2 AS INTEGER
  155.     DIM py3 AS INTEGER
  156.     DIM sw AS INTEGER '                 sprite width
  157.     DIM sh AS INTEGER '                 sprite height
  158.     DIM rw AS INTEGER '                 precalculated rotated sprite width
  159.     DIM rh AS INTEGER '                 precalculated rotated sprite height
  160.  
  161.     ' perform error checks
  162.  
  163.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  164.         SL_ERROR "SL_ROTATE_SPRITE", 500, "" '                                                          no, report error to programmer
  165.     END IF
  166.  
  167.     ' correct degree angle if needed (needs to be 0 - 359)
  168.  
  169.     IF degrees = 360 THEN '                                                                             is it 360?
  170.         degrees = 0 '                                                                                   yes, that's the same as 0
  171.     ELSEIF degrees < 0 THEN '                                                                           is it less than 360?
  172.         DO '                                                                                            yes
  173.             degrees = dgrees + 360 '                                                                    increase by 360
  174.         LOOP UNTIL degrees > 0 '                                                                        until it's in a valid range
  175.     ELSEIF degrees > 360 THEN '                                                                         is it greater than 360?
  176.         DO '                                                                                            yes
  177.             degrees = degrees - 360 '                                                                   decrease by 360
  178.         LOOP UNTIL degrees < 360 '                                                                      until it's in a valid range
  179.     END IF
  180.     SL_sprite(handle).rotation = degrees '                                                              remember degree of rotation
  181.     IF degrees = 0 THEN EXIT SUB '                                                                      no rotation needed, leave
  182.     SL_sprite(handle).rspritewidth = SL_rotate(SL_sprite(handle).sheet, degrees).rwidth '               get precalculated rotated sprite width
  183.     SL_sprite(handle).rspriteheight = SL_rotate(SL_sprite(handle).sheet, degrees).rheight '             get precalculated rotated sprite height
  184.     px0 = SL_rotate(SL_sprite(handle).sheet, degrees).px0 '                                             get precalculated polar coordinates
  185.     px1 = SL_rotate(SL_sprite(handle).sheet, degrees).px1
  186.     px2 = SL_rotate(SL_sprite(handle).sheet, degrees).px2
  187.     px3 = SL_rotate(SL_sprite(handle).sheet, degrees).px3
  188.     py0 = SL_rotate(SL_sprite(handle).sheet, degrees).py0
  189.     py1 = SL_rotate(SL_sprite(handle).sheet, degrees).py1
  190.     py2 = SL_rotate(SL_sprite(handle).sheet, degrees).py2
  191.     py3 = SL_rotate(SL_sprite(handle).sheet, degrees).py3
  192.     rw = SL_rotate(SL_sprite(handle).sheet, degrees).rwidth '                                           get precalculated rotated sprite width
  193.     rh = SL_rotate(SL_sprite(handle).sheet, degrees).rheight '                                          get precalculated rotated sprite height
  194.     sw = SL_sprite(handle).spritewidth - 1 '                                                            get sprite width
  195.     sh = SL_sprite(handle).spriteheight - 1 '                                                           get sprite height
  196.     IF SL_sprite(handle).rimage THEN _FREEIMAGE SL_sprite(handle).rimage '                              free rotated image if it already exists
  197.     SL_sprite(handle).rimage = _NEWIMAGE(rw, rh, 32) '                                                  create rotated image
  198.     _MAPTRIANGLE (0, 0)-(0, sh)-(sw, sh), SL_sprite(handle).image TO _
  199.                  (px0, py0)-(px1, py1)-(px2, py2), SL_sprite(handle).rimage '                           map rotated sprite onto image
  200.     _MAPTRIANGLE (0, 0)-(sw, 0)-(sw, sh), SL_sprite(handle).image TO _
  201.                  (px0, py0)-(px3, py3)-(px2, py2), SL_sprite(handle).rimage
  202.     IF SL_sprite(handle).rsprite THEN _FREEIMAGE SL_sprite(handle).rsprite '                            free rotated hardware sprite if it alreadt exists
  203.     SL_sprite(handle).rsprite = _COPYIMAGE(SL_sprite(handle).rimage, 33) '                              create hardware sprite of rotated image
  204.     IF SL_sprite(handle).transparency THEN '                                                            does this sprite have a mask?
  205.         IF SL_sprite(handle).rmask THEN _FREEIMAGE SL_sprite(handle).rmask '                            yes, free mask image if it already exists
  206.         SL_sprite(handle).rmask = _NEWIMAGE(rw, rh, 32) '                                               created rotated mask image
  207.         _MAPTRIANGLE (0, 0)-(0, sh)-(sw, sh), SL_sprite(handle).mask TO _
  208.                      (px0, py0)-(px1, py1)-(px2, py2), SL_sprite(handle).rmask '                        map rotated mask onto image
  209.         _MAPTRIANGLE (0, 0)-(sw, 0)-(sw, sh), SL_sprite(handle).mask TO _
  210.                      (px0, py0)-(px3, py3)-(px2, py2), SL_sprite(handle).rmask
  211.     END IF
  212.  
  213.  
  214. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  215. SUB SL_FLIP_SPRITE (handle AS INTEGER, flip AS INTEGER) '                                                                                                                                SL_FLIP_SPRITE
  216.     'ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  217.     '³                    °°°±±±²²²ÛÛÛ COMMAND DESCRIPTION AND USAGE ÛÛÛ²²²±±±°°°                     ³                                °°°±±±²²²ÛÛÛ NOTES ÛÛÛ²²²±±±°°°                                ³
  218.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  219.     '³ Sets a sprite's flipping behavior when drawn to the screen.                                    ³ - Four constants have been created for this subroutine:                                       ³
  220.     '³                                                                                                ³   : SL_NOFLIP     (0) no flipping desired (or reset flip behavior)                            ³
  221.     '³ SL_FLIP_SPRITE mysprite, SL_NOFLIP                                                             ³   : SL_HORIZONTAL (1) flip sprite horizontally                                                ³
  222.     '³                                                                                                ³   : SL_VERTICAL   (2) flip sprite vertically                                                  ³
  223.     '³ input : handle - the sprite to flip.                                                           ³   : SL_FLIPBOTH   (3) flip sprite both horizontally and vertically                            ³
  224.     '³         flip   - the type of flip desired:                                                     ³ - Once a flip behavior has been set it will remain in effect until the behavior is changed.   ³
  225.     '³                  : 0 - no flipping desired (or reset flip behavior)                            ³ - This subroutine will report an error on the following conditions:                           ³
  226.     '³                  : 1 - flip sprite horizontally                                                ³   : An invalid sprite has been requested.                                                     ³
  227.     '³                  : 2 - flip sprite vertically                                                  ³   : An invalid flip behavior.                                                                 ³
  228.     '³                  : 3 - flip sprite both horizontally and vertically                            ³                                                                                               ³
  229.     '³                                                                                                ³                                                                                               ³
  230.     '³ Sets  : SL_sprite(handle).flip = flip  (sets the flip behavior for later use)                  ³                                                                                               ³
  231.     '³                                                                                                ³                                                                                               ³
  232.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  233.     '³                            °°°±±±²²²ÛÛÛ KNOWN ISSUES ÛÛÛ²²²±±±°°°                              ³                               °°°±±±²²²ÛÛÛ CREDITS ÛÛÛ²²²±±±°°°                               ³
  234.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  235.     '³ None                                                                                           ³ None                                                                                          ³
  236.     '³                                                                                                ³                                                                                               ³
  237.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  238.     '³                                                                          °°°±±±²²²ÛÛÛ THEORY OF OPERATION ÛÛÛ²²²±±±°°°                                                                         ³
  239.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  240.     '³ A sprite array setting will be made for use by other library routines.                                                                                                                         ³
  241.     '³                                                                                                                                                                                                ³
  242.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  243.     '³                                                                                °°°±±±²²²ÛÛÛ HISTORY ÛÛÛ²²²±±±°°°                                                                               ³
  244.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  245.     '³ Date: 09/11/18 by Terry Ritchie                                                                                                                                                                ³
  246.     '³     : Initial writing of code.                                                                                                                                                                 ³
  247.     '³                                                                                                                                                                                                ³
  248.     'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  249.  
  250.     ' declare global variables
  251.  
  252.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  253.  
  254.     ' perform error checks
  255.  
  256.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  257.         SL_ERROR "SL_FLIP_SPRITE", 400, "" '                                                            no, report error to programmer
  258.     END IF
  259.     IF flip < 0 OR flip > 3 THEN '                                                                      valid flip behavior requested?
  260.         SL_ERROR "SL_FLIP_SPRITE", 401, "" '                                                            no, report error to programmer
  261.     END IF
  262.     SL_sprite(handle).flip = flip '                                                                     set flipping behavior
  263.  
  264.  
  265. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  266. SUB SL_PUT_SPRITE (x AS SINGLE, y AS SINGLE, handle AS INTEGER) '                                                                                                                         SL_PUT_SPRITE
  267.     'ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  268.     '³                    °°°±±±²²²ÛÛÛ COMMAND DESCRIPTION AND USAGE ÛÛÛ²²²±±±°°°                     ³                                °°°±±±²²²ÛÛÛ NOTES ÛÛÛ²²²±±±°°°                                ³
  269.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  270.     '³ Places a sprite on the current _DEST (normally screen) at the coordinates provided.            ³ - The x and y values supplied by the programmer can be sent in as single precision to allow   ³
  271.     '³                                                                                                ³   for fine x and y increments. Internally the final x and y values needed for image placement ³
  272.     '³ SL_PUT_SPRITE 100, 100, mysprite%                                                              ³   are converted to integer values.                                                            ³
  273.     '³                                                                                                ³                                                                                               ³
  274.     '³ Input : x      - x location (column) to place sprite.                                          ³                                                                                               ³
  275.     '³         y      - y location (row) to place sprite.                                             ³                                                                                               ³
  276.     '³         handle - the sprite to place on the screen.                                            ³                                                                                               ³
  277.     '³                                                                                                ³                                                                                               ³
  278.     '³ Sets  :                                                                                        ³                                                                                               ³
  279.     '³                                                                                                ³                                                                                               ³
  280.     '³                                                                                                ³                                                                                               ³
  281.     '³                                                                                                ³                                                                                               ³
  282.     '³                                                                                                ³                                                                                               ³
  283.     '³                                                                                                ³                                                                                               ³
  284.     '³ Errors: All reported errors will be in the 300 - 399 range for this function.                  ³                                                                                               ³
  285.     '³                                                                                                ³                                                                                               ³
  286.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  287.     '³                            °°°±±±²²²ÛÛÛ KNOWN ISSUES ÛÛÛ²²²±±±°°°                              ³                               °°°±±±²²²ÛÛÛ CREDITS ÛÛÛ²²²±±±°°°                               ³
  288.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  289.     '³                                                                                                ³                                                                                               ³
  290.     '³                                                                                                ³                                                                                               ³
  291.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  292.     '³                                                                          °°°±±±²²²ÛÛÛ THEORY OF OPERATION ÛÛÛ²²²±±±°°°                                                                         ³
  293.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  294.     '³                                                                                                                                                                                                ³
  295.     '³                                                                                                                                                                                                ³
  296.     '³                                                                                                                                                                                                ³
  297.     '³                                                                                                                                                                                                ³
  298.     '³                                                                                                                                                                                                ³
  299.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  300.     '³                                                                                °°°±±±²²²ÛÛÛ HISTORY ÛÛÛ²²²±±±°°°                                                                               ³
  301.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  302.     '³ Date: 09/10/18 by Terry Ritchie                                                                                                                                                                ³
  303.     '³     : Initial writing of code.                                                                                                                                                                 ³
  304.     '³                                                                                                                                                                                                ³
  305.     'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  306.  
  307.     ' declare global variables
  308.  
  309.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  310.  
  311.     ' declare local variables
  312.  
  313.     DIM xa AS INTEGER '                 actual x location of sprite on screen
  314.     DIM ya AS INTEGER '                 actual y location of sprite on screen
  315.     DIM sw AS INTEGER '                 width of sprite to be drawn
  316.     DIM sh AS INTEGER '                 height of sprite to be drawn
  317.     DIM sprite AS LONG '                the sprite to be drawn
  318.  
  319.     ' perform error checks
  320.  
  321.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  322.         SL_ERROR "SL_PUT_SPRITE", 300, "" '                                                             no, report error to programmer
  323.     END IF
  324.  
  325.     'local variable setup
  326.  
  327.     SL_sprite(handle).xreal = x '                                                             (SINGLE)  save requested x center location
  328.     SL_sprite(handle).yreal = y '                                                             (SINGLE)  save requested y center location
  329.     SL_sprite(handle).xint = INT(x) '                                                        (INTEGER)  save screen x center location
  330.     SL_sprite(handle).yint = INT(y) '                                                        (INTEGER)  save screen y center location
  331.     IF SL_sprite(handle).rotation THEN '                                                                is sprite rotated?
  332.         sprite = SL_sprite(handle).rsprite '                                                            yes, get rotated sprite image
  333.         sw = SL_sprite(handle).rspritewidth '                                                           get rotated sprite width
  334.         sh = SL_sprite(handle).rspriteheight '                                                          get rotated sprite height
  335.     ELSE '                                                                                              sprite is not rotated
  336.         sprite = SL_sprite(handle).sprite '                                                             get standard sprite image
  337.         sw = SL_sprite(handle).spritewidth '                                                            get standard sprite width
  338.         sh = SL_sprite(handle).spriteheight '                                                           get standard sprite height
  339.     END IF
  340.     xa = SL_sprite(handle).xint - sw \ 2 '                                                              calculate actual screen x location from center
  341.     ya = SL_sprite(handle).yint - sh \ 2 '                                                              calculate actual screen y location from center
  342.     SL_sprite(handle).xactual = xa '                                                         (INTEGER)  save actual screen x location
  343.     SL_sprite(handle).yactual = ya '                                                         (INTEGER)  save actual screen y location
  344.  
  345.     ' place sprite on the current destination
  346.  
  347.     SELECT CASE SL_sprite(handle).flip '                                                                which flipping style is selected?
  348.         CASE 0 '                                                                  (constant SL_NOFLIP)  normal, no flipping
  349.             _PUTIMAGE (xa, ya), sprite '                                                                draw normal sprite
  350.         CASE 1 '                                                              (constant SL_HORIZONTAL)  flip horizontally
  351.             _PUTIMAGE (xa + sw - 1, ya)-(xa, ya + sh - 1), sprite '                                     draw horizontally flipped sprite
  352.         CASE 2 '                                                                (constant SL_VERTICAL)  flip vertically
  353.             _PUTIMAGE (xa, ya + sh - 1)-(xa + sw - 1, ya), sprite '                                     draw vertically flipped sprite
  354.         CASE 3 '                                                                (constant SL_FLIPBOTH)  flip vertically and horizontally
  355.             _PUTIMAGE (xa + sw - 1, ya + sh - 1)-(xa, ya), sprite '                                     draw horizontally and vertically flipped sprite
  356.     END SELECT
  357.  
  358.  
  359. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  360. FUNCTION SL_NEW_SPRITE (sheet AS INTEGER, column AS INTEGER, row AS INTEGER, restores AS INTEGER) '                                                                                       SL_NEW_SPRITE
  361.     'ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  362.     '³                    °°°±±±²²²ÛÛÛ COMMAND DESCRIPTION AND USAGE ÛÛÛ²²²±±±°°°                     ³                                °°°±±±²²²ÛÛÛ NOTES ÛÛÛ²²²±±±°°°                                ³
  363.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  364.     '³ Creates a pointer to a sprite contained in the SL_sprite database array.                       ³ - Two constants have been created for use with this function:                                 ³
  365.     '³                                                                                                ³   : SL_NOSAVE ( 0) do not save the background image behind sprite between calls.              ³
  366.     '³ mysprite% = SL_NEW_SPRITE(mysheet%, 2, 3, SL_NOSAVE)                                           ³   : SL_SAVE   (-1) save the background image behind sprite between calls.                     ³
  367.     '³                                                                                                ³ - The function will report an error on the following conditions:                              ³
  368.     '³ Input : sheet    - the sprite sheet the sprite resides on.                                     ³   : An invalid sprite sheet has been selected.                                                ³
  369.     '³         column   - the column in the sprite sheet the sprite resides in.                       ³   : An invalid row or column value within a sprite sheet has been requested.                  ³
  370.     '³         row      - the row in the sprite sheet the sprite resides in.                          ³   : An invalid background image restoration method has been requested.                        ³
  371.     '³         restores - background saving behavior                                                  ³                                                                                               ³
  372.     '³                    :  0 - don't restore background between calls.                              ³                                                                                               ³
  373.     '³                    : -1 - restore the background between calls.                                ³                                                                                               ³
  374.     '³                                                                                                ³                                                                                               ³
  375.     '³ Output: an integer value greater than zero (0) that acts as a handle pointing to the sheet and ³                                                                                               ³
  376.     '³         location on the sheet where a sprite resides.                                          ³                                                                                               ³
  377.     '³                                                                                                ³                                                                                               ³
  378.     '³ Sets  : SL_sprite(x).inuse        = -1       (TRUE, this sprite index is in use)               ³                                                                                               ³
  379.     '³         SL_sprite(x).sheet        = sheet    (the sprite sheet where this sprite resides)      ³                                                                                               ³
  380.     '³         SL_sprite(x).column       = column   (column within sprite sheet where sprite resides) ³                                                                                               ³
  381.     '³         SL_sprite(x).row          = row      (row within sprite sheet where sprite resides)    ³                                                                                               ³
  382.     '³         SL_sprite(x).restore      = restores (background save behavior of sprite)              ³                                                                                               ³
  383.     '³         SL_sprite(x).spritewidth             (sprite width copied from sprite sheet)           ³                                                                                               ³
  384.     '³         SL_sprite(x).spriteheight            (sprite height copied from sprite sheet)          ³                                                                                               ³
  385.     '³         SL_sprite(x).collx1                  (upper left collision box x copied from sheet)    ³                                                                                               ³
  386.     '³         SL_sprite(x).colly1                  (upper left collision box y copied from sheet)    ³                                                                                               ³
  387.     '³         SL_sprite(x).collx2                  (lower right collision box x copied from sheet)   ³                                                                                               ³
  388.     '³         SL_sprite(x).colly2                  (lower right collision box y copied from sheet)   ³                                                                                               ³
  389.     '³         SL_sprite(x).sprite                  (hardware sprite image created from sheet image)  ³                                                                                               ³
  390.     '³         SL_sprite(x).image                   (software sprite image copied from sheet image)   ³                                                                                               ³
  391.     '³         SL_sprite(x).mask                    (software mask image copied from sheet image)     ³                                                                                               ³
  392.     '³                                                                                                ³                                                                                               ³
  393.     '³         all other SL_sprite(x).* subvariables reset to their initial value                     ³                                                                                               ³
  394.     '³                                                                                                ³                                                                                               ³
  395.     '³ Errors: All reported errors will be in the 200 - 299 range for this function.                  ³                                                                                               ³
  396.     '³                                                                                                ³                                                                                               ³
  397.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  398.     '³                            °°°±±±²²²ÛÛÛ KNOWN ISSUES ÛÛÛ²²²±±±°°°                              ³                               °°°±±±²²²ÛÛÛ CREDITS ÛÛÛ²²²±±±°°°                               ³
  399.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  400.     '³ None                                                                                           ³ None                                                                                          ³
  401.     '³                                                                                                ³                                                                                               ³
  402.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  403.     '³                                                                          °°°±±±²²²ÛÛÛ THEORY OF OPERATION ÛÛÛ²²²±±±°°°                                                                         ³
  404.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  405.     '³ The sprite array database is scanned for a free index and once found that index number becomes the handle (pointer) the the sprite being created. The new index contains further pointers to   ³
  406.     '³ where the requested sprite is located in the sprite sheet array database; the sheet number, the row, and the column the sprite resides in within the sheet. Information from the sprite sheet  ³
  407.     '³ is then copied over (see Sets: above) from the sheet array to the sprite array. A hardware image of the sprite is then created from the software image contained in the sprite sheet.          ³
  408.     '³                                                                                                                                                                                                ³
  409.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  410.     '³                                                                                °°°±±±²²²ÛÛÛ HISTORY ÛÛÛ²²²±±±°°°                                                                               ³
  411.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  412.     '³ Date: 09/10/18 by Terry Ritchie                                                                                                                                                                ³
  413.     '³     : Initial writing of code.                                                                                                                                                                 ³
  414.     '³                                                                                                                                                                                                ³
  415.     'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  416.  
  417.     ' declare global variables
  418.  
  419.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  420.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  421.  
  422.     ' declare local variables
  423.  
  424.     DIM handle AS INTEGER '             handle (pointer) number of new sprite
  425.  
  426.     ' perform error checks
  427.  
  428.     IF sheet > UBOUND(SL_sheet) OR SL_sheet(sheet, 0, 0).image <> -1 THEN '                             valid sprite sheet requested?
  429.         SL_ERROR "SL_NEW_SPRITE", 200, "" '                                                             no, report error to programmer
  430.     END IF
  431.     IF column > UBOUND(SL_sheet, 2) OR row > UBOUND(SL_sheet, 3) OR row < 1 OR column < 1 THEN '        valid row and column requested?
  432.         SL_ERROR "SL_NEW_SPRITE", 201, "" '                                                             no, report error to programmer
  433.     END IF
  434.     IF ABS(restores) > 1 THEN '                                                                         valid background restoration behavior requested?
  435.         SL_ERROR "SL_NEW_SPRITE", 202, "" '                                                             no, report error to programmer
  436.     END IF
  437.  
  438.     ' local variable setup
  439.  
  440.     handle = 0 '                                                                                        initialize handle value
  441.  
  442.     ' increase sprite array's size if needed
  443.  
  444.     DO '                                                                                                look for next available handle
  445.         handle = handle + 1 '                                                                           increment to next handle value
  446.     LOOP UNTIL (NOT SL_sprite(handle).inuse) OR handle = UBOUND(SL_sprite) '                            stop looking when valid handle found
  447.     IF SL_sprite(handle).inuse THEN '                                                                   is the last array element in use?
  448.         handle = handle + 1 '                                                                           yes, increment to next handle value
  449.         REDIM _PRESERVE SL_sprite(handle) AS SL_SPRITE '                                                increase the size of the sprite array
  450.     END IF
  451.  
  452.     ' populate sprite array
  453.  
  454.     SL_sprite(handle).inuse = -1 '                                                              (TRUE)  mark array index as in use
  455.     SL_sprite(handle).sheet = sheet '                                                                   point to sheet where sprite resides              *
  456.     SL_sprite(handle).column = column '                                                                 point to column on sheet where sprite located    * these still needed?
  457.     SL_sprite(handle).row = row '                                                                       point to row on sheet where sprite located       *
  458.     SL_sprite(handle).restore = restores '                             (constants SL_SAVE & SL_NOSAVE)  background restore behavior of sprite
  459.     SL_sprite(handle).rsprite = 0 '                                                                     no rotated hardware image yet
  460.     SL_sprite(handle).rimage = 0 '                                                                      no rotated software image yet
  461.     SL_sprite(handle).rmask = 0 '                                                                       no rotated software mask image yet
  462.     SL_sprite(handle).background = 0 '                                                                  no background image saved yet
  463.     SL_sprite(handle).xreal = 0 '                                                                       reset x location of sprite (center x)
  464.     SL_sprite(handle).yreal = 0 '                                                                       reset y location of sprite (center y)
  465.     SL_sprite(handle).xint = 0 '                                                                        reset x location of sprite on screen INT(xreal) (center x)
  466.     SL_sprite(handle).yint = 0 '                                                                        reset y location of sprite on screen INT(yreal) (center y)
  467.     SL_sprite(handle).xactual = 0 '                                                                     reset x location of sprite on screen (upper left x)
  468.     SL_sprite(handle).yactual = 0 '                                                                     reset y location of sprite on screen (upper left y)
  469.     SL_sprite(handle).collx1 = SL_sheet(sheet, column, row).collx1 '                                    get sprite's collision box boundaries
  470.     SL_sprite(handle).colly1 = SL_sheet(sheet, column, row).colly1
  471.     SL_sprite(handle).collx2 = SL_sheet(sheet, column, row).collx2
  472.     SL_sprite(handle).colly2 = SL_sheet(sheet, column, row).colly2
  473.     SL_sprite(handle).spritewidth = SL_sheet(sheet, column, row).spritewidth '                          get width of sprite
  474.     SL_sprite(handle).spriteheight = SL_sheet(sheet, column, row).spriteheight '                        get height of sprite
  475.     SL_sprite(handle).sprite = _COPYIMAGE(SL_sheet(sheet, column, row).image, 33) '                     create hardware sprite image
  476.     SL_sprite(handle).image = _COPYIMAGE(SL_sheet(sheet, column, row).image, 32) '                      copy software sprite image from sheet
  477.     IF SL_sheet(sheet, column, row).transparency THEN '                                                 does this sprite use transparency?
  478.         SL_sprite(handle).mask = _COPYIMAGE(SL_sheet(sheet, column, row).mask, 32) '                    yes, copy software sprite mask image from sheet
  479.         SL_sprite(handle).transparency = -1 '                                                   (TRUE)  remember this sprite has a transparency layer
  480.     ELSE '                                                                                              no transparency
  481.         SL_sprite(handle).mask = 0 '                                                                    no mask will be brought in
  482.         SL_sprite(handle).transparency = 0 '                                                   (FALSE)  remember this sprite has no transparency layer
  483.     END IF
  484.     SL_sprite(handle).flip = 0 '                                                                        no sprite flipping
  485.     SL_sprite(handle).rotation = 0 '                                                                    no sprite rotation angle
  486.  
  487.     SL_NEW_SPRITE = handle
  488.  
  489.  
  490. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  491. FUNCTION SL_NEW_SPRITE_SHEET (filename AS STRING, spritewidth AS INTEGER, spriteheight AS INTEGER, transparency AS INTEGER, transcolor AS _UNSIGNED LONG) '                         SL_NEW_SPRITE_SHEET
  492.     'ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  493.     '³                    °°°±±±²²²ÛÛÛ COMMAND DESCRIPTION AND USAGE ÛÛÛ²²²±±±°°°                     ³                                °°°±±±²²²ÛÛÛ NOTES ÛÛÛ²²²±±±°°°                                ³
  494.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  495.     '³ Loads a sprite sheet's sprites into memory and stores them in the sprite sheet array. Three    ³ - The software image mask will only be created if the sprite sheet contains a transparency    ³
  496.     '³ sprite images are created for each sprite; a hardware image for displaying, a software image   ³   layer (alpha channel) either built-in or user defined.                                      ³
  497.     '³ for manipulating, and a software mask image for pixel collision detection.                     ³ - Three constants have been created for use with this function:                               ³
  498.     '³                                                                                                ³   : SL_SHEETTRANSPARENCY (-1) to have the function use built-in sprite sheet's alpha layer.   ³
  499.     '³ mysheet% = SL_NEW_SPRITE_SHEET("sprites.png", 64, 96, SL_SETTRANSPARENCY, _RGB32(255, 0, 255)) ³   : SL_SETTRANSPARENCY   ( 0) to have the function use the programmer supplied alpha value.   ³
  500.     '³                                                                                                ³   : SL_NOTRANSPARENCY    ( 1) to have the function ignore alpha channel completely.           ³
  501.     '³ Input : filename     - the name of the sprite sheet image file to load in.                     ³ - The function will report an error on the following conditions:                              ³
  502.     '³         spritewidth  - the width of every sprite contained on the sprite sheet.                ³   : A filename is supplied that does not exist.                                               ³
  503.     '³         spriteheight - the height of every sprite contained on the sprite sheet.               ³   : A sprite width or height that is less than one (1).                                       ³
  504.     '³         transparency - the type of transparency to apply to the sprite sheet and sprites:      ³   : An invalid transparency type value. Valid types are from negative one (-1) to one (1).    ³
  505.     '³                         : -1 - use the sprite sheet's built-in alpha channel (PNG files).      ³   : The sprite sheet does not contain at least one row and column of sprites.                 ³
  506.     '³                         :  0 - use the programmer assigned alpha channel value.                ³ - The programmer supplied alpha channel value will be ignored if transparency is set to a     ³
  507.     '³                         :  1 - this sheet does not have any transparency included.             ³   value of negative one (-1).                                                                 ³
  508.     '³         transcolor   - programmer assigned alpha channel value for the sprite sheet.           ³ - When transparency is set to one (1) the programmer supplied transcolor is used to identify  ³
  509.     '³                                                                                                ³   the background color used in the sprite sheet. This is still needed to find the collision   ³
  510.     '³ Output: An integer value greater than zero (0) that acts as a handle pointing to the sheet     ³   box boundaries for collision detection.                                                     ³
  511.     '³         that contains the sprites.                                                             ³                                                                                               ³
  512.     '³                                                                                                ³                                                                                               ³
  513.     '³ Sets  : SL_sheet(x, 0, 0).image        = -1      (TRUE, this sheet index is in use)            ³                                                                                               ³
  514.     '³         SL_sheet(x, 0, 0).spritewidth  = columns (the number indexes in the 2nd dimension of   ³                                                                                               ³
  515.     '³                                                   sheet array)                                 ³                                                                                               ³
  516.     '³         SL_sheet(x, 0, 0).spriteheight = rows    (the number of indexes in the 3rd dimension   ³                                                                                               ³
  517.     '³                                                   of sheet array)                              ³                                                                                               ³
  518.     '³         SL_sheet(x, c, r).image                  software image copied from sprite sheet       ³                                                                                               ³
  519.     '³         SL_sheet(x, c, r).spritewidth            width of sprite in pixels                     ³                                                                                               ³
  520.     '³         SL_sheet(x, c, r).spriteheight           height of sprite in pixels                    ³                                                                                               ³
  521.     '³         SL_sheet(x, c, r).mask                   sprite mask (image black, background white)   ³                                                                                               ³
  522.     '³         SL_sheet(x, c, r).collx1                 collision box upper left x                    ³                                                                                               ³
  523.     '³         SL_sheet(x, c, r).colly1                 collision box upper left y                    ³                                                                                               ³
  524.     '³         SL_sheet(x, c, r).collx2                 collision box lower right x                   ³                                                                                               ³
  525.     '³         SL_sheet(x, c, r).colly2                 collision box lower right y                   ³                                                                                               ³
  526.     '³           * c = column  r = row                                                                ³                                                                                               ³
  527.     '³                                                                                                ³                                                                                               ³
  528.     '³ Errors: All reported errors will be in the 100 - 199 range for this function.                  ³                                                                                               ³
  529.     '³                                                                                                ³                                                                                               ³
  530.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  531.     '³                            °°°±±±²²²ÛÛÛ KNOWN ISSUES ÛÛÛ²²²±±±°°°                              ³                               °°°±±±²²²ÛÛÛ CREDITS ÛÛÛ²²²±±±°°°                               ³
  532.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  533.     '³ Need to incorporate Steve's PNG transparency layer identifier instead of mine.                 ³ Portions of this subroutine have code based off of Galleon's RotoZoom subroutine in the QB64  ³
  534.     '³                                                                                                ³ documentation at http://[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/wiki/index.php?title=MAPTRIANGLE (link no longer works)      ³
  535.     '³                                                                                                ³                                                                                               ³
  536.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  537.     '³                                                                          °°°±±±²²²ÛÛÛ THEORY OF OPERATION ÛÛÛ²²²±±±°°°                                                                         ³
  538.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  539.     '³ Once the sprite sheet is loaded it is scanned for an alpha channel if the programmer requests to use the sheet's transparency layer. The width and height of the sheet are retrieved and then  ³
  540.     '³ divided by the sprite dimensions provided by the programmer to determine how many columns and rows of sprites exist. A three dimensional sheet array is created where the first dimension is   ³
  541.     '³ the sheet number (handle/pointer), the second and thirs dimensions are then related to the sprite column and row locations on the sheet. Each sprite is copied from the sprite sheet into the  ³
  542.     '³ sprite sheet array. Each sprite is scanned to determine the absolute image size within the sprite (background/transparency areas are ignored) to determine the smallest possible collision box ³
  543.     '³ needed for collision detection. Finally, the sprite is scanned again to create an image mask for pixel perfect detection.                                                                      ³
  544.     '³                                                                                                                                                                                                ³
  545.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  546.     '³                                                                                °°°±±±²²²ÛÛÛ HISTORY ÛÛÛ²²²±±±°°°                                                                               ³
  547.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  548.     '³ Date: 09/09/18 by Terry Ritchie                                                                                                                                                                ³
  549.     '³     : Initial writing of code.                                                                                                                                                                 ³
  550.     '³                                                                                                                                                                                                ³
  551.     'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  552.  
  553.     ' declare global variables
  554.  
  555.     SHARED SL_sheet() AS SL_SHEET '    master sprite sheet array
  556.     SHARED SL_rotate() AS SL_ROTATE '  precalculated rotation table
  557.  
  558.     ' declare local variables
  559.  
  560.     DIM handle AS INTEGER '             handle (pointer) number of new sprite sheet
  561.     DIM x AS INTEGER '                  generic counter to cycle through sheet sprite columns
  562.     DIM y AS INTEGER '                  generic counter to cycle through sheet sprite rows
  563.     DIM x1 AS INTEGER '                 generic counter to cycle though sprite for collision boundaries and mask creation
  564.     DIM y1 AS INTEGER '                 generic ocunter to cycle though sprite for collision boundaries and mask creation
  565.     DIM osource AS LONG '               original source image before this function was called
  566.     DIM odest AS LONG '                 original destination image before this function was called
  567.     DIM pixel AS _UNSIGNED LONG '       pixel color at each coordinate in sprite sheet
  568.     DIM alpha AS _UNSIGNED LONG '       alpha level of current pixel
  569.     DIM top AS INTEGER '                upper boundary of sprite image
  570.     DIM bottom AS INTEGER '             lower boundary of sprite image
  571.     DIM left AS INTEGER '               left boundary of sprite image
  572.     DIM right AS INTEGER '              right boundary of sprite image
  573.     DIM sheetimage AS LONG '            sprite sheet image
  574.     DIM sheetwidth AS INTEGER '         width of sprite sheet in pixels
  575.     DIM sheetheight AS INTEGER '        height of sprite sheet in pixels
  576.     DIM rows AS INTEGER '               number of sprite rows contained on sheet
  577.     DIM columns AS INTEGER '            number of sprite columns contained on sheet
  578.     DIM clearcolor AS _UNSIGNED LONG '  transcolor passed in will be modified
  579.     DIM tempsprite AS LONG '            temporary sprite for _CLEARCOLOR detection
  580.  
  581.     DIM px(3) AS SINGLE '               polar x coordinates of maptriangle
  582.     DIM py(3) AS SINGLE '               polar y coordinates of maptriangle
  583.     DIM sinr AS SINGLE
  584.     DIM cosr AS SINGLE
  585.     DIM bx1 AS INTEGER
  586.     DIM bx2 AS INTEGER
  587.     DIM by1 AS INTEGER
  588.     DIM by2 AS INTEGER
  589.  
  590.     ' perform error checks
  591.  
  592.     IF NOT _FILEEXISTS(filename) THEN '                                                                 does the sprite sheet exist?
  593.         SL_ERROR "SL_NEW_SPRITE_SHEET", 100, filename '                                                 no, report error to programmer
  594.     END IF
  595.     IF ABS(transparency) > 1 THEN '                                                                     valid transparency setting?
  596.         SL_ERROR "SL_NEW_SPRITE_SHEET", 101, "" '                                                       no, report error to programmer
  597.     END IF
  598.     IF spritewidth < 1 OR spriteheight < 1 THEN '                                                       valid sprite width/height supplied?
  599.         SL_ERROR "SL_NEW_SPRITE_SHEET", 102, "" '                                                       no, report error to programmer
  600.     END IF
  601.     IF transparency = -1 AND UCASE$(RIGHT$(filename, 4)) <> ".PNG" THEN '                               wrong file type for transparency?
  602.         SL_ERROR "SL_NEW_SPRITE_SHEET", 103, UCASE$(RIGHT$(filename, 4)) '                              yes, report error to programmer
  603.     END IF
  604.  
  605.     ' local variable setup
  606.  
  607.     sheetimage = _LOADIMAGE(filename, 32) '                                                             load sprite sheet file
  608.     sheetwidth = _WIDTH(sheetimage) '                                                                   get width of sheet
  609.     sheetheight = _HEIGHT(sheetimage) '                                                                 get height of sheet
  610.     columns = sheetwidth \ spritewidth '                                                                get number of whole columns of sprites
  611.     rows = sheetheight \ spriteheight '                                                                 get number of whole rows of sprites
  612.     IF columns < 1 OR rows < 1 THEN '                                                                   at least one sprite column and row on sheet?
  613.         SL_ERROR "SL_NEW_SPRITE_SHEET", 104, "" '                                                       no, report error to programmer
  614.     END IF
  615.     osource = _SOURCE '                                                                                 remember current source image
  616.     odest = _DEST '                                                                                     remember current destination image
  617.     handle = 0 '                                                                                        initialize handle value
  618.     clearcolor = transcolor '                                                                           get background/transparent color passed in
  619.  
  620.     ' increase sheet array's 1st dimension if needed to create a new sprite sheet
  621.  
  622.     DO '                                                                                                look for the next available handle
  623.         handle = handle + 1 '                                                                           increment the handle value
  624.     LOOP UNTIL (NOT SL_sheet(handle, 0, 0).image) OR handle = UBOUND(SL_sheet) '                       stop looking when valid handle value found
  625.     IF SL_sheet(handle, 0, 0).image = -1 THEN '                                                        is the last array element in use?
  626.         handle = handle + 1 '                                                                           yes, increment the handle value
  627.         REDIM _PRESERVE SL_sheet(handle, UBOUND(SL_sheet, 2), UBOUND(SL_sheet, 3)) AS SL_SHEET '        create new sheet in sprite array
  628.         REDIM _PRESERVE SL_rotate(handle, UBOUND(SL_rotate, 2)) AS SL_ROTATE
  629.     END IF
  630.  
  631.     ' increase sheet array's 2nd and 3rd dimensions if needed to match number of rows and columns
  632.  
  633.     IF columns > UBOUND(SL_sheet, 2) THEN '                                                             more columns in this sheet than others?
  634.         REDIM _PRESERVE SL_sheet(handle, columns, UBOUND(SL_sheet, 3)) AS SL_SHEET '                    yes, increase the array's 2nd dimension to match
  635.     END IF
  636.     IF rows > UBOUND(SL_sheet, 3) THEN '                                                                more rows in this sheet than others?
  637.         REDIM _PRESERVE SL_sheet(handle, UBOUND(SL_sheet, 2), rows) AS SL_SHEET '                       yes, increase the array's 3rd dimension to match
  638.     END IF
  639.  
  640.     ' the variables in SL_sheet(x, 0, 0) will serve a dual purpose
  641.     ' SL_sheet(x, 0, 0).image will contain either -1 (true) or 0 (false) to indicate the first dimension of the array is in use.
  642.     ' SL_sheet(x, 0, 0).spritewidth will contain the number of columns contained in the sheet (the array's 2nd dimension)
  643.     ' SL_sheet(x, 0, 0).spriteheight will contain the number of rows contained in the sheet (the array's 3rd dimension)
  644.  
  645.     SL_sheet(handle, 0, 0).image = -1 '                                                         (TRUE)  mark as in use
  646.     SL_sheet(handle, 0, 0).spritewidth = columns '                                                      remember number of columns in sheet
  647.     SL_sheet(handle, 0, 0).spriteheight = rows '                                                        remember number of rows in sheet
  648.  
  649.     ' identify transparency of sprite sheet if requested
  650.  
  651.     IF transparency = -1 THEN '                                        (constant SL_SHEETTRANSPARENCY)  sheet have alpha channel?
  652.         x = 0 '                                                                                         yes, start at upper left x of sheet
  653.         y = 0 '                                                                                         start at upper left y of sheet
  654.         alpha = 255 '                                                                                   assume no alpha channel
  655.         _SOURCE sheetimage '                                                                            set sprite sheet image as source image
  656.         DO '                                                                                            start looping through the sheet's pixels
  657.             pixel = POINT(x, y) '                                                                       get the pixel's color attributes
  658.             alpha = _ALPHA32(pixel) '                                                                   get the alpha level (0 - 255)
  659.             IF alpha = 0 THEN EXIT DO '                                                                 if it is transparent then leave the loop
  660.             x = x + 1 '                                                                                 move right one pixel
  661.             IF x > sheetwidth THEN '                                                                    have we gone off the sheet?
  662.                 x = 0 '                                                                                 yes, reset back to the left beginning
  663.                 y = y + 1 '                                                                             move down one pixel
  664.             END IF
  665.         LOOP UNTIL y > sheetheight '                                                                    don't stop until the entire sheet has been checked
  666.         IF alpha = 0 THEN '                                                                             did we find a transparent pixel?
  667.             tempsprite = _NEWIMAGE(1, 1, 32) '                                                          yes, create a temporary image         * why did I have to do
  668.             _CLEARCOLOR pixel, tempsprite '                                                             set pixel found as transparent        * this hack to get
  669.             clearcolor = _CLEARCOLOR(tempsprite) '                                                      get the transparent color from image  * clearcolor to come out
  670.             _FREEIMAGE tempsprite '                                                                     temporary image no longer needed      * to the right value?
  671.         ELSE '                                                                                          no transparency found within sheet
  672.             transparency = 1 '                                                                          set sheet to having no alpha channel
  673.         END IF
  674.     ELSEIF transparency = 0 THEN '                                       (constant SL_SETTRANSPARENCY)  manually set alpha channel?
  675.         _CLEARCOLOR clearcolor, sheetimage '                                                            yes, set color as transparent
  676.         clearcolor = _CLEARCOLOR(sheetimage) '                                                          get the transparent color ************* again, why this hack?
  677.     END IF
  678.  
  679.     ' load sprites from sheet and place into sprite array
  680.  
  681.     FOR x = 1 TO columns '                                                                              cycle through the sheet's columns
  682.         FOR y = 1 TO rows '                                                                             cycle through the sheet's rows
  683.             SL_sheet(handle, x, y).image = _NEWIMAGE(spritewidth, spriteheight, 32) '                   create software sprite image
  684.             IF transparency < 1 THEN '                                                                  should a mask be created?
  685.                 SL_sheet(handle, x, y).mask = _NEWIMAGE(spritewidth, spriteheight, 32) '                yes, create software sprite mask image
  686.                 _DEST SL_sheet(handle, x, y).mask '                                                     write to the mask image
  687.             ELSE
  688.                 SL_sheet(handle, x, y).transparency = 0 '                                      (FALSE)  set sprite as having no transparency
  689.             END IF
  690.             _PUTIMAGE , sheetimage, SL_sheet(handle, x, y).image,_
  691.                  ((x - 1) * spritewidth, (y - 1) * spriteheight)-_
  692.                  ((x - 1) * spritewidth + spritewidth - 1, (y - 1) * spriteheight + spriteheight - 1) ' copy sprite from sheet and place in sprite image
  693.  
  694.             ' precalculate collision boundaries and update sprite mask if needed
  695.  
  696.             _SOURCE SL_sheet(handle, x, y).image '                                                      work from the software sprite image
  697.             top = spriteheight '                                                                        set initial collision boundary markers
  698.             left = spritewidth
  699.             bottom = 0
  700.             right = 0
  701.             FOR x1 = 0 TO spritewidth - 1 '                                                             cycle through the width of sprite
  702.                 FOR y1 = 0 TO spriteheight - 1 '                                                        cycle through the height of sprite
  703.                     IF POINT(x1, y1) <> clearcolor THEN '                                               is this pixel a transparent/background color?
  704.                         IF x1 < left THEN left = x1 '                                                   no, save position if left-most pixel
  705.                         IF y1 < top THEN top = y1 '                                                     save position if top-most pixel
  706.                         IF x1 > right THEN right = x1 '                                                 save position if right-most pixel
  707.                         IF y1 > bottom THEN bottom = y1 '                                               save position if bbottom-most pixel
  708.                     END IF
  709.                     IF transparency < 1 THEN '                                                          update software sprite mask?
  710.                         IF POINT(x1, y1) = clearcolor THEN '                                            yes, is this pixel a transparent/background color?
  711.                             PSET (x1, y1), _RGB32(255, 255, 255) '                                      yes, set as white on the mask image
  712.                         END IF
  713.                     END IF
  714.                 NEXT y1
  715.             NEXT x1
  716.             SL_sheet(handle, x, y).collx1 = left '                                                      collision box top left x
  717.             SL_sheet(handle, x, y).colly1 = top '                                                       collision box top left y
  718.             SL_sheet(handle, x, y).collx2 = right '                                                     collision box bottom right x
  719.             SL_sheet(handle, x, y).colly2 = bottom '                                                    collision box bottom right y
  720.             SL_sheet(handle, x, y).spritewidth = spritewidth '                                          remember sprite width
  721.             SL_sheet(handle, x, y).spriteheight = spriteheight '                                        remember sprite height
  722.         NEXT y
  723.     NEXT x
  724.     _FREEIMAGE sheetimage '                                                                             sprite sheet image no longer needed
  725.  
  726.     ' create precalculated rotation table for the sprite sheet (0 to 359 degrees)
  727.  
  728.     FOR x = 1 TO 359
  729.         px(0) = -spritewidth / 2 '                                                                      upper left  x polar coordinate of sprite
  730.         py(0) = -spriteheight / 2 '                                                                     upper left  y polar coordinate of sprite
  731.         px(1) = px(0) '                                                                                 lower left  x polar coordinate of sprite
  732.         py(1) = spriteheight / 2 '                                                                      lower left  y polar coordinate of sprite
  733.         px(2) = spritewidth / 2 '                                                                       lower right x polar coordinate of sprite
  734.         py(2) = py(1) '                                                                                 lower right y polar coordinate of sprite
  735.         px(3) = px(2) '                                                                                 upper right x polar coordinate of sprite
  736.         py(3) = py(0) '                                                                                 upper right y polar coordinate of sprite
  737.         sinr = SIN(-x / 57.2957795131) '                                                                calculate the sin of rotation
  738.         cosr = COS(-x / 57.2957795131) '                                                                calculate the cosine of rotation
  739.         bx1 = 0 '                                                                                       upper left x boundary of sprite
  740.         by1 = 0 '                                                                                       upper left y boundary of sprite
  741.         bx2 = 0 '                                                                                       lower right x boundary of sprite
  742.         by2 = 0 '                                                                                       lower right y boundary of sprite
  743.         FOR y = 0 TO 3 '                                                                                cycle through all four polar coordinates
  744.             x2 = (px(y) * cosr + sinr * py(y)) '                                                        compute new polar coordinate location
  745.             y2 = (py(y) * cosr - px(y) * sinr) '                                                        compute new polar coordinate location
  746.             px(y) = x2 '                                                                                save the new polar coordinate
  747.             py(y) = y2 '                                                                                save the new polar coordinate
  748.             IF px(y) < bx1 THEN bx1 = px(y) '                                                           save lowest  x value seen \  NOTE: use for
  749.             IF px(y) > bx2 THEN bx2 = px(y) '                                                           save highest x value seen  \ background image         <--------------------- LOOK
  750.             IF py(y) < by1 THEN by1 = py(y) '                                                           save lowest  y value seen  / rectangle coordinates
  751.             IF py(y) > by2 THEN by2 = py(y) '                                                           save highest y value seen /
  752.         NEXT y
  753.         SL_rotate(handle, x).rwidth = bx2 - bx1 + 1 '                                                   calculate width of rotated sprite
  754.         SL_rotate(handle, x).rheight = by2 - by1 + 1 '                                                  calculate height of rotated sprite
  755.         SL_rotate(handle, x).px0 = px(0) + ((bx2 - bx1 + 1) / 2) '                                      calculate triangular coordinates
  756.         SL_rotate(handle, x).px1 = px(1) + ((bx2 - bx1 + 1) / 2)
  757.         SL_rotate(handle, x).px2 = px(2) + ((bx2 - bx1 + 1) / 2)
  758.         SL_rotate(handle, x).px3 = px(3) + ((bx2 - bx1 + 1) / 2)
  759.         SL_rotate(handle, x).py0 = py(0) + ((by2 - by1 + 1) / 2)
  760.         SL_rotate(handle, x).py1 = py(1) + ((by2 - by1 + 1) / 2)
  761.         SL_rotate(handle, x).py2 = py(2) + ((by2 - by1 + 1) / 2)
  762.         SL_rotate(handle, x).py3 = py(3) + ((by2 - by1 + 1) / 2)
  763.     NEXT x
  764.     _SOURCE osource '                                                                                   return source to current
  765.     _DEST odest '                                                                                       return destination to current
  766.     SL_NEW_SPRITE_SHEET = handle '                                                                      return the handle number pointing to this sheet
  767.  
  768.  
  769. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  770. SUB SL_ERROR (routine AS STRING, errno AS INTEGER, info AS STRING) '                                                                                                                           SL_ERROR
  771.     'ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  772.     '³                    °°°±±±²²²ÛÛÛ COMMAND DESCRIPTION AND USAGE ÛÛÛ²²²±±±°°°                     ³                                °°°±±±²²²ÛÛÛ NOTES ÛÛÛ²²²±±±°°°                                ³
  773.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  774.     '³ Reports a Sprite Library error to the programmer. Used internally only.                        ³ - A copy of this library has been provided that has all of the error checks removed. Once     ³
  775.     '³                                                                                                ³   you are sure no errors exist you would then include that library for your final             ³
  776.     '³ Input : routine - the function/subroutine the error occurred in                                ³   compilation. The error checking routines do take some processing away from your code so     ³
  777.     '³                                                                                                ³   performance will improve by removing them.                                                  ³
  778.     '³         errno   - the error number associated with the error                                   ³                                                                                               ³
  779.     '³                   100 - sprite does not exist                                                  ³                                                                                               ³
  780.     '³                   101 - sprite is not in use                                                   ³                                                                                               ³
  781.     '³                   102 - sprite can't be hidden                                                 ³                                                                                               ³
  782.     '³                   103 - invalid zoom value                                                     ³                                                                                               ³
  783.     '³                   104 - invalid rotation angle                                                 ³                                                                                               ³
  784.     '³                   105 - invalid flipping behavior                                              ³                                                                                               ³
  785.     '³                   106 - sheet does not exist                                                   ³                                                                                               ³
  786.     '³                   107 - sheet is not in use                                                    ³                                                                                               ³
  787.     '³                   108 - invalid transparency setting                                           ³                                                                                               ³
  788.     '³                   109 - invalid sprite width/height                                            ³                                                                                               ³
  789.     '³                                                                                                ³                                                                                               ³
  790.     '³         info    - any information that need to be conveyed with the error                      ³                                                                                               ³
  791.     '³                   such as a file name                                                          ³                                                                                               ³
  792.     '³                                                                                                ³                                                                                               ³
  793.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  794.     '³                            °°°±±±²²²ÛÛÛ KNOWN ISSUES ÛÛÛ²²²±±±°°°                              ³                               °°°±±±²²²ÛÛÛ CREDITS ÛÛÛ²²²±±±°°°                               ³
  795.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  796.     '³ none                                                                                           ³ This routine was created in response to a request from QB64 member pitt                       ³
  797.     '³                                                                                                ³ http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=7281.0 (link no longer works)                       ³
  798.     '³                                                                                                ³                                                                                               ³
  799.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  800.     '³                                                                          °°°±±±²²²ÛÛÛ THEORY OF OPERATION ÛÛÛ²²²±±±°°°                                                                         ³
  801.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  802.     '³ A pure text screen is shown, the font reset to default, and _AUTODISPLAY enabled. This forces the code out of any graphics screen it may currently be in. The error is then displayed to the   ³
  803.     '³ programmer based on the values passed in. The program is then forced to terminate.                                                                                                             ³
  804.     '³                                                                                                                                                                                                ³
  805.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  806.     '³                                                                                °°°±±±²²²ÛÛÛ HISTORY ÛÛÛ²²²±±±°°°                                                                               ³
  807.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  808.     '³ Date: 09/09/18 by Terry Ritchie                                                                                                                                                                ³
  809.     '³     : Initial writing of code.                                                                                                                                                                 ³
  810.     '³                                                                                                                                                                                                ³
  811.     'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  812.  
  813.     SCREEN 0, 0, 0, 0 '                                                             go to a pure text screen
  814.     _FONT 16 '                                                                      set the standard screen 0 font
  815.     IF _FULLSCREEN THEN _FULLSCREEN _OFF '                                          turn off full screen if on
  816.     _AUTODISPLAY '                                                                  auto update the display
  817.     CLS '                                                                           clear the screen
  818.     COLOR 10, 0
  819.     PRINT "                   **************************************" '             print error header
  820.     PRINT "                   ** Sprite Library Error Encountered **"
  821.     PRINT "                   **************************************"
  822.     PRINT
  823.     COLOR 15, 0
  824.     PRINT " "; routine;
  825.     COLOR 7, 0
  826.     PRINT " has reported error";
  827.     COLOR 30, 0
  828.     PRINT STR$(errno)
  829.     COLOR 7, 0
  830.     PRINT
  831.     SELECT CASE errno '                                                             which error number is being reported?
  832.         CASE 100
  833.             PRINT "- "; CHR$(34); info; CHR$(34); " sprite sheet does not exist"
  834.             PRINT "- check path or spelling"
  835.         CASE 101
  836.             PRINT "- invalid transparency setting supplied - valid settings are"
  837.             PRINT "- : -1 (constant SL_SHEETTRANSPARENCY)"
  838.             PRINT "- :  0 (constant SL_SETTRANSPARENCY)"
  839.             PRINT "- :  1 (constant SL_NOTRANSPARENCY)"
  840.         CASE 102
  841.             PRINT "- sprite width and height must be greater than zero"
  842.         CASE 103
  843.             PRINT "- selecting to use a sheet's transparency only works with .PNG files"
  844.             PRINT "- the function was passed a "; info; " file."
  845.         CASE 104
  846.             PRINT "- there must be at least one column and one row of sprites on sheet"
  847.         CASE 200
  848.             PRINT "- the specified sprite sheet is not in use or does not exist"
  849.         CASE 201
  850.             PRINT "- invalid row or column selected for specified sprite sheet"
  851.         CASE 202
  852.             PRINT "- background restore behavior for a sprite can only be 0 (FALSE) or -1 (TRUE)"
  853.         CASE 300, 400, 500
  854.             PRINT "- the requested sprite does not exist"
  855.     END SELECT
  856.     COLOR 12, 0
  857.     PRINT
  858.     PRINT " See sprite library doumentation for further explanation."
  859.     COLOR 7, 0
  860.     DO: LOOP UNTIL INKEY$ = "" '                                                    clear the keyboard buffer
  861.     END '                                                                           end the program
  862.  
  863.  
  864.  
  865. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  866. FUNCTION SL_VALID_SPRITE (handle AS INTEGER) '                                                                                                                                         SL_VALID_SPRITE
  867.     'ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  868.     '³                    °°°±±±²²²ÛÛÛ COMMAND DESCRIPTION AND USAGE ÛÛÛ²²²±±±°°°                     ³                                °°°±±±²²²ÛÛÛ NOTES ÛÛÛ²²²±±±°°°                                ³
  869.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  870.     '³ Reports on the validity of a sprite handle (pointer).                                          ³                                                                                               ³
  871.     '³                                                                                                ³                                                                                               ³
  872.     '³ valid% = SL_VALID_SPRITE(mysprite%)                                                            ³                                                                                               ³
  873.     '³                                                                                                ³                                                                                               ³
  874.     '³ Input : handle - the handle (pointer) of the sprite being examined.                            ³                                                                                               ³
  875.     '³                                                                                                ³                                                                                               ³
  876.     '³ Output: an integer value of zero (0) (FALSE) or negative 1 (-1) (TRUE)                         ³                                                                                               ³
  877.     '³                                                                                                ³                                                                                               ³
  878.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  879.     '³                            °°°±±±²²²ÛÛÛ KNOWN ISSUES ÛÛÛ²²²±±±°°°                              ³                               °°°±±±²²²ÛÛÛ CREDITS ÛÛÛ²²²±±±°°°                               ³
  880.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  881.     '³ None                                                                                           ³ None                                                                                          ³
  882.     '³                                                                                                ³                                                                                               ³
  883.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  884.     '³                                                                          °°°±±±²²²ÛÛÛ THEORY OF OPERATION ÛÛÛ²²²±±±°°°                                                                         ³
  885.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  886.     '³ The sprite database is examined at the index the handle points to. If .inuse is -1 (TRUE) then the sprite handle is valid.                                                                     ³
  887.     '³                                                                                                                                                                                                ³
  888.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  889.     '³                                                                                °°°±±±²²²ÛÛÛ HISTORY ÛÛÛ²²²±±±°°°                                                                               ³
  890.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  891.     '³ Date: 09/11/18 by Terry Ritchie                                                                                                                                                                ³
  892.     '³     : Initial writing of code.                                                                                                                                                                 ³
  893.     '³                                                                                                                                                                                                ³
  894.     'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  895.  
  896.     ' declare global variables
  897.  
  898.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  899.  
  900.     IF handle > UBOUND(SL_SPRITE) OR (NOT SL_sprite(handle).inuse) THEN '                                is this a valid sprite handle?
  901.         SL_VALID_SPRITE = 0 '                                                                   (FALSE)  no, return 0
  902.     ELSE '                                                                                               yes, it is valid
  903.         SL_VALID_SPRITE = -1 '                                                                   (TRUE)  return -1
  904.     END IF
  905.  
  906.  
  907.  
  908.  
  909. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  910.  
  911. 'ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  912. '³                    °°°±±±²²²ÛÛÛ COMMAND DESCRIPTION AND USAGE ÛÛÛ²²²±±±°°°                     ³                                °°°±±±²²²ÛÛÛ NOTES ÛÛÛ²²²±±±°°°                                ³
  913. 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  914. '³                                                                                                ³                                                                                               ³
  915. '³                                                                                                ³                                                                                               ³
  916. 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  917. '³                            °°°±±±²²²ÛÛÛ KNOWN ISSUES ÛÛÛ²²²±±±°°°                              ³                               °°°±±±²²²ÛÛÛ CREDITS ÛÛÛ²²²±±±°°°                               ³
  918. 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  919. '³                                                                                                ³                                                                                               ³
  920. '³                                                                                                ³                                                                                               ³
  921. 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  922. '³                                                                          °°°±±±²²²ÛÛÛ THEORY OF OPERATION ÛÛÛ²²²±±±°°°                                                                         ³
  923. 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  924. '³                                                                                                                                                                                                ³
  925. '³                                                                                                                                                                                                ³
  926. 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  927. '³                                                                                °°°±±±²²²ÛÛÛ HISTORY ÛÛÛ²²²±±±°°°                                                                               ³
  928. 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  929. '³                                                                                                                                                                                                ³
  930. '³                                                                                                                                                                                                ³
  931. 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  932.  
Title: Re: Sprite Library Revisited
Post by: SMcNeill on September 06, 2018, 02:01:03 am
Why not use a data file to go along with each Sprite sheet? 

MySprite.jpg would be the name of the sheet, MySprite.NFO could be the name of a simple file containing pixel coordinates for each Sprite in the sheet.  Seems the easiest way to me for variable size sprites.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 06, 2018, 02:06:51 am
Yeah, in the game industry that's called a sprite atlas and in an earlier version of my code I actually wrote the coordinates out to a file as you suggested. However, I want the library to contain as much of the inner workings as possible with the programmer shielded from all the details.

Standard practice is to have all sprites the same size and ordered on the sheet. Having the programmer supply an atlas would be a pain in the ascii for him/her, especially since they are using a sprite library to avoid learning how to actually manipulate sprites.

Make sense? I get what your saying though.

One other thing too, manually trying to center up different sized sprites is way harder than it sounds.
Title: Re: Sprite Library Revisited
Post by: SMcNeill on September 06, 2018, 08:11:18 am
Trick would be to have a program which calculates the Sprite dimensions for you, and then places the individual sprites onto a sheet and preserve the coordinates. 

Steps I'd imagine would be:

Sprite editor to make a Sprite (or MS Paint/whatever tool the user wants).  A lot of these editors set us a default size for sheet creation (a lot of the RPGmaker sprites are 64x64 or 128x128).

A QB64 program to clear color background (black or white, as I've seen both used as a standard background), and then a simple detection routine to minimize size as much as possible.  (A little 32x32 fireball would have the blank edges stripped from it.)  Resave via SaveImage to the new size in BMP or PNG format.

An INFORM program where the user can load sprites and drag them into place on a Sprite sheet, to manually minimize overall size, or to set a specific order/layout....  OR...   A program which automatically assembles the sheet for us, from the edited files.

Either way, preserving the Atlas would be an automated task and wouldn't be anything the end-user would ever have to worry about, with the added feature of saving load/runtime inside the game, as all the calculations have already been done previously, and not need to happen on demand, in game.

*********************
*********************

One personal thing I'd like to see added to your library is the ability to SetSpritePath. 

"TN,P1,N1,P1,TE,P1,E1......RA"

A simple string script which tells the Sprite to try and Turn North (load north facing spite, if you have a directional set), Pause 1 turn, North 1, Pause 1 Turn, Turn East, Pause 1 Turn, East 1.... RepeatAll.

PRESTO!  Simple patrol path instantly added!

Add simple options for NP (no path; just wander), CH (chase hero, using pathfinding as discussed previously), and PB (play brick; don't move).

It'd be the start of a simple scripting system which the user could add/expand on later with future options (such as "LC123" so if the user Left Clicks on the Sprite, the program performs event 123 which might be a Popup saying, "Hi Hero!  How's your Mama today?").

It'd take the Sprite Library from just being a library to draw/display sprites, to becoming a much more active Game Engine.   ;)
Title: Re: Sprite Library Revisited
Post by: bplus on September 06, 2018, 10:14:31 am
I was wondering how you might handle rotation (with collision) but I see you are doing a sprite for every occasion! Wow, that's allot of sprites.

Petr had some discussion with pixel perfect collision here: https://www.qb64.org/forum/index.php?topic=261.0
As I recall he was entangling images pretty well (without collision), but again wow! that's allot of calculation.


Title: Re: Sprite Library Revisited
Post by: Petr on September 06, 2018, 10:16:11 am
Hi,

What you are looking for is the collision detection between N-angles. No matter how big the picture is, the subtlety of its borders is essential. This means that a finer entry that contains more points will also be very demanding on the processor. Making the mask out of the picture is not a problem, then the outer points (image border)  (each N point according to the detector sensitivity setting). The distance between these points will be given by the character's step. For example: If the characters move in the game with a 20 pixel pitch, it is enough to evaluate the collision detection every twentieth point of the circuit.


That's what I did somehow in writing collision detection. Then I realized another thing. To speed up the operation, it is possible to clarify where there is a collision. If the body is to be detected only to the left and right, it is not necessary for the field to contain the coordinates of the bottom and the ceiling. It is possible that MLINE could well serve to detect a collision between 2 points. In essence, it only sends the points through which the line passes. Just rewrite it - not use PSET, but this output send as array outputs...

Next option is ELLIPSE collision detection.

This source create image borders for collision detection:

rewrite on line 25 image name to your image name first
Code: QB64: [Select]
  1.  
  2. TYPE Borders '                                          this is "struct" for array Borders. This array conatains borders between image and background. It is my first vesion for collision detection.
  3.     X AS INTEGER '     X coordinate for point on border between two different colors (that is why you need one colored background for writing borders)
  4.     Y AS INTEGER '     Y coordinate for point on border between two different color
  5.     Clr AS LONG '      color on border, it is read, but then is not used, you need it not, only for drawing colored circuit in original colors
  6.     maxX AS INTEGER '  use index 0 only and return maximal picture X size (real width there are calculated valid pixels only)
  7.     minX AS INTEGER '  use index 0 only and return real image start on oxis X  (for use as quadratic collision detect with MinY and MaxY)
  8.     MaxY AS INTEGER '  use index 0 only and return real height
  9.     MinY AS INTEGER '  use index 0 only and return real start on axis Y
  10.  
  11. TYPE Brd '            this is next level - "compressed" array type Borders - contains not all color borders, but just StartX, EndX (for every Y) and StartY and EndY (for every X) (just circuit)
  12.     Xmin AS INTEGER ' if picture height is 100, there is 100 records for Xmin. Its X on left, its image start X
  13.     Xmax AS INTEGER ' if picture height is 100, there is 100 records for Xmax. Its X from right, last image point
  14.     Y AS INTEGER '    Y it is "help" value, need for draw content but not need for detect function
  15.     Ymin AS INTEGER ' if picture WIDTH is 100, there is 100 records for Ymin. Its Y from above, its image start Y
  16.     Ymax AS INTEGER ' if picture WIDTH is 100, there is 100 records for Ymax. Its Y from bottom, its image end Y
  17.     X AS INTEGER '    the same as Y
  18. REDIM S(0) AS Brd
  19.  
  20. my& = _NEWIMAGE(800, 600, 32)
  21. SCREEN my&
  22. PRINT "1] program load picture to memory"
  23. imag& = _LOADIMAGE("z.jpg", 32) '                       load example picture (downloaded from google)
  24. PRINT "2] function Filter& set image background (R input, G input, B input, R output, G output, B output)"
  25. image& = filter&(imag&, 150, 150, 150, 255, 255, 255) ' this is exemplary function. Downgrade background colors in set range to set RGB32 value: First 3* 255 are RGB inputs, next 3*230 are RGB outputs
  26. '                                                       This muss be set correctly for fine work! For use write program arrays outputs to text file, bacause its then always valid for this one picture
  27. '                                                       Array T contains all colors borders information, array S contains just external borders information
  28. SCREEN image&: SLEEP '                                  'It depends a lot on the correct setting of this function if the source image does not contain clear boundaries for proper border detection.
  29. SCREEN my&
  30. REDIM T(0) AS Borders
  31. _SOURCE image&
  32. PRINT "3] SUB Border create array named 'T' that contains X, Y about all colors borders and show it:"
  33. Border T(), image&, _RGB32(255, 255, 255) '            function based on ONE color in background. Write image borders to array, writed for 256 colors and or truecolor, but tested for truecolor only
  34. '                                                      parameter in function is background color in source image
  35. FOR u = LBOUND(T) TO UBOUND(T)
  36.     PSET (T(u).X, 50 + T(u).Y + 80)
  37. PRINT "4] SUB Compress reduce the input array T by writing only outer points to array S"
  38. compress T(), S(), 25 'if in game - character - step  size is bigger than 25, muss this step be enought for collis detect...
  39.  
  40.  
  41. PRINT "5] This is compressed (array S) output (PSET) on left, LINE for < > method is right" '    program show you detected and to array writed borders
  42. FOR T = LBOUND(s) TO UBOUND(s)
  43.  
  44.     IF S(T).Xmin AND S(T).Xmax THEN LINE (300 + S(T).Xmin, 370 + S(T).Y)-(300 + S(T).Xmax, 370 + S(T).Y)
  45.     IF S(T).Ymin AND S(T).Ymax THEN LINE (300 + S(T).X, 370 + S(T).Ymax)-(300 + S(T).X, 370 + S(T).Ymin)
  46.  
  47.  
  48.     IF S(T).Xmin THEN PSET (S(T).Xmin, S(T).Y + 370)
  49.     IF S(T).Xmax THEN PSET (S(T).Xmax, S(T).Y + 370)
  50.     IF S(T).Ymin THEN PSET (S(T).X, S(T).Ymin + 370)
  51.     IF S(T).Ymax THEN PSET (S(T).X, S(T).Ymax + 370)
  52.  
  53.  
  54. PRINT "Array size in records (S):"; UBOUND(s); " and size array T contains all color borders information:"; UBOUND(T)
  55.  
  56.  
  57.  
  58.  
  59. SUB Border (array() AS Borders, Source AS LONG, Background_Color AS _UNSIGNED LONG) 'own border detection sub
  60.     _DEST Source&
  61.     minX = _WIDTH(Source&)
  62.     minY = _HEIGHT(Source&)
  63.     DIM M AS _MEM '32 bytova promenna                                                                         '  MEM values are 32 BYTES long,
  64.     M = _MEMIMAGE(Source&) '                                                                                     M is pointer to memory with image content
  65.     SELECT CASE _PIXELSIZE(Source&) '                                                                           select if image is 256 colored, 8 bit (1 byte for pixel) or 32 bit colored (4 byte for pixel)
  66.         CASE 0: END 'not writed for text mode yet                                                                0 is for text mode, then this screen contains cells 8 * 16 pixels, one cell has value one BYTE
  67.         CASE 1: '    for 256 colors image
  68.             REDIM Value AS _UNSIGNED _BYTE, OldValue AS _UNSIGNED _BYTE '                                       because i need read value directly from memory, muss set correct type first - basicaly are
  69.             FOR y = 1 TO _HEIGHT(Source&) - 1 '                                                                 all varibles set to SINGLE (4 byte long)
  70.                 FOR x = 1 TO _WIDTH(Source&) - 1
  71.                     OldValue = Value
  72.                     _MEMGET M, M.OFFSET + IN&(x, y), Value '                                                    is the same as POINT but very  more faster!  _MEMGET is as POINT for read color value,
  73.                     '                                                                                           _MEMPUT is the same as POINT for writing color value. In use with mem muss be correct type and offset set.
  74.                     IF Value = Background_Color AND OldValue <> Background_Color OR Value <> Background_Color AND OldValue = Background_Color THEN
  75.                         GOSUB rozsah '                                                                          subprogram continuously compares values for MinX, MaxX, MinY and MaxY
  76.                         i = i + 1
  77.                         REDIM _PRESERVE array(i) AS Borders '                                                   this command increases the field value without losing the field contents // to i size
  78.                         array(i).X = x
  79.                         array(i).Y = y
  80.                         array(i).Clr = Value
  81.                     END IF
  82.                     IF y > 0 THEN _MEMGET M, M.OFFSET + IN&(x, y - 1), Value '                                  condition for preveting MEMORY REGION OUT OF RANGE and read current color value on X, Y
  83.                     IF Value = Background_Color AND OldValue <> Background_Color OR Value <> Background_Color AND OldValue = Background_Color THEN
  84.                         i = i + 1 'This condition: If current color is the same as background and previous color is different than background or above, write this coordinates to array. Easy trick.
  85.                         REDIM _PRESERVE array(i) AS Borders '                                                   this command increases the field value without losing the field contents // to i size
  86.                         array(i).X = x
  87.                         array(i).Y = y '                                                            program line 117 control colors in row, program line 126 control colors in column
  88.                         array(i).Clr = Value
  89.                     END IF
  90.             NEXT x, y
  91.  
  92.         CASE 4: 'for 32 bit screen                                                                ' this block is the same for truecolor (4 byte blocks)
  93.             REDIM Value4 AS LONG, OldValue4 AS LONG '                                               program lines 142 and 153 control and writing borders to array
  94.             FOR y = 0 TO _HEIGHT(Source&) - 4
  95.                 FOR x = 0 TO _WIDTH(Source&) - 4
  96.                     OldValue4& = Value4&
  97.                     _MEMGET M, M.OFFSET + IN&(x, y), Value4&
  98.                     IF Value4& = Background_Color AND OldValue4& <> Background_Color OR Value4& <> Background_Color AND OldValue4& = Background_Color THEN
  99.                         GOSUB rozsah
  100.                         i = i + 1
  101.                         REDIM _PRESERVE array(i) AS Borders
  102.                         array(i).X = x
  103.                         array(i).Y = y
  104.                         array(i).Clr = Value4&
  105.  
  106.                     END IF
  107.  
  108.                     IF y > 0 THEN _MEMGET M, M.OFFSET + IN&(x, y - 1), Value4&
  109.  
  110.                     IF Value4& = Background_Color AND OldValue4& <> Background_Color OR Value4& <> Background_Color AND OldValue4& = Background_Color THEN
  111.                         i = i + 1
  112.                         REDIM _PRESERVE array(i) AS Borders
  113.                         array(i).X = x
  114.                         array(i).Y = y
  115.                         array(i).Clr = Value4&
  116.  
  117.                     END IF
  118.                     nic:
  119.             NEXT x, y
  120.     END SELECT
  121.     _DEST 0
  122.     array(0).minX = minX '                                                                           to zero position in array are writed image width and height for
  123.     array(0).maxX = maxX '                                                                           possibillity quadric collision detection
  124.     array(0).MinY = minY
  125.     array(0).MaxY = maxY
  126.  
  127.     EXIT SUB
  128.     rozsah:
  129.     IF minX > x AND x > 0 THEN minX = x
  130.     IF minY > y AND y > 0 THEN minY = y
  131.     IF maxX < x THEN maxX = x
  132.     IF maxY < y THEN maxY = y
  133.     RETURN
  134.  
  135.     IN& = _PIXELSIZE(_SOURCE) * ((_WIDTH * y) + x) '                                                  function return offset for MEM functions. Copyed from Steve McNeill
  136.  
  137. FUNCTION filter& (image AS LONG, Ri, Gi, Bi, Ro, Go, Bo) '                                            Function has the task of making the background of the specified color and reducing the
  138.     DIM f AS _MEM '                                                                                   background color unevenness to make the best possible image border detection
  139.     f = _MEMIMAGE(image&)
  140.     '   filter& = _MEMNEW(_WIDTH(image&) * _HEIGHT(image&) * _PIXELSIZE(image&)) '                    Here is one bug for developers. Uncomment and give C++ compilation error. I know why, so just for info. :-D With love :-D
  141.     filter& = _NEWIMAGE(_WIDTH(image&), _HEIGHT(image&), 32)
  142.     DIM GG AS _MEM
  143.     GG = _MEMIMAGE(filter&)
  144.     _SOURCE image&
  145.     _DEST image& '                                                                                    next ask for developers. Comment DEST on this line and start it. You give HALF picture. Why?
  146.     SELECT CASE _PIXELSIZE(image&)
  147.         CASE 4
  148.             DIM clr AS LONG
  149.             choice& = _RGBA32(Ro, Go, Bo, 255)
  150.             FOR y = 0 TO _HEIGHT(image&) - 4
  151.                 FOR x = 0 TO _WIDTH(image&) - 4
  152.                     _MEMGET f, f.OFFSET + IN&(x, y), clr&
  153.  
  154.                     R = _RED32(clr&)
  155.                     G = _GREEN32(clr&)
  156.                     B = _BLUE32(clr&)
  157.                     A = _ALPHA32(clr&)
  158.                     IF R > Ri AND G > Gi AND B > Bi THEN _MEMPUT GG, GG.OFFSET + IN&(x, y), choice& ELSE _MEMPUT GG, GG.OFFSET + IN&(x, y), clr&
  159.     NEXT x, y: END SELECT
  160.     _MEMFREE f
  161.     _MEMFREE GG
  162.     _FREEIMAGE image&
  163.  
  164. SUB compress (array() AS Borders, outArray() AS Brd, stp) 'z pole vybere jen nejvetsi a nejmensi X pro JEDNO Y, bude to mit vystup X1, X2, Y, pres line to udela obrys
  165.  
  166.     FOR C = LBOUND(array) TO UBOUND(array)
  167.         FOR D = LBOUND(array) TO UBOUND(array)
  168.             IF array(D).Y = ly THEN
  169.                 IF array(D).X > 0 AND array(D).Y > 0 THEN
  170.                     IF max < array(D).X THEN max = array(D).X
  171.                     IF min > array(D).X THEN min = array(D).X
  172.                 END IF
  173.             END IF
  174.         NEXT D
  175.         IF min < 65535 AND min > 0 THEN
  176.             REDIM _PRESERVE outArray(i) AS Brd
  177.  
  178.             outArray(i).Y = ly
  179.             outArray(i).Xmin = min
  180.             outArray(i).Xmax = max
  181.             i = i + 1
  182.         END IF
  183.         min = 65535: max = 0: ly = ly + 1
  184.     NEXT C
  185.  
  186.     min = 65535: max = 0: ly = 0
  187.     FOR C = LBOUND(array) TO UBOUND(array)
  188.         FOR D = LBOUND(array) TO UBOUND(array)
  189.             IF array(D).X = ly THEN
  190.                 IF array(D).X > 0 AND array(D).Y > 0 THEN
  191.                     IF max < array(D).Y THEN max = array(D).Y
  192.                     IF min > array(D).Y THEN min = array(D).Y
  193.                 END IF
  194.             END IF
  195.         NEXT D
  196.         IF min < 65535 AND min > 0 THEN
  197.             REDIM _PRESERVE outArray(i) AS Brd
  198.             '    LINE (ly, min)-(ly, max)
  199.             outArray(i).X = ly
  200.             outArray(i).Ymin = min
  201.             outArray(i).Ymax = max
  202.             i = i + 1
  203.         END IF
  204.         min = 65535: max = 0: ly = ly + 1
  205.     NEXT C
  206.     IF stp > 1 THEN 'performs a reduction of records according to a specified number of STP steps. This is useful for speeding up the program if the basic
  207.         '            move of the pictures is not 1 but more, so  then it is necessary for all the pictures to move in the same step and it is not necessary to write all
  208.         '            the collision coordinates.
  209.  
  210.         'create copy array outArray AS BRD
  211.         REDIM Arrcopy(0) AS Brd
  212.         ii = 0
  213.         FOR copy = LBOUND(outarray) TO UBOUND(outarray) STEP stp
  214.             ii = ii + 1
  215.             REDIM _PRESERVE Arrcopy(ii) AS Brd
  216.             Arrcopy(ii) = outArray(copy)
  217.         NEXT copy
  218.         REDIM outArray(0) AS Brd
  219.  
  220.         FOR CopyBack = LBOUND(arrcopy) TO UBOUND(arrcopy)
  221.             REDIM _PRESERVE outArray(CopyBack) AS Brd
  222.             outArray(CopyBack) = Arrcopy(CopyBack)
  223.         NEXT
  224.         ERASE Arrcopy
  225.     END IF
  226.  
  227.  

this code NOT DETECT collision, but do borders for collision detection. (i have it not writed yet). I you have this points in memory, then is possible using (after upgrading sub outputs to array) this MLINE sub:

Code: QB64: [Select]
  1.  
  2.  
  3. MLine 0, 320, 200, 0
  4. LINE (0, 320)-(200, 0), 14
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12. SUB MLine (x1 AS INTEGER, y1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER)
  13.     '------------------------------------------------------
  14.     'in line solution for X:
  15.     IF x1 < x2 AND y1 = y2 THEN
  16.         FOR K = x1 TO x2
  17.             PSET (x1 + (K - x1), y1)
  18.         NEXT K
  19.         EXIT SUB
  20.     END IF
  21.  
  22.     IF x1 > x2 AND y1 = y2 THEN
  23.         FOR K = x1 TO x2 STEP -1
  24.             PSET (x1 + (K - x1), y1)
  25.         NEXT K
  26.         EXIT SUB
  27.     END IF
  28.     '-------------------------------------------------------
  29.     'in line solution for Y:
  30.     IF x1 = x2 AND y1 < y2 THEN
  31.         FOR K = y1 TO y2
  32.             PSET (x1, y1 + (K - y1))
  33.         NEXT K
  34.         EXIT SUB
  35.     END IF
  36.  
  37.     IF x1 = x2 AND y1 > y2 THEN
  38.         FOR K = y1 TO y2 STEP -1
  39.             PSET (x1, y1 + (K - y1))
  40.         NEXT K
  41.         EXIT SUB
  42.     END IF
  43.  
  44.  
  45.     '--------------------------------------------------- radkova reseni otestovana a v poradku
  46.     D = SQR((x1 - x2) ^ 2 + (y1 - y2) ^ 2)
  47.  
  48.     ky = ABS(y1 - y2) / D
  49.     kx = ABS(x1 - x2) / D
  50.  
  51.     IF x1 > x2 THEN kx = kx * -1
  52.     IF y1 > y2 THEN ky = ky * -1
  53.  
  54.     'solution for X1 <> X2, Y1 <> Y2
  55.     outX = x1: outY = y1
  56.  
  57.     FOR K = 0 TO D
  58.         PSET (outX, outY)
  59.         outX = outX + kx
  60.         outY = outY + ky
  61.     NEXT K
  62.  

or much easyer. If is picture simetric, use this collision detection function:

Code: QB64: [Select]
  1. 'elipse collision
  2. LET CenterX = 160: LET CenterY = 100: LET A = 40: LET B = 20
  3.  
  4. FOR F = 0 TO _PI(2) STEP .01
  5.     PSET (CenterX + SIN(F) * A, CenterY + COS(F) * B)
  6.  
  7.     IF Ellipse(_MOUSEX, _MOUSEY, CenterX, CenterY, A, B) THEN LOCATE 1, 1: PRINT "collision" ELSE LOCATE 1, 1: PRINT SPACE$(9)
  8.  
  9.  
  10. FUNCTION Ellipse (X&, Y&, CX&, CY&, A&, B&)
  11.     XY## = (((X& - CX&) ^ 2) / A& ^ 2) + (((Y& - CY&) ^ 2) / B& ^ 2)
  12.     IF XY## <= 1.1 THEN Ellipse = 1 ELSE Ellipse = 0
  13.  
  14.  

Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 06, 2018, 11:46:34 am
I was wondering how you might handle rotation (with collision) but I see you are doing a sprite for every occasion! Wow, that's allot of sprites.

Yes, that's called "cheater" 3D. I designed the ship using a 3D designer program then output an image for each rotation of 10 degrees. This was how Donkey Kong Country was done in 1994 to get the illusion of having 3D characters while using a 2D engine. It's painstaking work to create sheets like this but simple and effective when wanting the illusion of 3D. Most overhead games of years ago (Starcraft) were done using this method as well.

Doom used a similar method to achieve 3D in a 2D environment. I've attached the Archvile sprite sheet to show how much work was put into just one character. The two John's used clay models and a 3D scanner to create their sprites.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 06, 2018, 11:51:26 am
It'd take the Sprite Library from just being a library to draw/display sprites, to becoming a much more active Game Engine.   ;)

All good points! This is why I wanted to bounce this off the forum before I got too heavy into this. So many good ideas. I can already envision the code in my head for many of the ideas you presented here.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 06, 2018, 12:21:00 pm
Next option is ELLIPSE collision detection.

I like your ellipse detection. My library currently uses circle detection. It never occurred to me to use a ratio between two radii with Pythagoras to achieve elliptical detection. Nice!
Title: Re: Sprite Library Revisited
Post by: Petr on September 06, 2018, 12:24:04 pm
Hi again, for  your ask - how do image detection better - for some images is need polygon image scan. It is for cases, if is square image not possible to use as on this:
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 06, 2018, 12:28:58 pm
I played around with the possibility of using a polygon technique years ago. However, the processing needed to do this slowed everything to a crawl when put into a loop. If memory serves I wasn't able to get over 10-15 FPS because of all the time needed to check each part of the polygon.

I tried making the routine a bit smarter by detecting where the actual collision was taking place in order not to have to check the entire polygon structure of both sprites. But I could never get it to work quite right.

That elliptical collision has me thinking. A few well placed ellipses of different sizes throughout a sprite could be a close representation of a polygon detection method. I could easily write a program that allows the programmer to place the different sized ellipses onto a sprite, covering most if not all of the image. Writing code to automagically do that would take some work though.
Title: Re: Sprite Library Revisited
Post by: Petr on September 06, 2018, 12:46:36 pm
I would deal with this particular case by manually defining the points for each frame. This is then loaded as a _NEWIMAGE set for each. OR, if it's about saving memory, well, it can be done by dragging the picture the way it is and no longer splitting into single frames, but using pre-defined polygons. But I think, that more practical is if  picture will be cut into single frames because then the disk image can be released from memory and the all chopped parts  are together  maximal  the same size as the source image. And then the putimage will be used and speed will not be a problem.

i try do something  in this way.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 07, 2018, 11:54:49 am
I optimized the code in the original post above. Image detection is much simpler and the code now generates a sprite mask for use in pixel-perfect detection.

It also generates a hardware image for viewing now.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 11, 2018, 02:18:35 am
Petr - your N-Angles code is intriguing. Sorry I didn't comment on it earlier. I have it saved and will be looking it over to see how I may utilize it.

I'm happy to report that I'm chugging along on the new version of the sprite library (I updated the code in the original post above if anyone is interested in seeing it). I want to make sure it's as compatible as possible with Linux and MacOS as well. I can handle the Linux end of things, but when it comes time I'll need you MacOS users to help me out. My last Powerbook died on me a few years back.

I'm taking a whole new approach to the library that will make it easier to incorporate the ideas that Steve and others have put forth. What I have now is already magnitudes faster than the old library. QB64 coding is all coming back to me like boomerang! The new QB64 version, with its new features, and new IDE make this so much more enjoyable. Really great job to all the contributors to it over the years.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 12, 2018, 01:12:50 am
Super exciting and productive day today! My goal was to incorporate sprite rotation by the end of the day. I finished sprite rotation and flipping!

The old sprite library was very slow to perform sprite rotation due to the fact that sprites were not preloaded. This meant that every time a sprite needed to be rotated, the image was grabbed from the sheet, calculations were done to get the triangular coordinates for _MAPTRIANGLE and then the mapped image would be placed to the screen. This happened each and every time you rotated a sprite. Keeping a sprite rotating 360 degrees took a LOT of horsepower.

What I did today was create code that precalculates all of the variables needed for sprite rotation when the sheet is initially loaded and places the values in a rotational lookup table. Now keeping a sprite rotating 360 degrees is just a simple matter of plugging the known values into _MAPTRIANGLE. Boom! Instant rotation. And wow is it fast, because of the precalculated figures and the use of hardware images.

I updated the code in the original post above along with adding the sprite sheet (dkong.png)  for the test code contained in it.

Oh, one more thing ... _MAPTRIANGLE is a beast! LOL, sorry, that command was not my friend today.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 15, 2018, 03:44:54 pm
Here is a listing of the commands I have finished so far. I'm not sure how I should word the commands. Should I use all CAPS separated BY_UNDERSCORE, CamelCaseWithNoSpaces, or something else?

The convention I am using right now is:

LibraryName_Verb_Description_..._...

Any ideas on naming convention would be appreciated.

Code: QB64: [Select]
  1. SUB SL_SET_AUTOSPIN (handle AS INTEGER, s AS INTEGER)
  2. - Enables auto-rotation of a sprite and sets the spin rate (-359 to +359)
  3.  
  4. FUNCTION SL_GET_DISTANCE_POINT_TO_POINT (x1 AS INTEGER, y1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER)
  5. - Returns the distance between two points in pixels (uses Pythagoras)
  6.  
  7. FUNCTION SL_GET_DISTANCE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER)
  8. - Returns the distance from the center points of two sprites (uses Pythagoras)
  9.  
  10. FUNCTION SL_GET_DISTANCE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER)
  11. - Returns the distance from the center point of a sprite to an x,y location (uses Pythagoras)
  12.  
  13. FUNCTION SL_GET_ANGLE_POINT_TO_POINT (x1 AS INTEGER, y1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER)
  14. - Returns the angle in degrees from an x,y point location to a second x,y point location (0 - 359)
  15.  
  16. FUNCTION SL_GET_ANGLE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER)
  17. - Returns the angle in degrees from the center point of this sprite to the center point of a second sprite (0 - 359)
  18.  
  19. FUNCTION SL_GET_ANGLE_FROM_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER)
  20. - Returns the angle in degrees from the center point of a second sprite to the center point of this sprite (0 - 359)
  21.  
  22. FUNCTION SL_GET_ANGLE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER)
  23. - Returns the angle in degrees from the center point of this sprite to an x,y location (0 - 359)
  24.  
  25. FUNCTION SL_GET_ANGLE_FROM_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER)
  26. - Returns the angle in degrees from an x,y location to the center point of this sprite (0 - 359)
  27.  
  28. SUB SL_SET_SOFTWARE (handle AS INTEGER, restores AS INTEGER)
  29. - Sets a sprite to software mode if sprite is in hardware mode
  30. - Sets the sprites background saving mode on or off
  31.  
  32. SUB SL_SET_HARDWARE (handle AS INTEGER)
  33. - Sets a sprite to hardware mode if sprite is in software mode
  34. - Turns off background saving mode
  35.  
  36. SUB SL_SET_ZOOM (handle AS INTEGER, zoom AS INTEGER)
  37. - Sets the zoom level of a sprite (1 - x) (100 = normal zoom)
  38.  
  39. SUB SL_SET_ROTATION (handle AS INTEGER, degrees AS INTEGER)
  40. - Sets the rotation angle in degrees of a sprite (0 - 359)
  41.  
  42. SUB SL_FLIP_SPRITE (handle AS INTEGER, flip AS INTEGER)
  43. - Sets the flipping behavior of a sprite (None, Horizontal, Vertical, Both)
  44.  
  45. SUB SL_PUT_SPRITE (x AS SINGLE, y AS SINGLE, handle AS INTEGER)
  46. - Places a sprite on the current destination centered on location x,y
  47.  
  48. FUNCTION SL_NEW_SPRITE (sheet AS INTEGER, column AS INTEGER, row AS INTEGER, software AS INTEGER, restores AS INTEGER)
  49. - Creates a new sprite from a pre-loaded sprite sheet, sets software/hardware mode, and sets the background restoring behavior
  50.  
  51. SUB SL_FREE_SPRITE (handle AS INTEGER)
  52. - Removes a sprite and frees all image data associated with it
  53.  
  54. FUNCTION SL_NEW_SHEET (filename AS STRING, spritewidth AS INTEGER, spriteheight AS INTEGER, transparency AS INTEGER, transcolor AS _UNSIGNED LONG)
  55. - Loads a sprite sheet into memory, identifies transparency characteristics, pre-calculates rotational data for _MAPTRIANGLE, and pre-loads all sprite
  56. - images for use with SL_NEW_SPRITE
  57.  
  58. FUNCTION SL_VALID_SPRITE (handle AS INTEGER)
  59. - Identifies if a sprite handle is valid or not (0 or -1)
  60.  

I have MANY more subs/functions to finish, such as auto-motion routines and event handling routines. Any ideas for features in the library are appreciated. Like Steve suggested, I would like to make this more than just a sprite handling library and go in the direction of a game engine as well.
Title: Re: Sprite Library Revisited
Post by: Petr on September 15, 2018, 03:58:25 pm
Hi TerryRitchie,

This is a great list of features. I would be for preservation of underscores, it is then clearer.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 15, 2018, 05:36:32 pm
I agree with using underscore but I also want to get a majority opinion. Yours has been noted, thank you.

I'm going to make an effort to keep to commands to a limit of four words or less. I know I already broke this with SL_GET_DISTANCE_POINT_TO_POINT but SL_GET_DISTANCE_P2P just looks weird.
Title: Re: Sprite Library Revisited
Post by: SMcNeill on September 15, 2018, 05:50:45 pm
I'm going to sit down soon(tm) and see what it'd take to give us an _ALIAS command for QB64, which will work very similar to CONST.  For CONST, we say TRUE = -1, and the precompile routine reads every TRUE in our code and replaces it with the value -1.

I'd envision _ALIAS working the same way:

_ALIAS GDP2P = SL_Get_Distance_Point_To_Point

Then, lazy folks like me, could just type GDP2P and the code would read it as the longer command.

I'm also thinking of seeing about making a _REPLACE command, which works the same, but actually replaces one set of text with another (like ? Becomes PRINT).

I think both those features would make libraries with naming conventions like these, much, much, more appealing to me.  (And probably a few others as well.).  ;D
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 15, 2018, 06:01:30 pm
I wish there were a way to mimic the way Python includes libraries. If you just:

import pygame

then you need to use the the name of the library:

screen = pygame.display.set_mode([640, 480])

But if you:

from pygame import *

You no longer need to use the library name:

screen = display.set_mode([640, 480])

You can even go further. The pygame library includes handy constants. To load those you can:

from pygame.locals import *

and now you have all the constants at a local level without having to refer to pygame.locals first.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 15, 2018, 06:11:17 pm
I'd envision _ALIAS working the same way:

_ALIAS GDP2P = SL_Get_Distance_Point_To_Point

You could make an .alias file from these commands to. You could then just include a custom alias file that matches the library.

'$INCLUDE: sprite.bi
'$INCLUDE: sprite.alias
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 16, 2018, 12:36:31 pm
I was a programmer possessed yesterday. I already have more commands in this new sprite library than were contained in the old, and I'm not even close to being finished yet.

Here is what I have now:

SUB SL_UPDATE_AUTO_SPRITES ()
- All sprites that have auto-motion enabled will be updated and moved
- All sprites that have auto-rotation enabled will have their rotational data updated and displayed

SUB SL_MOVE_SPRITE (handle AS INTEGER)
- Allows the programmer to manually move a sprite that has motion data associated with it but auto-motion not turned on

SUB SL_ROTATE_SPRITE (handle AS INTEGER)
- Allows the programmer to manually rotate a sprite that has rotation data associated with it but auto-rotation not turned on

SUB SL_SET_DIRECTION (handle AS INTEGER, degrees AS INTEGER)
- Sets the direction in degrees that a sprite will move with auto-motion or a manual move

FUNCTION SL_GET_DIRECTION (handle AS INTEGER)
- Gets the direction in degrees that a sprite is currently set to travel in

SUB SL_SET_MOTION_SPEED (handle AS INTEGER, speed AS SINGLE)
- Sets the speed in pixels that a sprite will move with auto-motion or a manual move

FUNCTION SL_GET_MOTION_SPEED (handle AS INTEGER)
- Gets the speed in pixels that a sprite is currently set to travel

SUB SL_SET_AUTOMOTION (handle AS INTEGER, motion AS INTEGER)
- Enables or disables auto-motion for a given sprite

FUNCTION SL_GET_AUTOMOTION (handle AS INTEGER)
- Gets the current state of auto-motion for a sprite

SUB SL_SET_AUTOROTATE (handle AS INTEGER, rotate AS INTEGER)
- Enables or disables auto-rotation for a given sprite

FUNCTION SL_GET_AUTOROTATE (handle AS INTEGER)
- Gets the current state of auto-rotation for a sprite

SUB SL_SET_ROTATION_SPEED (handle AS INTEGER, degrees AS INTEGER)
- Sets the rotation speed in degrees for a given sprite

FUNCTION SL_GET_ROTATION_SPEED (handle AS INTEGER)
- Gets the rotation speed of a sprite

FUNCTION SL_GET_DISTANCE_POINT_TO_POINT (x1 AS INTEGER, y1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER)
- Returns the distance in pixels between two x,y points

FUNCTION SL_GET_DISTANCE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER)
- Returns the distance in pixels from this sprite to a second sprite

FUNCTION SL_GET_DISTANCE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER)
- Returns the distance in pixels from this sprite to an x,y point

FUNCTION SL_GET_ANGLE_POINT_TO_POINT (x1 AS INTEGER, y1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER)
- Returns the angle in degrees between two x,y points

FUNCTION SL_GET_ANGLE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER)
- Returns the angle in degrees from this sprite to a second sprite

FUNCTION SL_GET_ANGLE_FROM_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER)
- Returns the angle in degrees from a second sprite to this sprite

FUNCTION SL_GET_ANGLE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER)
- Returns the angle in degrees from this sprite to an x,y location

FUNCTION SL_GET_ANGLE_FROM_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER)
- Returns the angle in degrees from an x,y point to this sprite

SUB SL_SET_SOFTWARE (handle AS INTEGER, restores AS INTEGER)
- Changes a sprite's mode from hardware to software and sets background saving behavior

SUB SL_SET_HARDWARE (handle AS INTEGER)
- Changes a sprite's mode from software to hardware and disables background saving behavior

SUB SL_SET_ZOOM (handle AS INTEGER, zoom AS INTEGER)
- Sets the zoom level for a sprite

SUB SL_SET_ROTATION (handle AS INTEGER, degrees AS INTEGER)
- Sets the rotation angle in degrees of a sprite

SUB SL_FLIP_SPRITE (handle AS INTEGER, flip AS INTEGER)
- Sets the flipping behavior of a sprite (none, horizontal, vertical, both)

SUB SL_PUT_SPRITE (x AS SINGLE, y AS SINGLE, handle AS INTEGER)
- Places a prite on the current destination ay position x,y

FUNCTION SL_NEW_SPRITE (sheet AS INTEGER, column AS INTEGER, row AS INTEGER, software AS INTEGER, restores AS INTEGER)
- Creates a new sprite from a given sprite sheet

SUB SL_FREE_SPRITE (handle AS INTEGER)
- Removes a sprite from the sprite list and frees all associated image data

FUNCTION SL_NEW_SHEET (filename AS STRING, spritewidth AS INTEGER, spriteheight AS INTEGER, transparency AS INTEGER, transcolor AS _UNSIGNED LONG)
- Loads a sprite sheet in, pre-loads all images, precalculates all _MAPTRIANGLE rotational coordinates, identifies transparency type of sheet

FUNCTION SL_VALID_SPRITE (handle AS INTEGER)
- Returns the validity of a sprite (TRUE or FALSE)

Here is the code if anyone is interested in seeing it. I removed header comments for now to lower the line count.

Code: QB64: [Select]
  1. ' if SL_EVENT_TRIGGER then 'check for event that was sent
  2.  
  3. OPTION _EXPLICIT ' need to remove before publishing library!!
  4.  
  5. '*
  6. '* constant declarations
  7. '*
  8.  
  9. '         CONSTANT NAME                                DESCRIPTION                          FUNCTIONS / SUBROUTINES THAT MAY USE THIS CONSTANT
  10. ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  11. CONST SL_RESET = -32767 '               reset a function or subroutine                      SL_ROTATE_SPRITE, SL_FLIP_SPRITE, SL_ZOOM_SPRITE, SL_SET_AUTOROTATE, SL_SET_AUTOMOTION
  12. CONST SL_NOFLIP = 0 '                   sprite will use no flipping                         SL_FLIP_SPRITE
  13. CONST SL_HORIZONTAL = 1 '               sprite will be flipped horizontally                 SL_FLIP_SPRITE
  14. CONST SL_VERTICAL = 2 '                 sprite will be flipped vertically                   SL_FLIP_SPRITE
  15. CONST SL_FLIPBOTH = 3 '                 sprite will be flipped horizontally & vertically    SL_FLIP_SPRITE
  16. CONST SL_USESHEET = -1 '                use sheet's transparency info (.PNG)                SL_NEW_SHEET
  17. CONST SL_SET = 0 '                      manually set transparency                           SL_NEW_SHEET
  18. CONST SL_NONE = 1 '                     don't use transparency with sheet                   SL_NEW_SHEET
  19. CONST SL_NOSAVE = 0 '                   sprite will not save background                     SL_NEW_SPRITE, SL_SOFTWARE_SPRITE
  20. CONST SL_SAVE = -1 '                    sprite will save background                         SL_NEW_SPRITE, SL_SOFTWARE_SPRITE
  21. CONST SL_HARDWARE = 0 '                 sprite in hardware mode                             SL_NEW_SPRITE
  22. CONST SL_SOFTWARE = -1 '                sprite in software mode                             SL_NEW_SPRITE
  23. CONST SL_START = -1 '                   enable auto motion / rotation                       SL_SET_AUTOMOTION' SL_SET_AUTOROTATE
  24. CONST SL_STOP = 0 '                     disable auto motion / rotation                      SL_SET_AUTOMOTION, SL_SET_AUTOROTATE
  25.  
  26. '*
  27. '* type declarations
  28. '*
  29.  
  30. TYPE SL_SHEET ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ SPRITE SHEET DATABASE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  31.     image AS LONG '                     software sprite image
  32.     mask AS LONG '                      software mask image
  33.     spritewidth AS INTEGER '            width of sprite
  34.     spriteheight AS INTEGER '           height of sprite
  35.     collx1 AS INTEGER '                 collision box top left x
  36.     colly1 AS INTEGER '                 collision box top left y
  37.     collx2 AS INTEGER '                 collision box bottom right x
  38.     colly2 AS INTEGER '                 collision box bottom right y
  39.     transparency AS INTEGER '           -1 (TRUE) if sheet uses transparency
  40. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  41.  
  42. TYPE SL_SPRITE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ SPRITE DATABASE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  43.     inuse AS INTEGER '                  this array index in use
  44.     sheet AS INTEGER '                  sheet sprite belongs to
  45.     column AS INTEGER '                 the column on the sheet the sprite resides
  46.     row AS INTEGER '                    the row on the sheet the sprite resides
  47.     sprite AS LONG '                    hardware image
  48.     image AS LONG '                     software image
  49.     mask AS LONG '                      software mask image
  50.     spritewidth AS INTEGER '            width of sprite
  51.     spriteheight AS INTEGER '           height of sprite
  52.     background AS LONG '                background hardware image behind sprite
  53.     xreal AS SINGLE '                   x location of sprite (center point)
  54.     yreal AS SINGLE '                   y location of sprite (center point)
  55.     xint AS INTEGER '                   x location of sprite on screen INT(xreal) (center point)
  56.     yint AS INTEGER '                   y location of sprite on screen INT(yreal) (center point)
  57.     xactual AS INTEGER '                x location of sprite on screen (upper left x)
  58.     yactual AS INTEGER '                y location of sprite on screen (upper left y)
  59.     xback AS INTEGER '                  background image x location
  60.     yback AS INTEGER '                  background image y location
  61.     xdir AS SINGLE '                    direction of sprite in x axis
  62.     ydir AS SINGLE '                    direction of sprite in y axis
  63.     restore AS INTEGER '                -1 (true) if sprite restores background
  64.     collx1 AS INTEGER '                 collision box top left x
  65.     colly1 AS INTEGER '                 collision box top left y
  66.     collx2 AS INTEGER '                 collision box bottom right x
  67.     colly2 AS INTEGER '                 collision box bottom right y
  68.     flip AS INTEGER '                   flip horizontally, vertically, or both
  69.     rotation AS INTEGER '                rotation angle of sprite (0 - 359)
  70.     transparency AS INTEGER '           -1 (TRUE) if sprite uses transparency
  71.     zoom AS INTEGER '                   zoom level of sprite (1% - x%)
  72.     software AS INTEGER '               -1 (TRUE) if sprite is to be treated as software image
  73.     spin AS INTEGER '                   if other than zero the sprite will automatically spin
  74.     speed AS INTEGER '                  speed of sprite during motion
  75.     direction AS INTEGER '              the direction of sprite during motion (0 - 359)
  76.     automotion AS INTEGER '             -1 (TRUE) if automotion turned on
  77.     autorotate AS INTEGER '             -1 (TRUE) if auto rotation turned on
  78.  
  79. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  80.  
  81. TYPE SL_ROTATE 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ PRECALCULATED ROTATION TABLE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  82.     rwidth AS INTEGER '                 width of rotated sprite
  83.     rheight AS INTEGER '                height of rotated sprite
  84.     px0 AS INTEGER '                    rectangular rotation coordinates
  85.     px1 AS INTEGER
  86.     px2 AS INTEGER
  87.     px3 AS INTEGER
  88.     py0 AS INTEGER
  89.     py1 AS INTEGER
  90.     py2 AS INTEGER
  91.     py3 AS INTEGER
  92. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  93.  
  94. '*
  95. '* dynamic array declarations
  96. '*
  97.  
  98. REDIM SL_sheet(1, 1, 1) AS SL_SHEET '   master sprite sheet array
  99. REDIM SL_sprite(1) AS SL_SPRITE '       master working sprite array
  100. REDIM SL_rotate(1, 359) AS SL_ROTATE '  precalculated rotation values
  101.  
  102. '*
  103. '* main code (for testing)
  104. '*
  105.  
  106. DIM kongsheet AS INTEGER
  107. DIM mysprite AS INTEGER
  108. DIM mysprite2 AS INTEGER
  109. DIM angle AS INTEGER
  110.  
  111. kongsheet = SL_NEW_SHEET("dkong.png", 64, 64, SL_SET, _RGB32(255, 0, 255))
  112. mysprite = SL_NEW_SPRITE(kongsheet, 1, 1, SL_HARDWARE, SL_NOSAVE)
  113. mysprite2 = SL_NEW_SPRITE(kongsheet, 1, 1, SL_SOFTWARE, SL_NOSAVE)
  114.  
  115. 'SL_SET_ROTATION mysprite, 45
  116. 'SL_SET_ROTATION_SPEED mysprite, 1
  117. 'SL_SET_AUTOROTATE mysprite, SL_START
  118. 'SL_FLIP_SPRITE mysprite, SL_HORIZONTAL
  119. 'SL_SET_ZOOM mysprite, 125
  120.  
  121.  
  122.  
  123.  
  124. SCREEN _NEWIMAGE(640, 480, 32)
  125. CIRCLE (128, 128), 64, _RGB32(255, 255, 255)
  126. x = 128
  127. y = 128
  128.  
  129. SL_PUT_SPRITE 128, 128, mysprite2
  130.  
  131.     _LIMIT 30
  132.     'angle = angle + 1: IF angle = 360 THEN angle = 0
  133.     'SL_SET_ROTATION mysprite, angle
  134.     SL_PUT_SPRITE x, y, mysprite
  135.     x = x + 1
  136.     'IF INT(x) = 300 THEN
  137.     '    SL_SET_SOFTWARE mysprite, SL_NOSAVE
  138.     'END IF
  139.     IF INT(x) = 401 THEN x = 400
  140.     _DISPLAY
  141.  
  142. SL_FREE_SPRITE mysprite
  143. SL_FREE_SPRITE mysprite2
  144.  
  145.  
  146.  
  147.  
  148.  
  149. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  150. SUB SL_UPDATE_AUTO_SPRITES () '                                                                                                                                                  SL_UPDATE_AUTO_SPRITES
  151.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  152.  
  153.     ' declare global variables
  154.  
  155.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  156.  
  157.     ' declare local variables
  158.  
  159.     DIM handle AS INTEGER '             handle of sprite
  160.  
  161.     ' local variable setup
  162.  
  163.     handle = 0 '                                                                                                initialize handle counter
  164.  
  165.     DO
  166.         handle = handle + 1
  167.         IF SL_sprite(handle).inuse THEN '                                                                       is this a valid sprite?
  168.             IF SL_sprite(handle).automotion THEN '                                                              yes, is auto motion enabled?
  169.                 SL_sprite(handle).xreal = SL_sprite(handle).xreal + SL_sprite(handle).xdir '                    yes, update x location
  170.                 SL_sprite(handle).yreal = SL_sprite(handle).yreal + SL_sprite(handle).ydir '                    update y location
  171.             END IF
  172.             IF SL_sprite(handle).autorotate THEN '                                                              is auto rotation enabled?
  173.                 SL_SET_ROTATION handle, SL_sprite(handle).rotation + SL_sprite(handle).spin '                   yes, rotate sprite to next degree angle
  174.             END IF
  175.             SL_PUT_SPRITE SL_sprite(handle).xreal, SL_sprite(handle).yreal, handle '                            update sprite location
  176.         END IF
  177.     LOOP UNTIL handle = UBOUND(SL_sprite) '                                                                     leave when all indexes checked
  178.  
  179.  
  180. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  181. SUB SL_MOVE_SPRITE (handle AS INTEGER) '                                                                                                                                                 SL_MOVE_SPRITE
  182.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  183.  
  184.     ' declare global variables
  185.  
  186.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  187.  
  188.     ' perform error checks
  189.  
  190.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  191.         SL_ERROR "SL_MOVE_SPRITE", 1, "" '                                                              no, report error to programmer
  192.     END IF
  193.     IF SL_sprite(handle).automotion THEN '                                                              attempt to move sprite under automatic control?
  194.         SL_ERROR "SL_MOVE_SPRITE", 170, "" '                                                            yes, report error to programmer
  195.     END IF
  196.  
  197.     SL_sprite(handle).xreal = SL_sprite(handle).xreal + SL_sprite(handle).xdir '                        update x location
  198.     SL_sprite(handle).yreal = SL_sprite(handle).yreal + SL_sprite(handle).ydir '                        update y location
  199.     SL_PUT_SPRITE SL_sprite(handle).xreal, SL_sprite(handle).yreal, handle '                            update sprite location
  200.  
  201.  
  202. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  203. SUB SL_ROTATE_SPRITE (handle AS INTEGER) '                                                                                                                                             SL_ROTATE_SPRITE
  204.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  205.  
  206.     ' declare global variables
  207.  
  208.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  209.  
  210.     ' perform error checks
  211.  
  212.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  213.         SL_ERROR "SL_ROTATE_SPRITE", 1, "" '                                                            no, report error to programmer
  214.     END IF
  215.     IF SL_sprite(handle).autorotate THEN '                                                              attempt to rotate sprite under automatic control?
  216.         SL_ERROR "SL_ROTATE_SPRITE", 180, "" '                                                          yes, report error to programmer
  217.     END IF
  218.  
  219.     SL_SET_ROTATION handle, SL_sprite(handle).rotation + SL_sprite(handle).spin '                       rotate sprite to next degree angle
  220.  
  221.  
  222. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  223. SUB SL_SET_DIRECTION (handle AS INTEGER, degrees AS INTEGER) '                                                                                                                         SL_SET_DIRECTION
  224.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  225.  
  226.     ' declare global variables
  227.  
  228.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  229.  
  230.     ' delcare local variables
  231.  
  232.     DIM degree AS INTEGER '             degree angle passed in
  233.  
  234.     ' perform error checks
  235.  
  236.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  237.         SL_ERROR "SL_SET_DIRECTION", 1, "" '                                                            no, report error to programmer
  238.     END IF
  239.  
  240.     degree = degrees '                                                                                  get degree angle passed in
  241.  
  242.     ' correct degree angle if needed (needs to be 0 - 359)
  243.  
  244.     IF degree = 360 THEN '                                                                              is it 360?
  245.         degree = 0 '                                                                                    yes, that's the same as 0
  246.     ELSEIF degree < 0 THEN '                                                                            is it less than 360?
  247.         DO '                                                                                            yes
  248.             degree = degree + 360 '                                                                     increase by 360
  249.         LOOP UNTIL degree > 0 '                                                                         until it's in a valid range
  250.     ELSEIF degree > 360 THEN '                                                                          is it greater than 360?
  251.         DO '                                                                                            yes
  252.             degree = degree - 360 '                                                                     decrease by 360
  253.         LOOP UNTIL degree < 360 '                                                                       until it's in a valid range
  254.     END IF
  255.  
  256.     SL_sprite(handle).direction = degree '                                                              set motion degree angle
  257.     SL_sprite(handle).xdir = SIN(degree * 3.1415926 / 180) * SL_sprite(handle).speed '                  calculate x vector
  258.     SL_sprite(handle).ydir = -COS(degree * 3.1415926 / 180) * SL_sprite(handle).speed '                 calculate y vector
  259.  
  260.  
  261. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  262. FUNCTION SL_GET_DIRECTION (handle AS INTEGER) '                                                                                                                                        SL_GET_DIRECTION
  263.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  264.  
  265.     ' declare global variables
  266.  
  267.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  268.  
  269.     ' perform error checks
  270.  
  271.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  272.         SL_ERROR "SL_GET_DIRECTION", 1, "" '                                                            no, report error to programmer
  273.     END IF
  274.  
  275.     SL_GET_DIRECTION = SL_sprite(handle).direction '                                                    return direction sprite currently set to
  276.  
  277.  
  278. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  279. SUB SL_SET_MOTION_SPEED (handle AS INTEGER, speed AS SINGLE) '                                                                                                                      SL_SET_MOTION_SPEED
  280.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  281.  
  282.     ' declare global variables
  283.  
  284.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  285.  
  286.     ' perform error checks
  287.  
  288.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  289.         SL_ERROR "SL_SET_MOTION_SPEED", 1, "" '                                                         no, report error to programmer
  290.     END IF
  291.  
  292.     SL_sprite(handle).speed = speed '                                                                   set sprite motion speed
  293.  
  294.  
  295. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  296. FUNCTION SL_GET_MOTION_SPEED (handle AS INTEGER) '                                                                                                                                  SL_GET_MOTION_SPEED
  297.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  298.  
  299.     ' declare global variables
  300.  
  301.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  302.  
  303.     ' perform error checks
  304.  
  305.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  306.         SL_ERROR "SL_GET_MOTION_SPEED", 1, "" '                                                         no, report error to programmer
  307.     END IF
  308.  
  309.     SL_GET_MOTION_SPEED = SL_sprite(handle).speed '                                                     return current sprite motion speed
  310.  
  311.  
  312. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  313. SUB SL_SET_AUTOMOTION (handle AS INTEGER, motion AS INTEGER) '                                                                                                                        SL_SET_AUTOMOTION
  314.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  315.  
  316.     ' declare global variables
  317.  
  318.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  319.  
  320.     IF motion = -32767 THEN '                                                               (SL_RESET)  reset auto motion?
  321.         SL_sprite(handle).automotion = 0 '                                                     (FALSE)  yes, turn auto motion off
  322.         EXIT SUB '                                                                                      leave subroutine
  323.     END IF
  324.  
  325.     ' perform error checks
  326.  
  327.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  328.         SL_ERROR "SL_SET_AUTOMOTION", 1, "" '                                                           no, report error to programmer
  329.     END IF
  330.     IF motion < -1 OR motion > 0 THEN
  331.         SL_ERROR "SL_SET_AUTOMOTION", 150, ""
  332.     END IF
  333.  
  334.     SL_sprite(handle).automotion = motion '                                             (TRUE & FALSE)  set auto motion status
  335.  
  336.  
  337. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  338. FUNCTION SL_GET_AUTOMOTION (handle AS INTEGER) '                                                                                                                                      SL_GET_AUTOMOTION
  339.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  340.  
  341.     ' declare global variables
  342.  
  343.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  344.  
  345.     ' perform error checks
  346.  
  347.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  348.         SL_ERROR "SL_GET_AUTOMOTION", 1, "" '                                                           no, report error to programmer
  349.     END IF
  350.  
  351.     SL_GET_AUTOMOTION = SL_sprite(handle).automotion '                                  (TRUE & FALSE)  return auto motion status
  352.  
  353.  
  354. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  355. SUB SL_SET_AUTOROTATE (handle AS INTEGER, rotate AS INTEGER) '                                                                                                                        SL_SET_AUTOROTATE
  356.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  357.  
  358.     ' declare global variables
  359.  
  360.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  361.  
  362.     IF rotate = -32767 THEN '                                                               (SL_RESET)  reset auto rotate?
  363.         SL_sprite(handle).autorotate = 0 '                                                     (FALSE)  yes, turn auto rotation off
  364.         EXIT SUB '                                                                                      leave subroutine
  365.     END IF
  366.  
  367.     ' perform error checks
  368.  
  369.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  370.         SL_ERROR "SL_SET_AUTOROTATE", 1, "" '                                                           no, report error to programmer
  371.     END IF
  372.     IF rotate < -1 OR rotate > 0 THEN
  373.         SL_ERROR "SL_SET_AUTOROTATE", 160, ""
  374.     END IF
  375.  
  376.     SL_sprite(handle).autorotate = rotate '                                             (TRUE & FALSE)  set auto rotation status
  377.  
  378.  
  379. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  380. FUNCTION SL_GET_AUTOROTATE (handle AS INTEGER) '                                                                                                                                      SL_GET_AUTOROTATE
  381.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  382.  
  383.     ' declare global variables
  384.  
  385.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  386.  
  387.     ' perform error checks
  388.  
  389.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  390.         SL_ERROR "SL_GET_AUTOROTATE", 1, "" '                                                           no, report error to programmer
  391.     END IF
  392.  
  393.     SL_GET_AUTOROTATE = SL_sprite(handle).autorotate '                                  (TRUE & FALSE)  return auto rotation status
  394.  
  395.  
  396. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  397. SUB SL_SET_ROTATION_SPEED (handle AS INTEGER, degrees AS INTEGER) '                                                                                                               SL_SET_ROTATION_SPEED
  398.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  399.  
  400.     ' declare global variables
  401.  
  402.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  403.  
  404.     ' perform error checks
  405.  
  406.     IF degrees = -32767 THEN '                                                              (SL_RESET)  reset requested?
  407.         SL_sprite(handle).spin = 0 '                                                         (SL_STOP)  turn auto spin off
  408.         EXIT SUB '                                                                                      leave subroutine
  409.     END IF
  410.  
  411.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  412.         SL_ERROR "SL_SET_ROTATION_SPEED", 1, "" '                                                       no, report error to programmer
  413.     END IF
  414.     IF ABS(degrees) > 359 THEN '                                                                        degree requested between -359 and 359?
  415.         SL_ERROR "SL_SET_ROTATION_SPEED", 140, "" '                                                     no, report error to programmer
  416.     END IF
  417.  
  418.     SL_sprite(handle).spin = degrees '                                                                  set sprite spin rate
  419.  
  420.  
  421. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  422. FUNCTION SL_GET_ROTATION_SPEED (handle AS INTEGER) '                                                                                                                              SL_GET_ROTATION_SPEED
  423.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  424.  
  425.     ' declare global variables
  426.  
  427.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  428.  
  429.     ' perform error checks
  430.  
  431.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  432.         SL_ERROR "SL_GET_ROTATION_SPEED", 1, "" '                                                       no, report error to programmer
  433.     END IF
  434.  
  435.     SL_GET_ROTATION_SPEED = SL_sprite(handle).spin '                                                    return current sprite spin rate
  436.  
  437.  
  438. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  439. 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
  440.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  441.  
  442.     'declare local variables
  443.  
  444.     DIM a AS INTEGER '                  side a of triangle
  445.     DIM b AS INTEGER '                  side b of triangle
  446.  
  447.     'solve for c (hypotenuse)
  448.  
  449.     a = x1 - x2 '                                                                                       get length of side a
  450.     b = y1 = y2 '                                                                                       get length of side b
  451.  
  452.     SL_GET_DISTANCE_POINT_TO_POINT = INT(SQR(a * a + b * b)) '                                          return length of side c
  453.  
  454.  
  455. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  456. FUNCTION SL_GET_DISTANCE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                 SL_GET_DISTANCE_TO_SPRITE
  457.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  458.  
  459.     ' declare global variables
  460.  
  461.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  462.  
  463.     'perform error checks
  464.  
  465.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  466.         SL_ERROR "SL_GET_DISTANCE_TO_SPRITE", 1, "" '                                                   no, report error to programmer
  467.     END IF
  468.  
  469.     SL_GET_DISTANCE_TO_SPRITE = SL_GET_DISTANCE_POINT_TO_POINT(SL_sprite(handle1).xint, SL_sprite(handle1).yint, _
  470.                                                                SL_sprite(handle2).xint, SL_sprite(handle2).yint) '  return distance to sprite 2
  471.  
  472.  
  473. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  474. FUNCTION SL_GET_DISTANCE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                                                            SL_GET_DISTANCE_TO_POINT
  475.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  476.  
  477.     ' declare global variables
  478.  
  479.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  480.  
  481.     'perform error checks
  482.  
  483.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  484.         SL_ERROR "SL_GET_DISTANCE_TO_POINT", 1, "" '                                                    no, report error to programmer
  485.     END IF
  486.  
  487.     SL_GET_DISTANCE_TO_POINT = SL_GET_DISTANCE_POINT_TO_POINT(SL_sprite(handle).xint, SL_sprite(handle).yint, x, y) ' return distance to point
  488.  
  489.  
  490. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  491. 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
  492.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  493.  
  494.     'declare local variables
  495.  
  496.     DIM angle AS INTEGER '              angle from first x,y location to second x,y location
  497.  
  498.     IF y1 = y2 THEN '                                                                                   both y values same?
  499.         IF x1 = x2 THEN '                                                                               yes, both x values same?
  500.             EXIT FUNCTION '                                                                             yes, there is no angle (0), leave
  501.         END IF
  502.         IF x2 > x1 THEN '                                                                               is second x to the right of first x?
  503.             SL_GET_ANGLE_POINT_TO_POINT = 90 '                                                          yes, the angle must be 90 degrees
  504.         ELSE '                                                                                          no, second x is to the left of first x
  505.             SL_GET_ANGLE_POINT_TO_POINT = 270 '                                                         the angle must be 270 degrees
  506.         END IF
  507.         EXIT FUNCTION '                                                                                 leave function, angle computed
  508.     END IF
  509.     IF x1 = x2 THEN '                                                                                   both x values same?
  510.         IF y2 > y1 THEN '                                                                               yes, is second y lower than first y?
  511.             SL_GET_ANGLE_POINT_TO_POINT = 180 '                                                         yes, the angle must be 180
  512.         END IF
  513.         EXIT FUNCTION '                                                                                 leave function, angle computed (angle is 0 if no calculation done)
  514.     END IF
  515.     angle = ATN((x2 - x1) / (y2 - y1)) * -57.2957795131 '                                               calculate initial angle
  516.     IF y2 < y1 THEN '                                                                                   is second y higher than first y?
  517.         IF x2 > x1 THEN '                                                                               yes, is second x to right of first x?
  518.             SL_GET_ANGLE_POINT_TO_POINT = angle '                                                       yes, angle needs no adjustment
  519.         ELSE '                                                                                          no, second x is to left of first x
  520.             SL_GET_ANGLE_POINT_TO_POINT = angle + 360 '                                                 adjust angle accordingly
  521.         END IF
  522.     ELSE '                                                                                              no, second y is lower than first y
  523.         SL_GET_ANGLE_POINT_TO_POINT = angle + 180 '                                                     adjust angle accordingly
  524.     END IF
  525.  
  526.  
  527. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  528. FUNCTION SL_GET_ANGLE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                       SL_GET_ANGLE_TO_SPRITE
  529.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  530.  
  531.     ' declare global variables
  532.  
  533.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  534.  
  535.     'perform error checks
  536.  
  537.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  538.         SL_ERROR "SL_GET_ANGLE_TO_SPRITE", 1, "" '                                                      no, report error to programmer
  539.     END IF
  540.  
  541.     SL_GET_ANGLE_TO_SPRITE = SL_GET_ANGLE_POINT_TO_POINT(SL_sprite(handle1).xint, SL_sprite(handle1).yint, _
  542.                                                          SL_sprite(handle2).xint, SL_sprite(handle2).yint) ' return angle to sprite 2
  543.  
  544.  
  545. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  546. FUNCTION SL_GET_ANGLE_FROM_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                   SL_GET_ANGLE_FROM_SPRITE
  547.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  548.  
  549.     ' declare global variables
  550.  
  551.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  552.  
  553.     'perform error checks
  554.  
  555.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  556.         SL_ERROR "SL_GET_ANGLE_FROM_SPRITE", 1, "" '                                                    no, report error to programmer
  557.     END IF
  558.  
  559.     SL_GET_ANGLE_FROM_SPRITE = SL_GET_ANGLE_POINT_TO_POINT(SL_sprite(handle2).xint, SL_sprite(handle2).yint, _
  560.                                                            SL_sprite(handle1).xint, SL_sprite(handle1).yint) '  return angle from sprite 2
  561.  
  562.  
  563. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  564. FUNCTION SL_GET_ANGLE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                                                                  SL_GET_ANGLE_TO_POINT
  565.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  566.  
  567.     ' declare global variables
  568.  
  569.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  570.  
  571.     'perform error checks
  572.  
  573.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  574.         SL_ERROR "SL_GET_ANGLE_TO_POINT", 1, "" '                                                       no, report error to programmer
  575.     END IF
  576.  
  577.     SL_GET_ANGLE_TO_POINT = SL_GET_ANGLE_POINT_TO_POINT(SL_sprite(handle).xint, SL_sprite(handle).yint, x, y) ' return angle to point x,y
  578.  
  579.  
  580. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  581. FUNCTION SL_GET_ANGLE_FROM_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                                                              SL_GET_ANGLE_FROM_POINT
  582.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  583.  
  584.     ' declare global variables
  585.  
  586.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  587.  
  588.     'perform error checks
  589.  
  590.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  591.         SL_ERROR "SL_GET_ANGLE_FROM_POINT", 1, "" '                                                     no, report error to programmer
  592.     END IF
  593.  
  594.     SL_GET_ANGLE_FROM_POINT = SL_GET_ANGLE_POINT_TO_POINT(x, y, SL_sprite(handle).xint, SL_sprite(handle).yint) 'return angle from point x,y
  595.  
  596.  
  597. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  598. SUB SL_SET_SOFTWARE (handle AS INTEGER, restores AS INTEGER) '                                                                                                                          SL_SET_SOFTWARE
  599.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  600.  
  601.     ' declare global variables
  602.  
  603.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  604.  
  605.     'perform error checks
  606.  
  607.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  608.         SL_ERROR "SL_SET_SOFTWARE", 1, "" '                                                             no, report error to programmer
  609.     END IF
  610.     IF restores < -1 OR restores > 0 THEN '                                                             valid background restoration behavior requested?
  611.         SL_ERROR "SL_SET_SOFTWARE", 2, "" '                                                             no, report error to programmer
  612.     END IF
  613.  
  614.     SL_sprite(handle).software = -1 '                                                    (SL_SOFTWARE)  set sprite to software mode
  615.     SL_sprite(handle).restore = restores '                                       (SL_SAVE & SL_NOSAVE)  set background saving behavior
  616.  
  617.  
  618. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  619. SUB SL_SET_HARDWARE (handle AS INTEGER) '                                                                                                                                               SL_SET_HARDWARE
  620.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  621.  
  622.     ' declare global variables
  623.  
  624.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  625.  
  626.     'perform error checks
  627.  
  628.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  629.         SL_ERROR "SL_SET_HARDWARE", 1, "" '                                                             no, report error to programmer
  630.     END IF
  631.  
  632.     SL_sprite(handle).software = 0 '                                                     (SL_HARDWARE)  set sprite to hardware mode
  633.  
  634.  
  635. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  636. SUB SL_SET_ZOOM (handle AS INTEGER, zoom AS INTEGER) '                                                                                                                                      SL_SET_ZOOM
  637.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  638.  
  639.     ' declare global variables
  640.  
  641.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  642.  
  643.     IF zoom = -32767 THEN '                                                                 (SL_RESET)  reset zoom level?
  644.         SL_sprite(handle).zoom = 100 '                                                                  yes, reset level to normal
  645.         EXIT SUB '                                                                                      leave subroutine
  646.     END IF
  647.  
  648.     ' perform error checks (errors 130-139)
  649.  
  650.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  651.         SL_ERROR "SL_SET_ZOOM", 1, "" '                                                                 no, report error to programmer
  652.     END IF
  653.     IF zoom < 1 THEN '                                                                                  valid zoom level requested?
  654.         SL_ERROR "SL_SET_ZOOM", 130, "" '                                                               no, report error to programmer
  655.     END IF
  656.  
  657.     SL_sprite(handle).zoom = zoom '                                                                     set zoom level
  658.  
  659.  
  660.  
  661. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  662. SUB SL_SET_ROTATION (handle AS INTEGER, degrees AS INTEGER) '                                                                                                                           SL_SET_ROTATION
  663.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  664.  
  665.     ' declare global variables
  666.  
  667.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  668.  
  669.     ' declare local variables
  670.  
  671.     DIM degree AS INTEGER '             degree angle passed in
  672.  
  673.     ' perform error checks
  674.  
  675.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  676.         SL_ERROR "SL_SET_ROTATION", 1, "" '                                                             no, report error to programmer
  677.     END IF
  678.  
  679.     degree = degrees '                                                                                  get degree angle passed in
  680.  
  681.     'handle reset request
  682.  
  683.     IF degree = -32767 THEN '                                                               (SL_RESET)  reset sprite rotation?
  684.         SL_sprite(handle).rotation = 0 '                                                                reset rotation angle
  685.         EXIT SUB '                                                                                      leave subroutine
  686.     END IF
  687.  
  688.     ' correct degree angle if needed (needs to be 0 - 359)
  689.  
  690.     IF degree = 360 THEN '                                                                              is it 360?
  691.         degree = 0 '                                                                                    yes, that's the same as 0
  692.     ELSEIF degree < 0 THEN '                                                                            is it less than 360?
  693.         DO '                                                                                            yes
  694.             degree = degree + 360 '                                                                     increase by 360
  695.         LOOP UNTIL degree > 0 '                                                                         until it's in a valid range
  696.     ELSEIF degree > 360 THEN '                                                                          is it greater than 360?
  697.         DO '                                                                                            yes
  698.             degree = degree - 360 '                                                                     decrease by 360
  699.         LOOP UNTIL degree < 360 '                                                                       until it's in a valid range
  700.     END IF
  701.  
  702.     SL_sprite(handle).rotation = degree '                                                               set degree of rotation
  703.  
  704.  
  705. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  706. SUB SL_FLIP_SPRITE (handle AS INTEGER, flip AS INTEGER) '                                                                                                                                SL_FLIP_SPRITE
  707.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  708.  
  709.     ' declare global variables
  710.  
  711.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  712.  
  713.     ' check for subroutine reset
  714.  
  715.     IF flip = -32767 THEN '                                                                 (SL_RESET)  reset flipping behavior?
  716.         SL_sprite(handle).flip = 0 '                                                       (SL_NOFLIP)  yes, reset flip value
  717.         EXIT SUB '                                                                                      leave subroutine
  718.     END IF
  719.  
  720.     ' perform error checks
  721.  
  722.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  723.         SL_ERROR "SL_FLIP_SPRITE", 1, "" '                                                              no, report error to programmer
  724.     END IF
  725.     IF flip < 0 OR flip > 3 THEN '                                                                      valid flip behavior requested?
  726.         SL_ERROR "SL_FLIP_SPRITE", 120, "" '                                                            no, report error to programmer
  727.     END IF
  728.  
  729.     SL_sprite(handle).flip = flip '                                                                     set flipping behavior
  730.  
  731.  
  732. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  733. SUB SL_PUT_SPRITE (x AS SINGLE, y AS SINGLE, handle AS INTEGER) '                                                                                                                         SL_PUT_SPRITE
  734.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  735.  
  736.     ' declare global variables
  737.  
  738.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  739.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  740.     SHARED SL_rotate() AS SL_ROTATE '   precalculated rotation table
  741.  
  742.     ' declare local variables
  743.  
  744.     DIM xa AS INTEGER '                 actual x location of sprite on screen
  745.     DIM ya AS INTEGER '                 actual y location of sprite on screen
  746.     DIM sw AS INTEGER '                 width of sprite to be drawn
  747.     DIM sh AS INTEGER '                 height of sprite to be drawn
  748.     DIM rw AS INTEGER '                 precalculated rotated sprite width
  749.     DIM rh AS INTEGER '                 precalculated rotated sprite height
  750.     DIM px0 AS INTEGER '                precalculated triangular coordinates
  751.     DIM px1 AS INTEGER
  752.     DIM px2 AS INTEGER
  753.     DIM px3 AS INTEGER
  754.     DIM py0 AS INTEGER
  755.     DIM py1 AS INTEGER
  756.     DIM py2 AS INTEGER
  757.     DIM py3 AS INTEGER
  758.     DIM image AS LONG '                 software sprite image
  759.     DIM mask AS LONG '                  software sprite image mask
  760.     DIM sprite AS LONG '                hardware sprite image
  761.  
  762.     ' perform error checks
  763.  
  764.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  765.         SL_ERROR "SL_PUT_SPRITE", 1, "" '                                                               no, report error to programmer
  766.     END IF
  767.  
  768.     ' check for auto motion
  769.  
  770.     'IF SL_sprite(handle).automotion THEN '                                                              is this sprite auto motion?
  771.     '    EXIT SUB '                                                                                      yes, SL_UPDATE_AUTO_SPRITES handles it, leave subroutine
  772.     'END IF
  773.  
  774.     'local variable setup
  775.  
  776.     SL_sprite(handle).xreal = x '                                                             (SINGLE)  save requested x center location
  777.     SL_sprite(handle).yreal = y '                                                             (SINGLE)  save requested y center location
  778.     SL_sprite(handle).xint = INT(x) '                                                        (INTEGER)  save screen x center location
  779.     SL_sprite(handle).yint = INT(y) '                                                        (INTEGER)  save screen y center location
  780.     image = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).image '  get image from sprite sheet
  781.     mask = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).mask '    get mask from sprite sheet
  782.     sw = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).spritewidth 'get default sprite width from sprite sheet
  783.     sh = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).spriteheight 'get default sprite height from sprite sheet
  784.  
  785.     'free existing images
  786.  
  787.     _FREEIMAGE SL_sprite(handle).sprite '                                                               free hardware sprite image
  788.     _FREEIMAGE SL_sprite(handle).image '                                                                free software sprite image
  789.     IF SL_sprite(handle).mask THEN _FREEIMAGE SL_sprite(handle).mask '                                  free software mask image
  790.     IF SL_sprite(handle).restore THEN '                                                                 is sprite holding a background image?
  791.         IF SL_sprite(handle).background THEN '                                                          yes, has a background image been saved yet?
  792.             _PUTIMAGE (SL_sprite(handle).xback, SL_sprite(handle).yback), SL_sprite(handle).background 'yes, replace background with image
  793.             _FREEIMAGE SL_sprite(handle).background '                                                   free hardware background image
  794.         END IF
  795.         IF NOT SL_sprite(handle).software THEN '                                                        was the sprite type changed?
  796.             SL_sprite(handle).restore = 0 '                                                (SL_NOSAVE)  yes, stop saving background
  797.         END IF
  798.     END IF
  799.  
  800.     'adjust sprite rotation if needed
  801.  
  802.     IF SL_sprite(handle).rotation THEN '                                                                rotate sprite?
  803.         px0 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).px0 '                      yes, get precalculated triangular coordinates
  804.         px1 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).px1
  805.         px2 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).px2
  806.         px3 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).px3
  807.         py0 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).py0
  808.         py1 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).py1
  809.         py2 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).py2
  810.         py3 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).py3
  811.         rw = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).rwidth '                    get precalculated rotated sprite width
  812.         rh = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).rheight '                   get precalculated rotated sprite height
  813.         SL_sprite(handle).image = _NEWIMAGE(rw, rh, 32) '                                               create image using precalculated width/height
  814.         _MAPTRIANGLE (0, 0)-(0, sh-1)-(sw-1, sh-1), image TO _
  815.                      (px0, py0)-(px1, py1)-(px2, py2), SL_sprite(handle).image '                        map rotated sprite onto image
  816.         _MAPTRIANGLE (0, 0)-(sw-1, 0)-(sw-1, sh-1), image TO _
  817.                      (px0, py0)-(px3, py3)-(px2, py2), SL_sprite(handle).image
  818.         IF SL_sprite(handle).transparency THEN '                                                        does this sprite have a mask?
  819.             SL_sprite(handle).mask = _NEWIMAGE(rw, rh, 32) '                                            yes, create mask image
  820.             _MAPTRIANGLE (0, 0)-(0, sh-1)-(sw-1, sh-1), mask TO _
  821.                          (px0, py0)-(px1, py1)-(px2, py2), SL_sprite(handle).mask '                     map rotated mask onto image
  822.             _MAPTRIANGLE (0, 0)-(sw-1, 0)-(sw-1, sh-1), mask TO _
  823.                          (px0, py0)-(px3, py3)-(px2, py2), SL_sprite(handle).mask
  824.         END IF
  825.         sw = rw '                                                                                       save new sprite width
  826.         sh = rh '                                                                                       save new sprite height
  827.     ELSE '                                                                                              no rotation needed
  828.         SL_sprite(handle).image = _COPYIMAGE(image, 32) '                                               copy software image from sprite sheet
  829.         IF SL_sprite(handle).transparency THEN '                                                        does this sprite have a mask?
  830.             SL_sprite(handle).mask = _COPYIMAGE(mask, 32) '                                             yes, copy software mask from sprite sheet
  831.         END IF
  832.     END IF
  833.  
  834.     'create hardware sprite
  835.  
  836.     SL_sprite(handle).sprite = _COPYIMAGE(SL_sprite(handle).image, 33) '                                create hardware sprite of image
  837.  
  838.     'adjust zoom level if needed
  839.  
  840.     IF SL_sprite(handle).zoom <> 100 THEN '                                                             zoom sprite in/out?
  841.         sw = sw * SL_sprite(handle).zoom \ 100 '                                                        yes, calculate new zoom width
  842.         sh = sh * SL_sprite(handle).zoom \ 100 '                                                        calculate new zoom height
  843.     END IF
  844.  
  845.     'calculate actual sprite screen coordinates
  846.  
  847.     xa = SL_sprite(handle).xint - sw \ 2 '                                                              calculate actual screen x location from center
  848.     ya = SL_sprite(handle).yint - sh \ 2 '                                                              calculate actual screen y location from center
  849.     SL_sprite(handle).xactual = xa '                                                         (INTEGER)  save actual screen x location
  850.     SL_sprite(handle).yactual = ya '                                                         (INTEGER)  save actual screen y location
  851.  
  852.     'get background image before placing sprite if necessary
  853.  
  854.     IF SL_sprite(handle).restore THEN '                                                                 is this sprite storing background images?
  855.         SL_sprite(handle).background = _NEWIMAGE(sw, sh, 32) '                                          yes, create background image
  856.         _PUTIMAGE , _DEST, SL_sprite(handle).background, (xa, ya)-(xa + sw - 1, ya + sh - 1) '          get background area from current destination
  857.         SL_sprite(handle).xback = xa '                                                                  record background x location
  858.         SL_sprite(handle).yback = ya '                                                                  record background y location
  859.     END IF
  860.  
  861.     'use hardware or software image
  862.  
  863.     IF SL_sprite(handle).software THEN '                                                                is this a software sprite?
  864.         sprite = SL_sprite(handle).image '                                                              yes, use the software image
  865.     ELSE '                                                                                              no
  866.         sprite = SL_sprite(handle).sprite '                                                             use the hardware image
  867.     END IF
  868.  
  869.     ' place sprite on the current destination
  870.  
  871.     SELECT CASE SL_sprite(handle).flip '                                                                which flipping style is selected?
  872.         CASE 0 '                                                                           (SL_NOFLIP)  normal, no flipping
  873.             _PUTIMAGE (xa, ya)-(xa + sw - 1, ya + sh - 1), sprite '                                     draw normal sprite
  874.         CASE 1 '                                                                       (SL_HORIZONTAL)  flip horizontally
  875.             _PUTIMAGE (xa + sw - 1, ya)-(xa, ya + sh - 1), sprite '                                     draw horizontally flipped sprite
  876.         CASE 2 '                                                                         (SL_VERTICAL)  flip vertically
  877.             _PUTIMAGE (xa, ya + sh - 1)-(xa + sw - 1, ya), sprite '                                     draw vertically flipped sprite
  878.         CASE 3 '                                                                         (SL_FLIPBOTH)  flip vertically and horizontally
  879.             _PUTIMAGE (xa + sw - 1, ya + sh - 1)-(xa, ya), sprite '                                     draw horizontally and vertically flipped sprite
  880.     END SELECT
  881.  
  882.  
  883. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  884. FUNCTION SL_NEW_SPRITE (sheet AS INTEGER, column AS INTEGER, row AS INTEGER, software AS INTEGER, restores AS INTEGER) '                                                                  SL_NEW_SPRITE
  885.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  886.  
  887.     ' declare global variables
  888.  
  889.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  890.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  891.  
  892.     ' declare local variables
  893.  
  894.     DIM handle AS INTEGER '             handle (pointer) number of new sprite
  895.  
  896.     ' perform error checks
  897.  
  898.     IF sheet > UBOUND(SL_sheet) OR SL_sheet(sheet, 0, 0).image <> -1 THEN '                             valid sprite sheet requested?
  899.         SL_ERROR "SL_NEW_SPRITE", 110, "" '                                                             no, report error to programmer
  900.     END IF
  901.     IF column > UBOUND(SL_sheet, 2) OR row > UBOUND(SL_sheet, 3) OR row < 1 OR column < 1 THEN '        valid row and column requested?
  902.         SL_ERROR "SL_NEW_SPRITE", 111, "" '                                                             no, report error to programmer
  903.     END IF
  904.     IF restores < -1 OR restores > 0 THEN '                                                             valid background restoration behavior requested?
  905.         SL_ERROR "SL_NEW_SPRITE", 2, "" '                                                               no, report error to programmer
  906.     END IF
  907.     IF software < -1 OR software > 0 THEN '                                                             valid hardware / software setting requested?
  908.         SL_ERROR "SL_NEW_SPRITE", 112, "" '                                                             no, report error to programmer
  909.     END IF
  910.     IF (NOT software) AND restores THEN '                                                               hardware image that restores background?
  911.         SL_ERROR "SL_NEW_SPRITE", 113, "" '                                                             yes, report error to programmer
  912.     END IF
  913.  
  914.     ' local variable setup
  915.  
  916.     handle = 0 '                                                                                        initialize handle value
  917.  
  918.     ' increase sprite array's size if needed
  919.  
  920.     DO '                                                                                                look for next available handle
  921.         handle = handle + 1 '                                                                           increment to next handle value
  922.     LOOP UNTIL (NOT SL_sprite(handle).inuse) OR handle = UBOUND(SL_sprite) '                            stop looking when valid handle found
  923.     IF SL_sprite(handle).inuse THEN '                                                                   is the last array element in use?
  924.         handle = handle + 1 '                                                                           yes, increment to next handle value
  925.         REDIM _PRESERVE SL_sprite(handle) AS SL_SPRITE '                                                increase the size of the sprite array
  926.     END IF
  927.  
  928.     ' populate sprite array
  929.  
  930.     SL_sprite(handle).inuse = -1 '                                                              (TRUE)  mark array index as in use
  931.     SL_sprite(handle).sheet = sheet '                                                                   point to sheet where sprite resides              *
  932.     SL_sprite(handle).column = column '                                                                 point to column on sheet where sprite located    * these still needed?
  933.     SL_sprite(handle).row = row '                                                                       point to row on sheet where sprite located       *
  934.     SL_sprite(handle).software = software '                                (SL_SOFTWARE & SL_HARDWARE)  sprite treated as software or hardware image
  935.     SL_sprite(handle).restore = restores '                                       (SL_SAVE & SL_NOSAVE)  background restore behavior of sprite
  936.     SL_sprite(handle).background = 0 '                                                                  no background image saved yet
  937.     SL_sprite(handle).xreal = 0 '                                                                       reset x location of sprite (center x)
  938.     SL_sprite(handle).yreal = 0 '                                                                       reset y location of sprite (center y)
  939.     SL_sprite(handle).xint = 0 '                                                                        reset x location of sprite on screen INT(xreal) (center x)
  940.     SL_sprite(handle).yint = 0 '                                                                        reset y location of sprite on screen INT(yreal) (center y)
  941.     SL_sprite(handle).xactual = 0 '                                                                     reset x location of sprite on screen (upper left x)
  942.     SL_sprite(handle).yactual = 0 '                                                                     reset y location of sprite on screen (upper left y)
  943.     SL_sprite(handle).collx1 = SL_sheet(sheet, column, row).collx1 '                                    get sprite's collision box boundaries
  944.     SL_sprite(handle).colly1 = SL_sheet(sheet, column, row).colly1
  945.     SL_sprite(handle).collx2 = SL_sheet(sheet, column, row).collx2
  946.     SL_sprite(handle).colly2 = SL_sheet(sheet, column, row).colly2
  947.     SL_sprite(handle).spritewidth = SL_sheet(sheet, column, row).spritewidth '                          get width of sprite
  948.     SL_sprite(handle).spriteheight = SL_sheet(sheet, column, row).spriteheight '                        get height of sprite
  949.     SL_sprite(handle).sprite = _COPYIMAGE(SL_sheet(sheet, column, row).image, 33) '                     create hardware sprite image
  950.     SL_sprite(handle).image = _COPYIMAGE(SL_sheet(sheet, column, row).image, 32) '                      copy software sprite image from sheet
  951.     IF SL_sheet(sheet, column, row).transparency THEN '                                                 does this sprite use transparency?
  952.         SL_sprite(handle).mask = _COPYIMAGE(SL_sheet(sheet, column, row).mask, 32) '                    yes, copy software sprite mask image from sheet
  953.         SL_sprite(handle).transparency = -1 '                                                   (TRUE)  remember this sprite has a transparency layer
  954.     ELSE '                                                                                              no transparency
  955.         SL_sprite(handle).mask = 0 '                                                                    no mask will be brought in
  956.         SL_sprite(handle).transparency = 0 '                                                   (FALSE)  remember this sprite has no transparency layer
  957.     END IF
  958.     SL_sprite(handle).flip = 0 '                                                                        no sprite flipping
  959.     SL_sprite(handle).rotation = 0 '                                                                    no sprite rotation angle
  960.     SL_sprite(handle).zoom = 100 '                                                                      zoom normal at 100%
  961.     SL_sprite(handle).spin = 0 '                                                                        sprite will not spin automatically
  962.     SL_sprite(handle).xdir = 0 '                                                                        x direction during motion
  963.     SL_sprite(handle).ydir = 0 '                                                                        y direction during motion
  964.     SL_sprite(handle).speed = 0 '                                                                       speed during motion
  965.     SL_sprite(handle).direction = 0 '                                                                   direction during motion (0 - 359)
  966.     SL_sprite(handle).automotion = 0 '                                                         (FALSE)  auto motion disabled
  967.     SL_sprite(handle).autorotate = 0 '                                                         (FALSE)  auto rotation disabled
  968.  
  969.     SL_NEW_SPRITE = handle '                                                                            return pointer value of new sprite
  970.  
  971.  
  972. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  973. SUB SL_FREE_SPRITE (handle AS INTEGER) '                                                                                                                                                 SL_FREE_SPRITE
  974.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  975.  
  976.     ' declare global variables
  977.  
  978.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  979.  
  980.     ' check for errors
  981.  
  982.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  983.         SL_ERROR "SL_PUT_SPRITE", 1, "" '                                                               no, report error to programmer
  984.     END IF
  985.  
  986.     ' restore background if this sprite saving background
  987.  
  988.     IF SL_sprite(handle).restore THEN '                                                                 is there a background image to restore?
  989.         _PUTIMAGE (SL_sprite(handle).xback, SL_sprite(handle).yback), SL_sprite(handle).background '    yes, restore the image
  990.         _FREEIMAGE SL_sprite(handle).background '                                                       free background image
  991.     END IF
  992.  
  993.     ' free all image data associated with sprite
  994.  
  995.     IF SL_sprite(handle).background THEN _FREEIMAGE SL_sprite(handle).background '                      free background image if present
  996.     IF SL_sprite(handle).mask THEN _FREEIMAGE SL_sprite(handle).mask '                                  free sprite mask image if present
  997.     _FREEIMAGE SL_sprite(handle).sprite '                                                               free hardware sprite image
  998.     _FREEIMAGE SL_sprite(handle).image '                                                                free software sprite image
  999.  
  1000.     IF handle = UBOUND(sl_sprite) AND handle <> 1 THEN '                                                is handle the last element in array?
  1001.         REDIM _PRESERVE SL_sprite(handle - 1) AS SL_SPRITE '                                            yes, remove index and resize array
  1002.     ELSE '                                                                                              no, index somewhere else
  1003.         SL_sprite(handle).inuse = 0 '                                                          (FALSE)  mark index as usable later
  1004.     END IF
  1005.  
  1006.  
  1007. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1008. FUNCTION SL_NEW_SHEET (filename AS STRING, spritewidth AS INTEGER, spriteheight AS INTEGER, transparency AS INTEGER, transcolor AS _UNSIGNED LONG) '                                       SL_NEW_SHEET
  1009.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1010.  
  1011.     ' declare global variables
  1012.  
  1013.     SHARED SL_sheet() AS SL_SHEET '    master sprite sheet array
  1014.     SHARED SL_rotate() AS SL_ROTATE '  precalculated rotation table
  1015.  
  1016.     ' declare local variables
  1017.  
  1018.     DIM handle AS INTEGER '             handle (pointer) number of new sprite sheet
  1019.     DIM x AS INTEGER '                  generic counter to cycle through sheet sprite columns
  1020.     DIM y AS INTEGER '                  generic counter to cycle through sheet sprite rows
  1021.     DIM x1 AS INTEGER '                 generic counter to cycle though sprite for collision boundaries and mask creation
  1022.     DIM y1 AS INTEGER '                 generic ocunter to cycle though sprite for collision boundaries and mask creation
  1023.     DIM osource AS LONG '               original source image before this function was called
  1024.     DIM odest AS LONG '                 original destination image before this function was called
  1025.     DIM pixel AS _UNSIGNED LONG '       pixel color at each coordinate in sprite sheet
  1026.     DIM alpha AS _UNSIGNED LONG '       alpha level of current pixel
  1027.     DIM top AS INTEGER '                upper boundary of sprite image
  1028.     DIM bottom AS INTEGER '             lower boundary of sprite image
  1029.     DIM left AS INTEGER '               left boundary of sprite image
  1030.     DIM right AS INTEGER '              right boundary of sprite image
  1031.     DIM sheetimage AS LONG '            sprite sheet image
  1032.     DIM sheetwidth AS INTEGER '         width of sprite sheet in pixels
  1033.     DIM sheetheight AS INTEGER '        height of sprite sheet in pixels
  1034.     DIM rows AS INTEGER '               number of sprite rows contained on sheet
  1035.     DIM columns AS INTEGER '            number of sprite columns contained on sheet
  1036.     DIM clearcolor AS _UNSIGNED LONG '  transcolor passed in will be modified
  1037.     DIM tempsprite AS LONG '            temporary sprite for _CLEARCOLOR detection
  1038.     DIM px(3) AS DOUBLE '               polar x coordinates of maptriangle
  1039.     DIM py(3) AS DOUBLE '               polar y coordinates of maptriangle
  1040.     DIM sinr AS DOUBLE '                sin rotation calculation
  1041.     DIM cosr AS DOUBLE '                cosine rotation claculation
  1042.     DIM bx1 AS DOUBLE '                 max boundaries of rotated sprite
  1043.     DIM bx2 AS DOUBLE
  1044.     DIM by1 AS DOUBLE
  1045.     DIM by2 AS DOUBLE
  1046.     DIM x2 AS DOUBLE '                  new computed polar coordinates
  1047.     DIM y2 AS DOUBLE
  1048.  
  1049.     ' perform error checks
  1050.  
  1051.     IF NOT _FILEEXISTS(filename) THEN '                                                                 does the sprite sheet exist?
  1052.         SL_ERROR "SL_NEW_SHEET", 100, filename '                                                        no, report error to programmer
  1053.     END IF
  1054.     IF ABS(transparency) > 1 THEN '                                                                     valid transparency setting?
  1055.         SL_ERROR "SL_NEW_SHEET", 101, "" '                                                              no, report error to programmer
  1056.     END IF
  1057.     IF spritewidth < 1 OR spriteheight < 1 THEN '                                                       valid sprite width/height supplied?
  1058.         SL_ERROR "SL_NEW_SHEET", 102, "" '                                                              no, report error to programmer
  1059.     END IF
  1060.     IF transparency = -1 AND UCASE$(RIGHT$(filename, 4)) <> ".PNG" THEN '                               wrong file type for transparency?
  1061.         SL_ERROR "SL_NEW_SHEET", 103, UCASE$(RIGHT$(filename, 4)) '                                     yes, report error to programmer
  1062.     END IF
  1063.  
  1064.     ' local variable setup
  1065.  
  1066.     sheetimage = _LOADIMAGE(filename, 32) '                                                             load sprite sheet file
  1067.     sheetwidth = _WIDTH(sheetimage) '                                                                   get width of sheet
  1068.     sheetheight = _HEIGHT(sheetimage) '                                                                 get height of sheet
  1069.     columns = sheetwidth \ spritewidth '                                                                get number of whole columns of sprites
  1070.     rows = sheetheight \ spriteheight '                                                                 get number of whole rows of sprites
  1071.     IF columns < 1 OR rows < 1 THEN '                                                                   at least one sprite column and row on sheet?
  1072.         SL_ERROR "SL_NEW_SHEET", 104, "" '                                                              no, report error to programmer
  1073.     END IF
  1074.     osource = _SOURCE '                                                                                 remember current source image
  1075.     odest = _DEST '                                                                                     remember current destination image
  1076.     handle = 0 '                                                                                        initialize handle value
  1077.     clearcolor = transcolor '                                                                           get background/transparent color passed in
  1078.  
  1079.     ' increase sheet array's 1st dimension if needed to create a new sprite sheet
  1080.  
  1081.     DO '                                                                                                look for the next available handle
  1082.         handle = handle + 1 '                                                                           increment the handle value
  1083.     LOOP UNTIL (NOT SL_sheet(handle, 0, 0).image) OR handle = UBOUND(SL_sheet) '                        stop looking when valid handle value found
  1084.     IF SL_sheet(handle, 0, 0).image = -1 THEN '                                                 (TRUE)  is the last array element in use?
  1085.         handle = handle + 1 '                                                                           yes, increment the handle value
  1086.         REDIM _PRESERVE SL_sheet(handle, UBOUND(SL_sheet, 2), UBOUND(SL_sheet, 3)) AS SL_SHEET '        create new sheet in sprite array
  1087.         REDIM _PRESERVE SL_rotate(handle, UBOUND(SL_rotate, 2)) AS SL_ROTATE
  1088.     END IF
  1089.  
  1090.     ' increase sheet array's 2nd and 3rd dimensions if needed to match number of rows and columns
  1091.  
  1092.     IF columns > UBOUND(SL_sheet, 2) THEN '                                                             more columns in this sheet than others?
  1093.         REDIM _PRESERVE SL_sheet(handle, columns, UBOUND(SL_sheet, 3)) AS SL_SHEET '                    yes, increase the array's 2nd dimension to match
  1094.     END IF
  1095.     IF rows > UBOUND(SL_sheet, 3) THEN '                                                                more rows in this sheet than others?
  1096.         REDIM _PRESERVE SL_sheet(handle, UBOUND(SL_sheet, 2), rows) AS SL_SHEET '                       yes, increase the array's 3rd dimension to match
  1097.     END IF
  1098.  
  1099.     ' the variables in SL_sheet(x, 0, 0) will serve a dual purpose
  1100.     ' SL_sheet(x, 0, 0).image will contain either -1 (true) or 0 (false) to indicate the first dimension of the array is in use.
  1101.     ' SL_sheet(x, 0, 0).spritewidth will contain the number of columns contained in the sheet (the array's 2nd dimension)
  1102.     ' SL_sheet(x, 0, 0).spriteheight will contain the number of rows contained in the sheet (the array's 3rd dimension)
  1103.  
  1104.     SL_sheet(handle, 0, 0).image = -1 '                                                         (TRUE)  mark as in use
  1105.     SL_sheet(handle, 0, 0).spritewidth = columns '                                                      remember number of columns in sheet
  1106.     SL_sheet(handle, 0, 0).spriteheight = rows '                                                        remember number of rows in sheet
  1107.  
  1108.     ' identify transparency of sprite sheet if requested
  1109.  
  1110.     IF transparency = -1 THEN '                                                 (constant SL_USESHEET)  sheet have alpha channel?
  1111.         x = 0 '                                                                                         yes, start at upper left x of sheet
  1112.         y = 0 '                                                                                         start at upper left y of sheet
  1113.         alpha = 255 '                                                                                   assume no alpha channel
  1114.         _SOURCE sheetimage '                                                                            set sprite sheet image as source image
  1115.         DO '                                                                                            start looping through the sheet's pixels
  1116.             pixel = POINT(x, y) '                                                                       get the pixel's color attributes
  1117.             alpha = _ALPHA32(pixel) '                                                                   get the alpha level (0 - 255)
  1118.             IF alpha = 0 THEN EXIT DO '                                                                 if it is transparent then leave the loop
  1119.             x = x + 1 '                                                                                 move right one pixel
  1120.             IF x > sheetwidth THEN '                                                                    have we gone off the sheet?
  1121.                 x = 0 '                                                                                 yes, reset back to the left beginning
  1122.                 y = y + 1 '                                                                             move down one pixel
  1123.             END IF
  1124.         LOOP UNTIL y > sheetheight '                                                                    don't stop until the entire sheet has been checked
  1125.         IF alpha = 0 THEN '                                                                             did we find a transparent pixel?
  1126.             tempsprite = _NEWIMAGE(1, 1, 32) '                                                          yes, create a temporary image         * why did I have to do
  1127.             _CLEARCOLOR pixel, tempsprite '                                                             set pixel found as transparent        * this hack to get
  1128.             clearcolor = _CLEARCOLOR(tempsprite) '                                                      get the transparent color from image  * clearcolor to come out
  1129.             _FREEIMAGE tempsprite '                                                                     temporary image no longer needed      * to the right value?
  1130.         ELSE '                                                                                          no transparency found within sheet
  1131.             transparency = 1 '                                                                          set sheet to having no alpha channel
  1132.         END IF
  1133.     ELSEIF transparency = 0 THEN '                                                   (constant SL_SET)  manually set alpha channel?
  1134.         _CLEARCOLOR clearcolor, sheetimage '                                                            yes, set color as transparent
  1135.         clearcolor = _CLEARCOLOR(sheetimage) '                                                          get the transparent color ************* again, why this hack?
  1136.     END IF
  1137.  
  1138.     ' load sprites from sheet and place into sprite array
  1139.  
  1140.     FOR x = 1 TO columns '                                                                              cycle through the sheet's columns
  1141.         FOR y = 1 TO rows '                                                                             cycle through the sheet's rows
  1142.             SL_sheet(handle, x, y).image = _NEWIMAGE(spritewidth, spriteheight, 32) '                   create software sprite image
  1143.             IF transparency < 1 THEN '                                                                  should a mask be created?
  1144.                 SL_sheet(handle, x, y).mask = _NEWIMAGE(spritewidth, spriteheight, 32) '                yes, create software sprite mask image
  1145.                 _DEST SL_sheet(handle, x, y).mask '                                                     write to the mask image
  1146.             ELSE
  1147.                 SL_sheet(handle, x, y).transparency = 0 '                                      (FALSE)  set sprite as having no transparency
  1148.             END IF
  1149.             _PUTIMAGE , sheetimage, SL_sheet(handle, x, y).image,_
  1150.                  ((x - 1) * spritewidth, (y - 1) * spriteheight)-_
  1151.                  ((x - 1) * spritewidth + spritewidth - 1, (y - 1) * spriteheight + spriteheight - 1) ' copy sprite from sheet and place in sprite image
  1152.  
  1153.             ' precalculate collision boundaries and update sprite mask if needed
  1154.  
  1155.             _SOURCE SL_sheet(handle, x, y).image '                                                      work from the software sprite image
  1156.             top = spriteheight - 1 '                                                                    set initial collision boundary markers
  1157.             left = spritewidth - 1
  1158.             bottom = 0
  1159.             right = 0
  1160.             FOR x1 = 0 TO spritewidth - 1 '                                                             cycle through the width of sprite
  1161.                 FOR y1 = 0 TO spriteheight - 1 '                                                        cycle through the height of sprite
  1162.                     IF POINT(x1, y1) <> clearcolor THEN '                                               is this pixel a transparent/background color?
  1163.                         IF x1 < left THEN left = x1 '                                                   no, save position if left-most pixel
  1164.                         IF y1 < top THEN top = y1 '                                                     save position if top-most pixel
  1165.                         IF x1 > right THEN right = x1 '                                                 save position if right-most pixel
  1166.                         IF y1 > bottom THEN bottom = y1 '                                               save position if bbottom-most pixel
  1167.                     END IF
  1168.                     IF transparency < 1 THEN '                                                          update software sprite mask?
  1169.                         IF POINT(x1, y1) = clearcolor THEN '                                            yes, is this pixel a transparent/background color?
  1170.                             PSET (x1, y1), _RGB32(255, 255, 255) '                                      yes, set as white on the mask image
  1171.                         END IF
  1172.                     END IF
  1173.                 NEXT y1
  1174.             NEXT x1
  1175.             SL_sheet(handle, x, y).collx1 = left '                                                      collision box top left x
  1176.             SL_sheet(handle, x, y).colly1 = top '                                                       collision box top left y
  1177.             SL_sheet(handle, x, y).collx2 = right '                                                     collision box bottom right x
  1178.             SL_sheet(handle, x, y).colly2 = bottom '                                                    collision box bottom right y
  1179.             SL_sheet(handle, x, y).spritewidth = spritewidth '                                          remember sprite width
  1180.             SL_sheet(handle, x, y).spriteheight = spriteheight '                                        remember sprite height
  1181.         NEXT y
  1182.     NEXT x
  1183.     _FREEIMAGE sheetimage '                                                                             sprite sheet image no longer needed
  1184.  
  1185.     ' create precalculated rotation table for the sprite sheet (0 to 359 degrees)
  1186.  
  1187.     FOR x = 1 TO 359
  1188.         'px(0) = (-spritewidth + 1) / 2 '                                                                upper left  x polar coordinate of sprite
  1189.         'py(0) = (-spriteheight + 1) / 2 '                                                               upper left  y polar coordinate of sprite
  1190.         px(0) = -spritewidth / 2 '                                                                      upper left  x polar coordinate of sprite
  1191.         py(0) = -spriteheight / 2 '                                                                     upper left  y polar coordinate of sprite
  1192.         px(1) = px(0) '                                                                                 lower left  x polar coordinate of sprite
  1193.         'py(1) = (spriteheight -1) / 2 '                                                                 lower left  y polar coordinate of sprite
  1194.         'px(2) = (spritewidth - 1) / 2 '                                                                 lower right x polar coordinate of sprite
  1195.         py(1) = spriteheight / 2 '                                                                      lower left  y polar coordinate of sprite
  1196.         px(2) = spritewidth / 2 '                                                                       lower right x polar coordinate of sprite
  1197.         py(2) = py(1) '                                                                                 lower right y polar coordinate of sprite
  1198.         px(3) = px(2) '                                                                                 upper right x polar coordinate of sprite
  1199.         py(3) = py(0) '                                                                                 upper right y polar coordinate of sprite
  1200.         sinr = SIN(-x / 57.2957795131) '                                                                calculate the sin of rotation
  1201.         cosr = COS(-x / 57.2957795131) '                                                                calculate the cosine of rotation
  1202.         bx1 = 0 '                                                                                       upper left x boundary of sprite
  1203.         by1 = 0 '                                                                                       upper left y boundary of sprite
  1204.         bx2 = 0 '                                                                                       lower right x boundary of sprite
  1205.         by2 = 0 '                                                                                       lower right y boundary of sprite
  1206.         FOR y = 0 TO 3 '                                                                                cycle through all four polar coordinates
  1207.             x2 = (px(y) * cosr + sinr * py(y)) '                                                        compute new polar coordinate location
  1208.             y2 = (py(y) * cosr - px(y) * sinr) '                                                        compute new polar coordinate location
  1209.             px(y) = x2 '                                                                                save the new polar coordinate
  1210.             py(y) = y2 '                                                                                save the new polar coordinate
  1211.             IF px(y) < bx1 THEN bx1 = px(y) '                                                           save lowest  x value seen \  NOTE: use for
  1212.             IF px(y) > bx2 THEN bx2 = px(y) '                                                           save highest x value seen  \ background image         <--------------------- LOOK
  1213.             IF py(y) < by1 THEN by1 = py(y) '                                                           save lowest  y value seen  / rectangle coordinates
  1214.             IF py(y) > by2 THEN by2 = py(y) '                                                           save highest y value seen /
  1215.         NEXT y
  1216.         SL_rotate(handle, x).rwidth = bx2 - bx1 + 1 '                                                   calculate width of rotated sprite
  1217.         SL_rotate(handle, x).rheight = by2 - by1 + 1 '                                                  calculate height of rotated sprite
  1218.         SL_rotate(handle, x).px0 = px(0) + ((bx2 - bx1 + 1) \ 2) '                                      calculate triangular coordinates
  1219.         SL_rotate(handle, x).px1 = px(1) + ((bx2 - bx1 + 1) \ 2)
  1220.         SL_rotate(handle, x).px2 = px(2) + ((bx2 - bx1 + 1) \ 2)
  1221.         SL_rotate(handle, x).px3 = px(3) + ((bx2 - bx1 + 1) \ 2)
  1222.         SL_rotate(handle, x).py0 = py(0) + ((by2 - by1 + 1) \ 2)
  1223.         SL_rotate(handle, x).py1 = py(1) + ((by2 - by1 + 1) \ 2)
  1224.         SL_rotate(handle, x).py2 = py(2) + ((by2 - by1 + 1) \ 2)
  1225.         SL_rotate(handle, x).py3 = py(3) + ((by2 - by1 + 1) \ 2)
  1226.  
  1227.         'SL_rotate(handle, x).rwidth = bx2 - bx1 '                                                       calculate width of rotated sprite
  1228.         'SL_rotate(handle, x).rheight = by2 - by1 '                                                      calculate height of rotated sprite
  1229.         'SL_rotate(handle, x).px0 = px(0) + ((bx2 - bx1) / 2) '                                          calculate triangular coordinates
  1230.         'SL_rotate(handle, x).px1 = px(1) + ((bx2 - bx1) / 2)
  1231.         'SL_rotate(handle, x).px2 = px(2) + ((bx2 - bx1) / 2)
  1232.         'SL_rotate(handle, x).px3 = px(3) + ((bx2 - bx1) / 2)
  1233.         'SL_rotate(handle, x).py0 = py(0) + ((by2 - by1) / 2)
  1234.         'SL_rotate(handle, x).py1 = py(1) + ((by2 - by1) / 2)
  1235.         'SL_rotate(handle, x).py2 = py(2) + ((by2 - by1) / 2)
  1236.         'SL_rotate(handle, x).py3 = py(3) + ((by2 - by1) / 2)
  1237.  
  1238.     NEXT x
  1239.     _SOURCE osource '                                                                                   return source to current
  1240.     _DEST odest '                                                                                       return destination to current
  1241.     SL_NEW_SHEET = handle '                                                                             return the handle number pointing to this sheet
  1242.  
  1243.  
  1244. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1245. FUNCTION SL_VALID_SPRITE (handle AS INTEGER) '                                                                                                                                         SL_VALID_SPRITE
  1246.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1247.  
  1248.     ' declare global variables
  1249.  
  1250.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1251.  
  1252.     IF handle > UBOUND(SL_SPRITE) OR (NOT SL_sprite(handle).inuse) OR handle < 1 THEN '                  is this a valid sprite handle?
  1253.         SL_VALID_SPRITE = 0 '                                                                   (FALSE)  no, return 0
  1254.     ELSE '                                                                                               yes, it is valid
  1255.         SL_VALID_SPRITE = -1 '                                                                   (TRUE)  return -1
  1256.     END IF
  1257.  
  1258.  
  1259. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1260. SUB SL_ERROR (routine AS STRING, errno AS INTEGER, info AS STRING) '                                                                                                                           SL_ERROR
  1261.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1262.  
  1263.     SCREEN 0, 0, 0, 0 '                                                                                 go to a pure text screen
  1264.     _FONT 16 '                                                                                          set the standard screen 0 font
  1265.     IF _FULLSCREEN THEN _FULLSCREEN _OFF '                                                              turn off full screen if on
  1266.     _AUTODISPLAY '                                                                                      auto update the display
  1267.     CLS '                                                                                               clear the screen
  1268.     COLOR 10, 0
  1269.     PRINT "                   **************************************" '                                 print error header
  1270.     PRINT "                   ** Sprite Library Error Encountered **"
  1271.     PRINT "                   **************************************"
  1272.     PRINT
  1273.     COLOR 15, 0
  1274.     PRINT " "; routine;
  1275.     COLOR 7, 0
  1276.     PRINT " has reported error";
  1277.     COLOR 30, 0
  1278.     PRINT STR$(errno)
  1279.     COLOR 7, 0
  1280.     PRINT
  1281.     SELECT CASE errno '                                                                                 which error number is being reported?
  1282.  
  1283.         ' general purpose errors for all subs/functions
  1284.  
  1285.         CASE 1
  1286.             PRINT "- the requested sprite does not exist"
  1287.         CASE 2
  1288.             PRINT "- invalid background restore setting supplied - valid settings are"
  1289.             PRINT "- : -1 (constant SL_SAVE)"
  1290.             PRINT "- :  0 (constant SL_NOSAVE)"
  1291.  
  1292.             ' errors belonging to SL_NEW_SHEET (100 - 109)
  1293.  
  1294.         CASE 100
  1295.             PRINT "- "; CHR$(34); info; CHR$(34); " sprite sheet does not exist"
  1296.             PRINT "- check path or spelling"
  1297.         CASE 101
  1298.             PRINT "- invalid transparency setting supplied - valid settings are"
  1299.             PRINT "- : -1 (constant SL_USESHEET)"
  1300.             PRINT "- :  0 (constant SL_SET)"
  1301.             PRINT "- :  1 (constant SL_NONE)"
  1302.         CASE 102
  1303.             PRINT "- sprite width and height must be greater than zero"
  1304.         CASE 103
  1305.             PRINT "- selecting to use a sheet's transparency only works with .PNG files"
  1306.             PRINT "- the function was passed a "; info; " file."
  1307.         CASE 104
  1308.             PRINT "- there must be at least one column and one row of sprites on sheet"
  1309.             PRINT "- the sheet being loaded does not meet these minimums"
  1310.  
  1311.             'errors belonging to SL_NEW_SPRITE (110 - 119)
  1312.  
  1313.         CASE 110
  1314.             PRINT "- the specified sprite sheet is not in use or does not exist"
  1315.         CASE 111
  1316.             PRINT "- invalid row or column selected for specified sprite sheet"
  1317.         CASE 112
  1318.             PRINT "- invalid hardware / software setting supplied - valid settings are"
  1319.             PRINT "- : -1 (constant SL_SOFTWARE)"
  1320.             PRINT "- :  0 (constant SL_HARDWARE)"
  1321.         CASE 113
  1322.             PRINT "- there is no need to restore the background with hardware sprites"
  1323.             PRINT "- change background restore setting to zero (0) (constant SL_NOSAVE)"
  1324.  
  1325.             ' errors belonging to SL_FLIP_SPRITE (120 - 129)
  1326.  
  1327.         CASE 120
  1328.             PRINT "- invalid flip setting supplied - valid settings are"
  1329.             PRINT "  : 0 (constant SL_NOFLIP)"
  1330.             PRINT "  : 1 (constant SL_HORIZONTAL)"
  1331.             PRINT "  : 2 (constant SL_VERTICAL)"
  1332.             PRINT "  : 3 (constant SL_FLIPBOTH)"
  1333.  
  1334.             ' errors belonging to SL_ZOOM_SPRITE (130 - 139)
  1335.  
  1336.         CASE 130
  1337.             PRINT "- invalid zoom level setting supplied"
  1338.             PRINT "- zoom level must be greater than zero (0)"
  1339.  
  1340.             ' errors belonging to SL_SET_ROTATION_SPEED (140 - 149)
  1341.  
  1342.         CASE 140
  1343.             PRINT "- rotation speed must be between -359 and 359 degrees"
  1344.  
  1345.             ' errors belonging to SL_SET_AUTOMOTION (150 - 159)
  1346.  
  1347.         CASE 150
  1348.             PRINT "- invalid auto motion behavior requested - valid settings are"
  1349.             PRINT "- : -1 (constant SL_START)"
  1350.             PRINT "- :  0 (constant SL_STOP)"
  1351.  
  1352.             ' errors belonging to SL_SET_AUTOROTATE (160 - 169)
  1353.  
  1354.         CASE 160
  1355.             PRINT "- invalid auto rotation behavior requested - valid settings are"
  1356.             PRINT "- : -1 (constant SL_START)"
  1357.             PRINT "- :  0 (constant SL_STOP)"
  1358.  
  1359.             ' errors belonging to SL_MOVE_SPRITE (170 - 179)
  1360.  
  1361.         CASE 170
  1362.             PRINT "- the sprite requested is already under automatic movement control"
  1363.  
  1364.             ' errors belonging to SL_ROTATE_SPRITE (180 - 189)
  1365.  
  1366.         CASE 180
  1367.             PRINT "- the sprite requested is already under automatic rotation control"
  1368.  
  1369.     END SELECT
  1370.     COLOR 12, 0
  1371.     PRINT
  1372.     PRINT " See sprite library doumentation for further explanation."
  1373.     COLOR 7, 0
  1374.     DO: LOOP UNTIL INKEY$ = "" '                                                                        clear the keyboard buffer
  1375.     END '                                                                                               end the program
  1376.  
  1377.  
  1378.  
Title: Re: Sprite Library Revisited
Post by: Petr on September 16, 2018, 03:39:58 pm
Hi,
could I ask you for a dkong.png file? :-D  oh, sorry i found it....

Nice and clear. It's a great job. I look forward to continuing.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 17, 2018, 02:23:28 am
I added the following commands today:

FUNCTION SL_FIX_DEGREES(degrees AS INTEGER)
- Returns a degree value between 0 and 359 for any given value

FUNCTION SL_GET_REALX (handle AS INTEGER)
- Return the single precision center point x value of a sprite

FUNCTION SL_GET_REALY (handle AS INTEGER)
- Return the single precision center point y value of a sprite

FUNCTION SL_GET_INTX (handle AS INTEGER)
- Return the integer center point x value of a sprite

FUNCTION SL_GET_INTY (handle AS INTEGER)
- Return the integer center point x value of a sprite

FUNCTION SL_GET_ACTUALX (handle AS INTEGER)
- Return the integer upper left point x value of a sprite

FUNCTION SL_GET_ACTUALY (handle AS INTEGER)
- Return the integer upper left point Y value of a sprite

FUNCTION SL_COPY_SPRITE (handle AS INTEGER)
- Create a copy of the given sprite

SUB SL_STAMP_SPRITE (x AS INTEGER, y AS INTEGER, sheet AS INTEGER, column AS INTEGER, row AS INTEGER, degrees AS INTEGER, flip AS INTEGER, zoom AS INTEGER)
- Stamp a software image of a sprite to the current destination with the given characteristics

Also made some internal modifications to how information is stored in data TYPES and arrays in preparation for the animation commands. Tomorrow I'll be tackling the animation commands and possibly some auto-travel  ideas I have from Steve's input on giving sprites a defined path to follow.
Title: Re: Sprite Library Revisited
Post by: codeguy on September 17, 2018, 02:59:03 am
Code: QB64: [Select]
  1. ' if SL_EVENT_TRIGGER then 'check for event that was sent
  2.  
  3. OPTION _EXPLICIT ' need to remove before publishing library!!
  4.  
  5. '*
  6. '* constant declarations
  7. '*
  8.  
  9. '         CONSTANT NAME                                DESCRIPTION                          FUNCTIONS / SUBROUTINES THAT MAY USE THIS CONSTANT
  10. ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  11. CONST SL_RESET = -32767 '               reset a function or subroutine                      SL_ROTATE_SPRITE, SL_FLIP_SPRITE, SL_ZOOM_SPRITE, SL_SET_AUTOROTATE, SL_SET_AUTOMOTION
  12. CONST SL_NOFLIP = 0 '                   sprite will use no flipping                         SL_FLIP_SPRITE
  13. CONST SL_HORIZONTAL = 1 '               sprite will be flipped horizontally                 SL_FLIP_SPRITE
  14. CONST SL_VERTICAL = 2 '                 sprite will be flipped vertically                   SL_FLIP_SPRITE
  15. CONST SL_FLIPBOTH = 3 '                 sprite will be flipped horizontally & vertically    SL_FLIP_SPRITE
  16. CONST SL_USESHEET = -1 '                use sheet's transparency info (.PNG)                SL_NEW_SHEET
  17. CONST SL_SET = 0 '                      manually set transparency                           SL_NEW_SHEET
  18. CONST SL_NONE = 1 '                     don't use transparency with sheet                   SL_NEW_SHEET
  19. CONST SL_NOSAVE = 0 '                   sprite will not save background                     SL_NEW_SPRITE, SL_SOFTWARE_SPRITE
  20. CONST SL_SAVE = -1 '                    sprite will save background                         SL_NEW_SPRITE, SL_SOFTWARE_SPRITE
  21. CONST SL_HARDWARE = 0 '                 sprite in hardware mode                             SL_NEW_SPRITE
  22. CONST SL_SOFTWARE = -1 '                sprite in software mode                             SL_NEW_SPRITE
  23. CONST SL_START = -1 '                   enable auto motion / rotation                       SL_SET_AUTOMOTION' SL_SET_AUTOROTATE
  24. CONST SL_STOP = 0 '                     disable auto motion / rotation                      SL_SET_AUTOMOTION, SL_SET_AUTOROTATE
  25.  
  26. '*
  27. '* type declarations
  28. '*
  29.  
  30. TYPE SL_SHEET ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ SPRITE SHEET DATABASE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  31.     image AS LONG '                     software sprite image
  32.     mask AS LONG '                      software mask image
  33.     spritewidth AS INTEGER '            width of sprite
  34.     spriteheight AS INTEGER '           height of sprite
  35.     collx1 AS INTEGER '                 collision box top left x
  36.     colly1 AS INTEGER '                 collision box top left y
  37.     collx2 AS INTEGER '                 collision box bottom right x
  38.     colly2 AS INTEGER '                 collision box bottom right y
  39.     transparency AS INTEGER '           -1 (TRUE) if sheet uses transparency
  40. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  41.  
  42. TYPE SL_SPRITE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ SPRITE DATABASE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  43.     inuse AS INTEGER '                  this array index in use
  44.     sheet AS INTEGER '                  sheet sprite belongs to
  45.     column AS INTEGER '                 the column on the sheet the sprite resides
  46.     row AS INTEGER '                    the row on the sheet the sprite resides
  47.     sprite AS LONG '                    hardware image
  48.     image AS LONG '                     software image
  49.     mask AS LONG '                      software mask image
  50.     spritewidth AS INTEGER '            width of sprite
  51.     spriteheight AS INTEGER '           height of sprite
  52.     background AS LONG '                background hardware image behind sprite
  53.     xreal AS SINGLE '                   x location of sprite (center point)
  54.     yreal AS SINGLE '                   y location of sprite (center point)
  55.     xint AS INTEGER '                   x location of sprite on screen INT(xreal) (center point)
  56.     yint AS INTEGER '                   y location of sprite on screen INT(yreal) (center point)
  57.     xactual AS INTEGER '                x location of sprite on screen (upper left x)
  58.     yactual AS INTEGER '                y location of sprite on screen (upper left y)
  59.     xback AS INTEGER '                  background image x location
  60.     yback AS INTEGER '                  background image y location
  61.     xdir AS SINGLE '                    direction of sprite in x axis
  62.     ydir AS SINGLE '                    direction of sprite in y axis
  63.     restore AS INTEGER '                -1 (true) if sprite restores background
  64.     collx1 AS INTEGER '                 collision box top left x
  65.     colly1 AS INTEGER '                 collision box top left y
  66.     collx2 AS INTEGER '                 collision box bottom right x
  67.     colly2 AS INTEGER '                 collision box bottom right y
  68.     flip AS INTEGER '                   flip horizontally, vertically, or both
  69.     rotation AS INTEGER '                rotation angle of sprite (0 - 359)
  70.     transparency AS INTEGER '           -1 (TRUE) if sprite uses transparency
  71.     zoom AS INTEGER '                   zoom level of sprite (1% - x%)
  72.     software AS INTEGER '               -1 (TRUE) if sprite is to be treated as software image
  73.     spin AS INTEGER '                   if other than zero the sprite will automatically spin
  74.     speed AS INTEGER '                  speed of sprite during motion
  75.     direction AS INTEGER '              the direction of sprite during motion (0 - 359)
  76.     automotion AS INTEGER '             -1 (TRUE) if automotion turned on
  77.     autorotate AS INTEGER '             -1 (TRUE) if auto rotation turned on
  78.  
  79. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  80.  
  81. TYPE SL_ROTATE 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ PRECALCULATED ROTATION TABLE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  82.     rwidth AS INTEGER '                 width of rotated sprite
  83.     rheight AS INTEGER '                height of rotated sprite
  84.     px0 AS INTEGER '                    rectangular rotation coordinates
  85.     px1 AS INTEGER
  86.     px2 AS INTEGER
  87.     px3 AS INTEGER
  88.     py0 AS INTEGER
  89.     py1 AS INTEGER
  90.     py2 AS INTEGER
  91.     py3 AS INTEGER
  92. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  93.  
  94. '*
  95. '* dynamic array declarations
  96. '*
  97.  
  98. REDIM SL_sheet(1, 1, 1) AS SL_SHEET '   master sprite sheet array
  99. REDIM SL_sprite(1) AS SL_SPRITE '       master working sprite array
  100. REDIM SL_rotate(1, 359) AS SL_ROTATE '  precalculated rotation values
  101.  
  102. '*
  103. '* main code (for testing)
  104. '*
  105.  
  106. DIM kongsheet AS INTEGER
  107. DIM mysprite AS INTEGER
  108. DIM mysprite2 AS INTEGER
  109. DIM angle AS INTEGER
  110.  
  111. kongsheet = SL_NEW_SHEET("dkong.png", 64, 64, SL_SET, _RGB32(255, 0, 255))
  112. mysprite = SL_NEW_SPRITE(kongsheet, 1, 1, SL_HARDWARE, SL_NOSAVE)
  113. mysprite2 = SL_NEW_SPRITE(kongsheet, 1, 1, SL_SOFTWARE, SL_NOSAVE)
  114.  
  115. 'SL_SET_ROTATION mysprite, 45
  116. 'SL_SET_ROTATION_SPEED mysprite, 1
  117. 'SL_SET_AUTOROTATE mysprite, SL_START
  118. 'SL_FLIP_SPRITE mysprite, SL_HORIZONTAL
  119. 'SL_SET_ZOOM mysprite, 125
  120.  
  121.  
  122.  
  123.  
  124. SCREEN _NEWIMAGE(640, 480, 32)
  125. CIRCLE (128, 128), 64, _RGB32(255, 255, 255)
  126. x = 128
  127. y = 128
  128.  
  129. SL_PUT_SPRITE 128, 128, mysprite2
  130.  
  131.     _LIMIT 30
  132.     angle = SL_Correct_Degree_Angle_To_360%(angle + 1)
  133.     '* angle = (angle + 1) MOD 360 ': IF angle = 360 THEN angle = 0
  134.     SL_SET_ROTATION mysprite, angle
  135.     SL_PUT_SPRITE x, y, mysprite
  136.     x = x + 1
  137.     'IF INT(x) = 300 THEN
  138.     '    SL_SET_SOFTWARE mysprite, SL_NOSAVE
  139.     'END IF
  140.     IF INT(x) = 401 THEN x = 400
  141.     _DISPLAY
  142.  
  143. SL_FREE_SPRITE mysprite
  144. SL_FREE_SPRITE mysprite2
  145.  
  146.  
  147.  
  148.  
  149.  
  150. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  151. SUB SL_UPDATE_AUTO_SPRITES () '                                                                                                                                                  SL_UPDATE_AUTO_SPRITES
  152.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  153.  
  154.     ' declare global variables
  155.  
  156.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  157.  
  158.     ' declare local variables
  159.  
  160.     DIM handle AS INTEGER '             handle of sprite
  161.  
  162.     ' local variable setup
  163.  
  164.     handle = 0 '                                                                                                initialize handle counter
  165.  
  166.     DO
  167.         handle = handle + 1
  168.         IF SL_sprite(handle).inuse THEN '                                                                       is this a valid sprite?
  169.             IF SL_sprite(handle).automotion THEN '                                                              yes, is auto motion enabled?
  170.                 SL_sprite(handle).xreal = SL_sprite(handle).xreal + SL_sprite(handle).xdir '                    yes, update x location
  171.                 SL_sprite(handle).yreal = SL_sprite(handle).yreal + SL_sprite(handle).ydir '                    update y location
  172.             END IF
  173.             IF SL_sprite(handle).autorotate THEN '                                                              is auto rotation enabled?
  174.                 SL_SET_ROTATION handle, SL_sprite(handle).rotation + SL_sprite(handle).spin '                   yes, rotate sprite to next degree angle
  175.             END IF
  176.             SL_PUT_SPRITE SL_sprite(handle).xreal, SL_sprite(handle).yreal, handle '                            update sprite location
  177.         END IF
  178.     LOOP UNTIL handle = UBOUND(SL_sprite) '                                                                     leave when all indexes checked
  179.  
  180.  
  181. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  182. SUB SL_MOVE_SPRITE (handle AS INTEGER) '                                                                                                                                                 SL_MOVE_SPRITE
  183.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  184.  
  185.     ' declare global variables
  186.  
  187.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  188.  
  189.     ' perform error checks
  190.  
  191.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  192.         SL_ERROR "SL_MOVE_SPRITE", 1, "" '                                                              no, report error to programmer
  193.     END IF
  194.     IF SL_sprite(handle).automotion THEN '                                                              attempt to move sprite under automatic control?
  195.         SL_ERROR "SL_MOVE_SPRITE", 170, "" '                                                            yes, report error to programmer
  196.     END IF
  197.  
  198.     SL_sprite(handle).xreal = SL_sprite(handle).xreal + SL_sprite(handle).xdir '                        update x location
  199.     SL_sprite(handle).yreal = SL_sprite(handle).yreal + SL_sprite(handle).ydir '                        update y location
  200.     SL_PUT_SPRITE SL_sprite(handle).xreal, SL_sprite(handle).yreal, handle '                            update sprite location
  201.  
  202.  
  203. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  204. SUB SL_ROTATE_SPRITE (handle AS INTEGER) '                                                                                                                                             SL_ROTATE_SPRITE
  205.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  206.  
  207.     ' declare global variables
  208.  
  209.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  210.  
  211.     ' perform error checks
  212.  
  213.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  214.         SL_ERROR "SL_ROTATE_SPRITE", 1, "" '                                                            no, report error to programmer
  215.     END IF
  216.     IF SL_sprite(handle).autorotate THEN '                                                              attempt to rotate sprite under automatic control?
  217.         SL_ERROR "SL_ROTATE_SPRITE", 180, "" '                                                          yes, report error to programmer
  218.     END IF
  219.  
  220.     SL_SET_ROTATION handle, SL_sprite(handle).rotation + SL_sprite(handle).spin '                       rotate sprite to next degree angle
  221.  
  222.  
  223. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  224. SUB SL_SET_DIRECTION (handle AS INTEGER, degrees AS INTEGER) '                                                                                                                         SL_SET_DIRECTION
  225.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  226.  
  227.     ' declare global variables
  228.  
  229.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  230.  
  231.     ' delcare local variables
  232.  
  233.     DIM degree AS INTEGER '             degree angle passed in
  234.  
  235.     ' perform error checks
  236.  
  237.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  238.         SL_ERROR "SL_SET_DIRECTION", 1, "" '                                                            no, report error to programmer
  239.     END IF
  240.  
  241.     ' Correct degree angle if needed (needs to be 0 - 359)
  242.     ' This code supplants the next now commented block
  243.     degree = SL_Correct_Degree_Angle_To_360%(degrees)
  244.  
  245.     'DIM moddegree360 AS INTEGER '                                                                      This value will always be BETWEEN -360 and 360 (ie: -359 to 359)
  246.     'moddegree360 = degree MOD 360
  247.     'IF moddegree360 < 0 THEN
  248.     '    degree = moddegree360 + 360
  249.     'ELSE
  250.     '    degree = moddegree360
  251.     'END IF
  252.  
  253.     'degree = degrees '                                                                                  get degree angle passed in
  254.     'IF degree = 360 THEN '                                                                              is it 360?
  255.     '    degree = 0 '                                                                                    yes, that's the same as 0
  256.     'ELSEIF degree < 0 THEN '                                                                            is it less than 360?
  257.     '    DO '                                                                                            yes
  258.     '        degree = degree + 360 '                                                                     increase by 360
  259.     '    LOOP UNTIL degree > 0 '                                                                         until it's in a valid range
  260.     'ELSEIF degree > 360 THEN '                                                                          is it greater than 360?
  261.     '    DO '                                                                                            yes
  262.     '        degree = degree - 360 '                                                                     decrease by 360
  263.     '    LOOP UNTIL degree < 360 '                                                                       until it's in a valid range
  264.     'END IF
  265.  
  266.     SL_sprite(handle).direction = degree '                                                              set motion degree angle
  267.     SL_sprite(handle).xdir = SIN(degree * 3.1415926 / 180) * SL_sprite(handle).speed '                  calculate x vector
  268.     SL_sprite(handle).ydir = -COS(degree * 3.1415926 / 180) * SL_sprite(handle).speed '                 calculate y vector
  269.  
  270.  
  271. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  272. FUNCTION SL_GET_DIRECTION (handle AS INTEGER) '                                                                                                                                        SL_GET_DIRECTION
  273.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  274.  
  275.     ' declare global variables
  276.  
  277.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  278.  
  279.     ' perform error checks
  280.  
  281.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  282.         SL_ERROR "SL_GET_DIRECTION", 1, "" '                                                            no, report error to programmer
  283.     END IF
  284.  
  285.     SL_GET_DIRECTION = SL_sprite(handle).direction '                                                    return direction sprite currently set to
  286.  
  287.  
  288. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  289. SUB SL_SET_MOTION_SPEED (handle AS INTEGER, speed AS SINGLE) '                                                                                                                      SL_SET_MOTION_SPEED
  290.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  291.  
  292.     ' declare global variables
  293.  
  294.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  295.  
  296.     ' perform error checks
  297.  
  298.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  299.         SL_ERROR "SL_SET_MOTION_SPEED", 1, "" '                                                         no, report error to programmer
  300.     END IF
  301.  
  302.     SL_sprite(handle).speed = speed '                                                                   set sprite motion speed
  303.  
  304.  
  305. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  306. FUNCTION SL_GET_MOTION_SPEED (handle AS INTEGER) '                                                                                                                                  SL_GET_MOTION_SPEED
  307.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  308.  
  309.     ' declare global variables
  310.  
  311.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  312.  
  313.     ' perform error checks
  314.  
  315.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  316.         SL_ERROR "SL_GET_MOTION_SPEED", 1, "" '                                                         no, report error to programmer
  317.     END IF
  318.  
  319.     SL_GET_MOTION_SPEED = SL_sprite(handle).speed '                                                     return current sprite motion speed
  320.  
  321.  
  322. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  323. SUB SL_SET_AUTOMOTION (handle AS INTEGER, motion AS INTEGER) '                                                                                                                        SL_SET_AUTOMOTION
  324.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  325.  
  326.     ' declare global variables
  327.  
  328.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  329.  
  330.     IF motion = -32767 THEN '                                                               (SL_RESET)  reset auto motion?
  331.         SL_sprite(handle).automotion = 0 '                                                     (FALSE)  yes, turn auto motion off
  332.         EXIT SUB '                                                                                      leave subroutine
  333.     END IF
  334.  
  335.     ' perform error checks
  336.  
  337.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  338.         SL_ERROR "SL_SET_AUTOMOTION", 1, "" '                                                           no, report error to programmer
  339.     END IF
  340.     IF motion < -1 OR motion > 0 THEN
  341.         SL_ERROR "SL_SET_AUTOMOTION", 150, ""
  342.     END IF
  343.  
  344.     SL_sprite(handle).automotion = motion '                                             (TRUE & FALSE)  set auto motion status
  345.  
  346.  
  347. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  348. FUNCTION SL_GET_AUTOMOTION (handle AS INTEGER) '                                                                                                                                      SL_GET_AUTOMOTION
  349.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  350.  
  351.     ' declare global variables
  352.  
  353.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  354.  
  355.     ' perform error checks
  356.  
  357.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  358.         SL_ERROR "SL_GET_AUTOMOTION", 1, "" '                                                           no, report error to programmer
  359.     END IF
  360.  
  361.     SL_GET_AUTOMOTION = SL_sprite(handle).automotion '                                  (TRUE & FALSE)  return auto motion status
  362.  
  363.  
  364. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  365. SUB SL_SET_AUTOROTATE (handle AS INTEGER, rotate AS INTEGER) '                                                                                                                        SL_SET_AUTOROTATE
  366.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  367.  
  368.     ' declare global variables
  369.  
  370.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  371.  
  372.     IF rotate = -32767 THEN '                                                               (SL_RESET)  reset auto rotate?
  373.         SL_sprite(handle).autorotate = 0 '                                                     (FALSE)  yes, turn auto rotation off
  374.         EXIT SUB '                                                                                      leave subroutine
  375.     END IF
  376.  
  377.     ' perform error checks
  378.  
  379.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  380.         SL_ERROR "SL_SET_AUTOROTATE", 1, "" '                                                           no, report error to programmer
  381.     END IF
  382.     IF rotate < -1 OR rotate > 0 THEN
  383.         SL_ERROR "SL_SET_AUTOROTATE", 160, ""
  384.     END IF
  385.  
  386.     SL_sprite(handle).autorotate = rotate '                                             (TRUE & FALSE)  set auto rotation status
  387.  
  388.  
  389. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  390. FUNCTION SL_GET_AUTOROTATE (handle AS INTEGER) '                                                                                                                                      SL_GET_AUTOROTATE
  391.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  392.  
  393.     ' declare global variables
  394.  
  395.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  396.  
  397.     ' perform error checks
  398.  
  399.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  400.         SL_ERROR "SL_GET_AUTOROTATE", 1, "" '                                                           no, report error to programmer
  401.     END IF
  402.  
  403.     SL_GET_AUTOROTATE = SL_sprite(handle).autorotate '                                  (TRUE & FALSE)  return auto rotation status
  404.  
  405.  
  406. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  407. SUB SL_SET_ROTATION_SPEED (handle AS INTEGER, degrees AS INTEGER) '                                                                                                               SL_SET_ROTATION_SPEED
  408.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  409.  
  410.     ' declare global variables
  411.  
  412.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  413.  
  414.     ' perform error checks
  415.  
  416.     IF degrees = -32767 THEN '                                                              (SL_RESET)  reset requested?
  417.         SL_sprite(handle).spin = 0 '                                                         (SL_STOP)  turn auto spin off
  418.         EXIT SUB '                                                                                      leave subroutine
  419.     END IF
  420.  
  421.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  422.         SL_ERROR "SL_SET_ROTATION_SPEED", 1, "" '                                                       no, report error to programmer
  423.     END IF
  424.     IF ABS(degrees) > 359 THEN '                                                                        degree requested between -359 and 359?
  425.         SL_ERROR "SL_SET_ROTATION_SPEED", 140, "" '                                                     no, report error to programmer
  426.     END IF
  427.  
  428.     SL_sprite(handle).spin = degrees '                                                                  set sprite spin rate
  429.  
  430.  
  431. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  432. FUNCTION SL_GET_ROTATION_SPEED (handle AS INTEGER) '                                                                                                                              SL_GET_ROTATION_SPEED
  433.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  434.  
  435.     ' declare global variables
  436.  
  437.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  438.  
  439.     ' perform error checks
  440.  
  441.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  442.         SL_ERROR "SL_GET_ROTATION_SPEED", 1, "" '                                                       no, report error to programmer
  443.     END IF
  444.  
  445.     SL_GET_ROTATION_SPEED = SL_sprite(handle).spin '                                                    return current sprite spin rate
  446.  
  447.  
  448. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  449. 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
  450.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  451.  
  452.     'declare local variables
  453.  
  454.     DIM a AS INTEGER '                  side a of triangle
  455.     DIM b AS INTEGER '                  side b of triangle
  456.  
  457.     'solve for c (hypotenuse)
  458.  
  459.     a = x1 - x2 '                                                                                       get length of side a
  460.     b = y1 = y2 '                                                                                       get length of side b
  461.  
  462.     SL_GET_DISTANCE_POINT_TO_POINT = INT(SQR(a * a + b * b)) '                                          return length of side c
  463.  
  464.  
  465. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  466. FUNCTION SL_GET_DISTANCE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                 SL_GET_DISTANCE_TO_SPRITE
  467.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  468.  
  469.     ' declare global variables
  470.  
  471.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  472.  
  473.     'perform error checks
  474.  
  475.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  476.         SL_ERROR "SL_GET_DISTANCE_TO_SPRITE", 1, "" '                                                   no, report error to programmer
  477.     END IF
  478.  
  479.     SL_GET_DISTANCE_TO_SPRITE = SL_GET_DISTANCE_POINT_TO_POINT(SL_sprite(handle1).xint, SL_sprite(handle1).yint, _
  480.                                                                SL_sprite(handle2).xint, SL_sprite(handle2).yint) '  return distance to sprite 2
  481.  
  482.  
  483. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  484. FUNCTION SL_GET_DISTANCE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                                                            SL_GET_DISTANCE_TO_POINT
  485.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  486.  
  487.     ' declare global variables
  488.  
  489.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  490.  
  491.     'perform error checks
  492.  
  493.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  494.         SL_ERROR "SL_GET_DISTANCE_TO_POINT", 1, "" '                                                    no, report error to programmer
  495.     END IF
  496.  
  497.     SL_GET_DISTANCE_TO_POINT = SL_GET_DISTANCE_POINT_TO_POINT(SL_sprite(handle).xint, SL_sprite(handle).yint, x, y) ' return distance to point
  498.  
  499.  
  500. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  501. 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
  502.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  503.  
  504.     'declare local variables
  505.  
  506.     DIM angle AS INTEGER '              angle from first x,y location to second x,y location
  507.  
  508.     IF y1 = y2 THEN '                                                                                   both y values same?
  509.         IF x1 = x2 THEN '                                                                               yes, both x values same?
  510.             EXIT FUNCTION '                                                                             yes, there is no angle (0), leave
  511.         END IF
  512.         IF x2 > x1 THEN '                                                                               is second x to the right of first x?
  513.             SL_GET_ANGLE_POINT_TO_POINT = 90 '                                                          yes, the angle must be 90 degrees
  514.         ELSE '                                                                                          no, second x is to the left of first x
  515.             SL_GET_ANGLE_POINT_TO_POINT = 270 '                                                         the angle must be 270 degrees
  516.         END IF
  517.         EXIT FUNCTION '                                                                                 leave function, angle computed
  518.     END IF
  519.     IF x1 = x2 THEN '                                                                                   both x values same?
  520.         IF y2 > y1 THEN '                                                                               yes, is second y lower than first y?
  521.             SL_GET_ANGLE_POINT_TO_POINT = 180 '                                                         yes, the angle must be 180
  522.         END IF
  523.         EXIT FUNCTION '                                                                                 leave function, angle computed (angle is 0 if no calculation done)
  524.     END IF
  525.     angle = ATN((x2 - x1) / (y2 - y1)) * -57.2957795131 '                                               calculate initial angle
  526.     IF y2 < y1 THEN '                                                                                   is second y higher than first y?
  527.         IF x2 > x1 THEN '                                                                               yes, is second x to right of first x?
  528.             SL_GET_ANGLE_POINT_TO_POINT = angle '                                                       yes, angle needs no adjustment
  529.         ELSE '                                                                                          no, second x is to left of first x
  530.             SL_GET_ANGLE_POINT_TO_POINT = angle + 360 '                                                 adjust angle accordingly
  531.         END IF
  532.     ELSE '                                                                                              no, second y is lower than first y
  533.         SL_GET_ANGLE_POINT_TO_POINT = angle + 180 '                                                     adjust angle accordingly
  534.     END IF
  535.  
  536.  
  537. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  538. FUNCTION SL_GET_ANGLE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                       SL_GET_ANGLE_TO_SPRITE
  539.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  540.  
  541.     ' declare global variables
  542.  
  543.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  544.  
  545.     'perform error checks
  546.  
  547.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  548.         SL_ERROR "SL_GET_ANGLE_TO_SPRITE", 1, "" '                                                      no, report error to programmer
  549.     END IF
  550.  
  551.     SL_GET_ANGLE_TO_SPRITE = SL_GET_ANGLE_POINT_TO_POINT(SL_sprite(handle1).xint, SL_sprite(handle1).yint, _
  552.                                                          SL_sprite(handle2).xint, SL_sprite(handle2).yint) ' return angle to sprite 2
  553.  
  554.  
  555. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  556. FUNCTION SL_GET_ANGLE_FROM_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                   SL_GET_ANGLE_FROM_SPRITE
  557.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  558.  
  559.     ' declare global variables
  560.  
  561.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  562.  
  563.     'perform error checks
  564.  
  565.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  566.         SL_ERROR "SL_GET_ANGLE_FROM_SPRITE", 1, "" '                                                    no, report error to programmer
  567.     END IF
  568.  
  569.     SL_GET_ANGLE_FROM_SPRITE = SL_GET_ANGLE_POINT_TO_POINT(SL_sprite(handle2).xint, SL_sprite(handle2).yint, _
  570.                                                            SL_sprite(handle1).xint, SL_sprite(handle1).yint) '  return angle from sprite 2
  571.  
  572.  
  573. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  574. FUNCTION SL_GET_ANGLE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                                                                  SL_GET_ANGLE_TO_POINT
  575.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  576.  
  577.     ' declare global variables
  578.  
  579.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  580.  
  581.     'perform error checks
  582.  
  583.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  584.         SL_ERROR "SL_GET_ANGLE_TO_POINT", 1, "" '                                                       no, report error to programmer
  585.     END IF
  586.  
  587.     SL_GET_ANGLE_TO_POINT = SL_GET_ANGLE_POINT_TO_POINT(SL_sprite(handle).xint, SL_sprite(handle).yint, x, y) ' return angle to point x,y
  588.  
  589.  
  590. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  591. FUNCTION SL_GET_ANGLE_FROM_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                                                              SL_GET_ANGLE_FROM_POINT
  592.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  593.  
  594.     ' declare global variables
  595.  
  596.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  597.  
  598.     'perform error checks
  599.  
  600.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  601.         SL_ERROR "SL_GET_ANGLE_FROM_POINT", 1, "" '                                                     no, report error to programmer
  602.     END IF
  603.  
  604.     SL_GET_ANGLE_FROM_POINT = SL_GET_ANGLE_POINT_TO_POINT(x, y, SL_sprite(handle).xint, SL_sprite(handle).yint) 'return angle from point x,y
  605.  
  606.  
  607. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  608. SUB SL_SET_SOFTWARE (handle AS INTEGER, restores AS INTEGER) '                                                                                                                          SL_SET_SOFTWARE
  609.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  610.  
  611.     ' declare global variables
  612.  
  613.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  614.  
  615.     'perform error checks
  616.  
  617.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  618.         SL_ERROR "SL_SET_SOFTWARE", 1, "" '                                                             no, report error to programmer
  619.     END IF
  620.     IF restores < -1 OR restores > 0 THEN '                                                             valid background restoration behavior requested?
  621.         SL_ERROR "SL_SET_SOFTWARE", 2, "" '                                                             no, report error to programmer
  622.     END IF
  623.  
  624.     SL_sprite(handle).software = -1 '                                                    (SL_SOFTWARE)  set sprite to software mode
  625.     SL_sprite(handle).restore = restores '                                       (SL_SAVE & SL_NOSAVE)  set background saving behavior
  626.  
  627.  
  628. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  629. SUB SL_SET_HARDWARE (handle AS INTEGER) '                                                                                                                                               SL_SET_HARDWARE
  630.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  631.  
  632.     ' declare global variables
  633.  
  634.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  635.  
  636.     'perform error checks
  637.  
  638.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  639.         SL_ERROR "SL_SET_HARDWARE", 1, "" '                                                             no, report error to programmer
  640.     END IF
  641.  
  642.     SL_sprite(handle).software = 0 '                                                     (SL_HARDWARE)  set sprite to hardware mode
  643.  
  644.  
  645. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  646. SUB SL_SET_ZOOM (handle AS INTEGER, zoom AS INTEGER) '                                                                                                                                      SL_SET_ZOOM
  647.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  648.  
  649.     ' declare global variables
  650.  
  651.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  652.  
  653.     IF zoom = -32767 THEN '                                                                 (SL_RESET)  reset zoom level?
  654.         SL_sprite(handle).zoom = 100 '                                                                  yes, reset level to normal
  655.         EXIT SUB '                                                                                      leave subroutine
  656.     END IF
  657.  
  658.     ' perform error checks (errors 130-139)
  659.  
  660.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  661.         SL_ERROR "SL_SET_ZOOM", 1, "" '                                                                 no, report error to programmer
  662.     END IF
  663.     IF zoom < 1 THEN '                                                                                  valid zoom level requested?
  664.         SL_ERROR "SL_SET_ZOOM", 130, "" '                                                               no, report error to programmer
  665.     END IF
  666.  
  667.     SL_sprite(handle).zoom = zoom '                                                                     set zoom level
  668.  
  669.  
  670.  
  671. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  672. SUB SL_SET_ROTATION (handle AS INTEGER, degrees AS INTEGER) '                                                                                                                           SL_SET_ROTATION
  673.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  674.  
  675.     ' declare global variables
  676.  
  677.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  678.  
  679.     ' declare local variables
  680.  
  681.     DIM degree AS INTEGER '             degree angle passed in
  682.  
  683.     ' perform error checks
  684.  
  685.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  686.         SL_ERROR "SL_SET_ROTATION", 1, "" '                                                             no, report error to programmer
  687.     END IF
  688.  
  689.     degree = degrees '                                                                                  get degree angle passed in
  690.  
  691.     'handle reset request
  692.  
  693.     IF degree = -32767 THEN '                                                               (SL_RESET)  reset sprite rotation?
  694.         SL_sprite(handle).rotation = 0 '                                                                reset rotation angle
  695.         EXIT SUB '                                                                                      leave subroutine
  696.     END IF
  697.  
  698.     ' correct degree angle if needed (needs to be 0 - 359)
  699.     degree = SL_Correct_Degree_Angle_To_360%(degree)
  700.     'IF degree = 360 THEN '                                                                              is it 360?
  701.     '    degree = 0 '                                                                                    yes, that's the same as 0
  702.     'ELSEIF degree < 0 THEN '                                                                            is it less than 360?
  703.     '    DO '                                                                                            yes
  704.     '        degree = degree + 360 '                                                                     increase by 360
  705.     '    LOOP UNTIL degree > 0 '                                                                         until it's in a valid range
  706.     'ELSEIF degree > 360 THEN '                                                                          is it greater than 360?
  707.     '    DO '                                                                                            yes
  708.     '        degree = degree - 360 '                                                                     decrease by 360
  709.     '    LOOP UNTIL degree < 360 '                                                                       until it's in a valid range
  710.     'END IF
  711.  
  712.     SL_sprite(handle).rotation = degree '                                                               set degree of rotation
  713.  
  714.  
  715. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  716. SUB SL_FLIP_SPRITE (handle AS INTEGER, flip AS INTEGER) '                                                                                                                                SL_FLIP_SPRITE
  717.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  718.  
  719.     ' declare global variables
  720.  
  721.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  722.  
  723.     ' check for subroutine reset
  724.  
  725.     IF flip = -32767 THEN '                                                                 (SL_RESET)  reset flipping behavior?
  726.         SL_sprite(handle).flip = 0 '                                                       (SL_NOFLIP)  yes, reset flip value
  727.         EXIT SUB '                                                                                      leave subroutine
  728.     END IF
  729.  
  730.     ' perform error checks
  731.  
  732.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  733.         SL_ERROR "SL_FLIP_SPRITE", 1, "" '                                                              no, report error to programmer
  734.     END IF
  735.     IF flip < 0 OR flip > 3 THEN '                                                                      valid flip behavior requested?
  736.         SL_ERROR "SL_FLIP_SPRITE", 120, "" '                                                            no, report error to programmer
  737.     END IF
  738.  
  739.     SL_sprite(handle).flip = flip '                                                                     set flipping behavior
  740.  
  741.  
  742. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  743. SUB SL_PUT_SPRITE (x AS SINGLE, y AS SINGLE, handle AS INTEGER) '                                                                                                                         SL_PUT_SPRITE
  744.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  745.  
  746.     ' declare global variables
  747.  
  748.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  749.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  750.     SHARED SL_rotate() AS SL_ROTATE '   precalculated rotation table
  751.  
  752.     ' declare local variables
  753.  
  754.     DIM xa AS INTEGER '                 actual x location of sprite on screen
  755.     DIM ya AS INTEGER '                 actual y location of sprite on screen
  756.     DIM sw AS INTEGER '                 width of sprite to be drawn
  757.     DIM sh AS INTEGER '                 height of sprite to be drawn
  758.     DIM rw AS INTEGER '                 precalculated rotated sprite width
  759.     DIM rh AS INTEGER '                 precalculated rotated sprite height
  760.     DIM px0 AS INTEGER '                precalculated triangular coordinates
  761.     DIM px1 AS INTEGER
  762.     DIM px2 AS INTEGER
  763.     DIM px3 AS INTEGER
  764.     DIM py0 AS INTEGER
  765.     DIM py1 AS INTEGER
  766.     DIM py2 AS INTEGER
  767.     DIM py3 AS INTEGER
  768.     DIM image AS LONG '                 software sprite image
  769.     DIM mask AS LONG '                  software sprite image mask
  770.     DIM sprite AS LONG '                hardware sprite image
  771.  
  772.     ' perform error checks
  773.  
  774.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  775.         SL_ERROR "SL_PUT_SPRITE", 1, "" '                                                               no, report error to programmer
  776.     END IF
  777.  
  778.     ' check for auto motion
  779.  
  780.     'IF SL_sprite(handle).automotion THEN '                                                              is this sprite auto motion?
  781.     '    EXIT SUB '                                                                                      yes, SL_UPDATE_AUTO_SPRITES handles it, leave subroutine
  782.     'END IF
  783.  
  784.     'local variable setup
  785.  
  786.     SL_sprite(handle).xreal = x '                                                             (SINGLE)  save requested x center location
  787.     SL_sprite(handle).yreal = y '                                                             (SINGLE)  save requested y center location
  788.     SL_sprite(handle).xint = INT(x) '                                                        (INTEGER)  save screen x center location
  789.     SL_sprite(handle).yint = INT(y) '                                                        (INTEGER)  save screen y center location
  790.     image = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).image '  get image from sprite sheet
  791.     mask = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).mask '    get mask from sprite sheet
  792.     sw = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).spritewidth 'get default sprite width from sprite sheet
  793.     sh = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).spriteheight 'get default sprite height from sprite sheet
  794.  
  795.     'free existing images
  796.  
  797.     _FREEIMAGE SL_sprite(handle).sprite '                                                               free hardware sprite image
  798.     _FREEIMAGE SL_sprite(handle).image '                                                                free software sprite image
  799.     IF SL_sprite(handle).mask THEN _FREEIMAGE SL_sprite(handle).mask '                                  free software mask image
  800.     IF SL_sprite(handle).restore THEN '                                                                 is sprite holding a background image?
  801.         IF SL_sprite(handle).background THEN '                                                          yes, has a background image been saved yet?
  802.             _PUTIMAGE (SL_sprite(handle).xback, SL_sprite(handle).yback), SL_sprite(handle).background 'yes, replace background with image
  803.             _FREEIMAGE SL_sprite(handle).background '                                                   free hardware background image
  804.         END IF
  805.         IF NOT SL_sprite(handle).software THEN '                                                        was the sprite type changed?
  806.             SL_sprite(handle).restore = 0 '                                                (SL_NOSAVE)  yes, stop saving background
  807.         END IF
  808.     END IF
  809.  
  810.     'adjust sprite rotation if needed
  811.  
  812.     IF SL_sprite(handle).rotation THEN '                                                                rotate sprite?
  813.         px0 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).px0 '                      yes, get precalculated triangular coordinates
  814.         px1 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).px1
  815.         px2 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).px2
  816.         px3 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).px3
  817.         py0 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).py0
  818.         py1 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).py1
  819.         py2 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).py2
  820.         py3 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).py3
  821.         rw = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).rwidth '                    get precalculated rotated sprite width
  822.         rh = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation).rheight '                   get precalculated rotated sprite height
  823.         SL_sprite(handle).image = _NEWIMAGE(rw, rh, 32) '                                               create image using precalculated width/height
  824.         _MAPTRIANGLE (0, 0)-(0, sh-1)-(sw-1, sh-1), image TO _
  825.                      (px0, py0)-(px1, py1)-(px2, py2), SL_sprite(handle).image '                        map rotated sprite onto image
  826.         _MAPTRIANGLE (0, 0)-(sw-1, 0)-(sw-1, sh-1), image TO _
  827.                      (px0, py0)-(px3, py3)-(px2, py2), SL_sprite(handle).image
  828.         IF SL_sprite(handle).transparency THEN '                                                        does this sprite have a mask?
  829.             SL_sprite(handle).mask = _NEWIMAGE(rw, rh, 32) '                                            yes, create mask image
  830.             _MAPTRIANGLE (0, 0)-(0, sh-1)-(sw-1, sh-1), mask TO _
  831.                          (px0, py0)-(px1, py1)-(px2, py2), SL_sprite(handle).mask '                     map rotated mask onto image
  832.             _MAPTRIANGLE (0, 0)-(sw-1, 0)-(sw-1, sh-1), mask TO _
  833.                          (px0, py0)-(px3, py3)-(px2, py2), SL_sprite(handle).mask
  834.         END IF
  835.         sw = rw '                                                                                       save new sprite width
  836.         sh = rh '                                                                                       save new sprite height
  837.     ELSE '                                                                                              no rotation needed
  838.         SL_sprite(handle).image = _COPYIMAGE(image, 32) '                                               copy software image from sprite sheet
  839.         IF SL_sprite(handle).transparency THEN '                                                        does this sprite have a mask?
  840.             SL_sprite(handle).mask = _COPYIMAGE(mask, 32) '                                             yes, copy software mask from sprite sheet
  841.         END IF
  842.     END IF
  843.  
  844.     'create hardware sprite
  845.  
  846.     SL_sprite(handle).sprite = _COPYIMAGE(SL_sprite(handle).image, 33) '                                create hardware sprite of image
  847.  
  848.     'adjust zoom level if needed
  849.  
  850.     IF SL_sprite(handle).zoom <> 100 THEN '                                                             zoom sprite in/out?
  851.         sw = sw * SL_sprite(handle).zoom \ 100 '                                                        yes, calculate new zoom width
  852.         sh = sh * SL_sprite(handle).zoom \ 100 '                                                        calculate new zoom height
  853.     END IF
  854.  
  855.     'calculate actual sprite screen coordinates
  856.  
  857.     xa = SL_sprite(handle).xint - sw \ 2 '                                                              calculate actual screen x location from center
  858.     ya = SL_sprite(handle).yint - sh \ 2 '                                                              calculate actual screen y location from center
  859.     SL_sprite(handle).xactual = xa '                                                         (INTEGER)  save actual screen x location
  860.     SL_sprite(handle).yactual = ya '                                                         (INTEGER)  save actual screen y location
  861.  
  862.     'get background image before placing sprite if necessary
  863.  
  864.     IF SL_sprite(handle).restore THEN '                                                                 is this sprite storing background images?
  865.         SL_sprite(handle).background = _NEWIMAGE(sw, sh, 32) '                                          yes, create background image
  866.         _PUTIMAGE , _DEST, SL_sprite(handle).background, (xa, ya)-(xa + sw - 1, ya + sh - 1) '          get background area from current destination
  867.         SL_sprite(handle).xback = xa '                                                                  record background x location
  868.         SL_sprite(handle).yback = ya '                                                                  record background y location
  869.     END IF
  870.  
  871.     'use hardware or software image
  872.  
  873.     IF SL_sprite(handle).software THEN '                                                                is this a software sprite?
  874.         sprite = SL_sprite(handle).image '                                                              yes, use the software image
  875.     ELSE '                                                                                              no
  876.         sprite = SL_sprite(handle).sprite '                                                             use the hardware image
  877.     END IF
  878.  
  879.     ' place sprite on the current destination
  880.  
  881.     SELECT CASE SL_sprite(handle).flip '                                                                which flipping style is selected?
  882.         CASE 0 '                                                                           (SL_NOFLIP)  normal, no flipping
  883.             _PUTIMAGE (xa, ya)-(xa + sw - 1, ya + sh - 1), sprite '                                     draw normal sprite
  884.         CASE 1 '                                                                       (SL_HORIZONTAL)  flip horizontally
  885.             _PUTIMAGE (xa + sw - 1, ya)-(xa, ya + sh - 1), sprite '                                     draw horizontally flipped sprite
  886.         CASE 2 '                                                                         (SL_VERTICAL)  flip vertically
  887.             _PUTIMAGE (xa, ya + sh - 1)-(xa + sw - 1, ya), sprite '                                     draw vertically flipped sprite
  888.         CASE 3 '                                                                         (SL_FLIPBOTH)  flip vertically and horizontally
  889.             _PUTIMAGE (xa + sw - 1, ya + sh - 1)-(xa, ya), sprite '                                     draw horizontally and vertically flipped sprite
  890.     END SELECT
  891.  
  892.  
  893. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  894. FUNCTION SL_NEW_SPRITE (sheet AS INTEGER, column AS INTEGER, row AS INTEGER, software AS INTEGER, restores AS INTEGER) '                                                                  SL_NEW_SPRITE
  895.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  896.  
  897.     ' declare global variables
  898.  
  899.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  900.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  901.  
  902.     ' declare local variables
  903.  
  904.     DIM handle AS INTEGER '             handle (pointer) number of new sprite
  905.  
  906.     ' perform error checks
  907.  
  908.     IF sheet > UBOUND(SL_sheet) OR SL_sheet(sheet, 0, 0).image <> -1 THEN '                             valid sprite sheet requested?
  909.         SL_ERROR "SL_NEW_SPRITE", 110, "" '                                                             no, report error to programmer
  910.     END IF
  911.     IF column > UBOUND(SL_sheet, 2) OR row > UBOUND(SL_sheet, 3) OR row < 1 OR column < 1 THEN '        valid row and column requested?
  912.         SL_ERROR "SL_NEW_SPRITE", 111, "" '                                                             no, report error to programmer
  913.     END IF
  914.     IF restores < -1 OR restores > 0 THEN '                                                             valid background restoration behavior requested?
  915.         SL_ERROR "SL_NEW_SPRITE", 2, "" '                                                               no, report error to programmer
  916.     END IF
  917.     IF software < -1 OR software > 0 THEN '                                                             valid hardware / software setting requested?
  918.         SL_ERROR "SL_NEW_SPRITE", 112, "" '                                                             no, report error to programmer
  919.     END IF
  920.     IF (NOT software) AND restores THEN '                                                               hardware image that restores background?
  921.         SL_ERROR "SL_NEW_SPRITE", 113, "" '                                                             yes, report error to programmer
  922.     END IF
  923.  
  924.     ' local variable setup
  925.  
  926.     handle = 0 '                                                                                        initialize handle value
  927.  
  928.     ' increase sprite array's size if needed
  929.  
  930.     DO '                                                                                                look for next available handle
  931.         handle = handle + 1 '                                                                           increment to next handle value
  932.     LOOP UNTIL (NOT SL_sprite(handle).inuse) OR handle = UBOUND(SL_sprite) '                            stop looking when valid handle found
  933.     IF SL_sprite(handle).inuse THEN '                                                                   is the last array element in use?
  934.         handle = handle + 1 '                                                                           yes, increment to next handle value
  935.         REDIM _PRESERVE SL_sprite(handle) AS SL_SPRITE '                                                increase the size of the sprite array
  936.     END IF
  937.  
  938.     ' populate sprite array
  939.  
  940.     SL_sprite(handle).inuse = -1 '                                                              (TRUE)  mark array index as in use
  941.     SL_sprite(handle).sheet = sheet '                                                                   point to sheet where sprite resides              *
  942.     SL_sprite(handle).column = column '                                                                 point to column on sheet where sprite located    * these still needed?
  943.     SL_sprite(handle).row = row '                                                                       point to row on sheet where sprite located       *
  944.     SL_sprite(handle).software = software '                                (SL_SOFTWARE & SL_HARDWARE)  sprite treated as software or hardware image
  945.     SL_sprite(handle).restore = restores '                                       (SL_SAVE & SL_NOSAVE)  background restore behavior of sprite
  946.     SL_sprite(handle).background = 0 '                                                                  no background image saved yet
  947.     SL_sprite(handle).xreal = 0 '                                                                       reset x location of sprite (center x)
  948.     SL_sprite(handle).yreal = 0 '                                                                       reset y location of sprite (center y)
  949.     SL_sprite(handle).xint = 0 '                                                                        reset x location of sprite on screen INT(xreal) (center x)
  950.     SL_sprite(handle).yint = 0 '                                                                        reset y location of sprite on screen INT(yreal) (center y)
  951.     SL_sprite(handle).xactual = 0 '                                                                     reset x location of sprite on screen (upper left x)
  952.     SL_sprite(handle).yactual = 0 '                                                                     reset y location of sprite on screen (upper left y)
  953.     SL_sprite(handle).collx1 = SL_sheet(sheet, column, row).collx1 '                                    get sprite's collision box boundaries
  954.     SL_sprite(handle).colly1 = SL_sheet(sheet, column, row).colly1
  955.     SL_sprite(handle).collx2 = SL_sheet(sheet, column, row).collx2
  956.     SL_sprite(handle).colly2 = SL_sheet(sheet, column, row).colly2
  957.     SL_sprite(handle).spritewidth = SL_sheet(sheet, column, row).spritewidth '                          get width of sprite
  958.     SL_sprite(handle).spriteheight = SL_sheet(sheet, column, row).spriteheight '                        get height of sprite
  959.     SL_sprite(handle).sprite = _COPYIMAGE(SL_sheet(sheet, column, row).image, 33) '                     create hardware sprite image
  960.     SL_sprite(handle).image = _COPYIMAGE(SL_sheet(sheet, column, row).image, 32) '                      copy software sprite image from sheet
  961.     IF SL_sheet(sheet, column, row).transparency THEN '                                                 does this sprite use transparency?
  962.         SL_sprite(handle).mask = _COPYIMAGE(SL_sheet(sheet, column, row).mask, 32) '                    yes, copy software sprite mask image from sheet
  963.         SL_sprite(handle).transparency = -1 '                                                   (TRUE)  remember this sprite has a transparency layer
  964.     ELSE '                                                                                              no transparency
  965.         SL_sprite(handle).mask = 0 '                                                                    no mask will be brought in
  966.         SL_sprite(handle).transparency = 0 '                                                   (FALSE)  remember this sprite has no transparency layer
  967.     END IF
  968.     SL_sprite(handle).flip = 0 '                                                                        no sprite flipping
  969.     SL_sprite(handle).rotation = 0 '                                                                    no sprite rotation angle
  970.     SL_sprite(handle).zoom = 100 '                                                                      zoom normal at 100%
  971.     SL_sprite(handle).spin = 0 '                                                                        sprite will not spin automatically
  972.     SL_sprite(handle).xdir = 0 '                                                                        x direction during motion
  973.     SL_sprite(handle).ydir = 0 '                                                                        y direction during motion
  974.     SL_sprite(handle).speed = 0 '                                                                       speed during motion
  975.     SL_sprite(handle).direction = 0 '                                                                   direction during motion (0 - 359)
  976.     SL_sprite(handle).automotion = 0 '                                                         (FALSE)  auto motion disabled
  977.     SL_sprite(handle).autorotate = 0 '                                                         (FALSE)  auto rotation disabled
  978.  
  979.     SL_NEW_SPRITE = handle '                                                                            return pointer value of new sprite
  980.  
  981.  
  982. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  983. SUB SL_FREE_SPRITE (handle AS INTEGER) '                                                                                                                                                 SL_FREE_SPRITE
  984.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  985.  
  986.     ' declare global variables
  987.  
  988.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  989.  
  990.     ' check for errors
  991.  
  992.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  993.         SL_ERROR "SL_PUT_SPRITE", 1, "" '                                                               no, report error to programmer
  994.     END IF
  995.  
  996.     ' restore background if this sprite saving background
  997.  
  998.     IF SL_sprite(handle).restore THEN '                                                                 is there a background image to restore?
  999.         _PUTIMAGE (SL_sprite(handle).xback, SL_sprite(handle).yback), SL_sprite(handle).background '    yes, restore the image
  1000.         _FREEIMAGE SL_sprite(handle).background '                                                       free background image
  1001.     END IF
  1002.  
  1003.     ' free all image data associated with sprite
  1004.  
  1005.     IF SL_sprite(handle).background THEN _FREEIMAGE SL_sprite(handle).background '                      free background image if present
  1006.     IF SL_sprite(handle).mask THEN _FREEIMAGE SL_sprite(handle).mask '                                  free sprite mask image if present
  1007.     _FREEIMAGE SL_sprite(handle).sprite '                                                               free hardware sprite image
  1008.     _FREEIMAGE SL_sprite(handle).image '                                                                free software sprite image
  1009.  
  1010.     IF handle = UBOUND(sl_sprite) AND handle <> 1 THEN '                                                is handle the last element in array?
  1011.         REDIM _PRESERVE SL_sprite(handle - 1) AS SL_SPRITE '                                            yes, remove index and resize array
  1012.     ELSE '                                                                                              no, index somewhere else
  1013.         SL_sprite(handle).inuse = 0 '                                                          (FALSE)  mark index as usable later
  1014.     END IF
  1015.  
  1016.  
  1017. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1018. FUNCTION SL_NEW_SHEET (filename AS STRING, spritewidth AS INTEGER, spriteheight AS INTEGER, transparency AS INTEGER, transcolor AS _UNSIGNED LONG) '                                       SL_NEW_SHEET
  1019.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1020.  
  1021.     ' declare global variables
  1022.  
  1023.     SHARED SL_sheet() AS SL_SHEET '    master sprite sheet array
  1024.     SHARED SL_rotate() AS SL_ROTATE '  precalculated rotation table
  1025.  
  1026.     ' declare local variables
  1027.  
  1028.     DIM handle AS INTEGER '             handle (pointer) number of new sprite sheet
  1029.     DIM x AS INTEGER '                  generic counter to cycle through sheet sprite columns
  1030.     DIM y AS INTEGER '                  generic counter to cycle through sheet sprite rows
  1031.     DIM x1 AS INTEGER '                 generic counter to cycle though sprite for collision boundaries and mask creation
  1032.     DIM y1 AS INTEGER '                 generic ocunter to cycle though sprite for collision boundaries and mask creation
  1033.     DIM osource AS LONG '               original source image before this function was called
  1034.     DIM odest AS LONG '                 original destination image before this function was called
  1035.     DIM pixel AS _UNSIGNED LONG '       pixel color at each coordinate in sprite sheet
  1036.     DIM alpha AS _UNSIGNED LONG '       alpha level of current pixel
  1037.     DIM top AS INTEGER '                upper boundary of sprite image
  1038.     DIM bottom AS INTEGER '             lower boundary of sprite image
  1039.     DIM left AS INTEGER '               left boundary of sprite image
  1040.     DIM right AS INTEGER '              right boundary of sprite image
  1041.     DIM sheetimage AS LONG '            sprite sheet image
  1042.     DIM sheetwidth AS INTEGER '         width of sprite sheet in pixels
  1043.     DIM sheetheight AS INTEGER '        height of sprite sheet in pixels
  1044.     DIM rows AS INTEGER '               number of sprite rows contained on sheet
  1045.     DIM columns AS INTEGER '            number of sprite columns contained on sheet
  1046.     DIM clearcolor AS _UNSIGNED LONG '  transcolor passed in will be modified
  1047.     DIM tempsprite AS LONG '            temporary sprite for _CLEARCOLOR detection
  1048.     DIM px(3) AS DOUBLE '               polar x coordinates of maptriangle
  1049.     DIM py(3) AS DOUBLE '               polar y coordinates of maptriangle
  1050.     DIM sinr AS DOUBLE '                sin rotation calculation
  1051.     DIM cosr AS DOUBLE '                cosine rotation claculation
  1052.     DIM bx1 AS DOUBLE '                 max boundaries of rotated sprite
  1053.     DIM bx2 AS DOUBLE
  1054.     DIM by1 AS DOUBLE
  1055.     DIM by2 AS DOUBLE
  1056.     DIM x2 AS DOUBLE '                  new computed polar coordinates
  1057.     DIM y2 AS DOUBLE
  1058.  
  1059.     ' perform error checks
  1060.  
  1061.     IF NOT _FILEEXISTS(filename) THEN '                                                                 does the sprite sheet exist?
  1062.         SL_ERROR "SL_NEW_SHEET", 100, filename '                                                        no, report error to programmer
  1063.     END IF
  1064.     IF ABS(transparency) > 1 THEN '                                                                     valid transparency setting?
  1065.         SL_ERROR "SL_NEW_SHEET", 101, "" '                                                              no, report error to programmer
  1066.     END IF
  1067.     IF spritewidth < 1 OR spriteheight < 1 THEN '                                                       valid sprite width/height supplied?
  1068.         SL_ERROR "SL_NEW_SHEET", 102, "" '                                                              no, report error to programmer
  1069.     END IF
  1070.     IF transparency = -1 AND UCASE$(RIGHT$(filename, 4)) <> ".PNG" THEN '                               wrong file type for transparency?
  1071.         SL_ERROR "SL_NEW_SHEET", 103, UCASE$(RIGHT$(filename, 4)) '                                     yes, report error to programmer
  1072.     END IF
  1073.  
  1074.     ' local variable setup
  1075.  
  1076.     sheetimage = _LOADIMAGE(filename, 32) '                                                             load sprite sheet file
  1077.     sheetwidth = _WIDTH(sheetimage) '                                                                   get width of sheet
  1078.     sheetheight = _HEIGHT(sheetimage) '                                                                 get height of sheet
  1079.     columns = sheetwidth \ spritewidth '                                                                get number of whole columns of sprites
  1080.     rows = sheetheight \ spriteheight '                                                                 get number of whole rows of sprites
  1081.     IF columns < 1 OR rows < 1 THEN '                                                                   at least one sprite column and row on sheet?
  1082.         SL_ERROR "SL_NEW_SHEET", 104, "" '                                                              no, report error to programmer
  1083.     END IF
  1084.     osource = _SOURCE '                                                                                 remember current source image
  1085.     odest = _DEST '                                                                                     remember current destination image
  1086.     handle = 0 '                                                                                        initialize handle value
  1087.     clearcolor = transcolor '                                                                           get background/transparent color passed in
  1088.  
  1089.     ' increase sheet array's 1st dimension if needed to create a new sprite sheet
  1090.  
  1091.     DO '                                                                                                look for the next available handle
  1092.         handle = handle + 1 '                                                                           increment the handle value
  1093.     LOOP UNTIL (NOT SL_sheet(handle, 0, 0).image) OR handle = UBOUND(SL_sheet) '                        stop looking when valid handle value found
  1094.     IF SL_sheet(handle, 0, 0).image = -1 THEN '                                                 (TRUE)  is the last array element in use?
  1095.         handle = handle + 1 '                                                                           yes, increment the handle value
  1096.         REDIM _PRESERVE SL_sheet(handle, UBOUND(SL_sheet, 2), UBOUND(SL_sheet, 3)) AS SL_SHEET '        create new sheet in sprite array
  1097.         REDIM _PRESERVE SL_rotate(handle, UBOUND(SL_rotate, 2)) AS SL_ROTATE
  1098.     END IF
  1099.  
  1100.     ' increase sheet array's 2nd and 3rd dimensions if needed to match number of rows and columns
  1101.  
  1102.     IF columns > UBOUND(SL_sheet, 2) THEN '                                                             more columns in this sheet than others?
  1103.         REDIM _PRESERVE SL_sheet(handle, columns, UBOUND(SL_sheet, 3)) AS SL_SHEET '                    yes, increase the array's 2nd dimension to match
  1104.     END IF
  1105.     IF rows > UBOUND(SL_sheet, 3) THEN '                                                                more rows in this sheet than others?
  1106.         REDIM _PRESERVE SL_sheet(handle, UBOUND(SL_sheet, 2), rows) AS SL_SHEET '                       yes, increase the array's 3rd dimension to match
  1107.     END IF
  1108.  
  1109.     ' the variables in SL_sheet(x, 0, 0) will serve a dual purpose
  1110.     ' SL_sheet(x, 0, 0).image will contain either -1 (true) or 0 (false) to indicate the first dimension of the array is in use.
  1111.     ' SL_sheet(x, 0, 0).spritewidth will contain the number of columns contained in the sheet (the array's 2nd dimension)
  1112.     ' SL_sheet(x, 0, 0).spriteheight will contain the number of rows contained in the sheet (the array's 3rd dimension)
  1113.  
  1114.     SL_sheet(handle, 0, 0).image = -1 '                                                         (TRUE)  mark as in use
  1115.     SL_sheet(handle, 0, 0).spritewidth = columns '                                                      remember number of columns in sheet
  1116.     SL_sheet(handle, 0, 0).spriteheight = rows '                                                        remember number of rows in sheet
  1117.  
  1118.     ' identify transparency of sprite sheet if requested
  1119.  
  1120.     IF transparency = -1 THEN '                                                 (constant SL_USESHEET)  sheet have alpha channel?
  1121.         x = 0 '                                                                                         yes, start at upper left x of sheet
  1122.         y = 0 '                                                                                         start at upper left y of sheet
  1123.         alpha = 255 '                                                                                   assume no alpha channel
  1124.         _SOURCE sheetimage '                                                                            set sprite sheet image as source image
  1125.         DO '                                                                                            start looping through the sheet's pixels
  1126.             pixel = POINT(x, y) '                                                                       get the pixel's color attributes
  1127.             alpha = _ALPHA32(pixel) '                                                                   get the alpha level (0 - 255)
  1128.             IF alpha = 0 THEN EXIT DO '                                                                 if it is transparent then leave the loop
  1129.             x = x + 1 '                                                                                 move right one pixel
  1130.             IF x > sheetwidth THEN '                                                                    have we gone off the sheet?
  1131.                 x = 0 '                                                                                 yes, reset back to the left beginning
  1132.                 y = y + 1 '                                                                             move down one pixel
  1133.             END IF
  1134.         LOOP UNTIL y > sheetheight '                                                                    don't stop until the entire sheet has been checked
  1135.         IF alpha = 0 THEN '                                                                             did we find a transparent pixel?
  1136.             tempsprite = _NEWIMAGE(1, 1, 32) '                                                          yes, create a temporary image         * why did I have to do
  1137.             _CLEARCOLOR pixel, tempsprite '                                                             set pixel found as transparent        * this hack to get
  1138.             clearcolor = _CLEARCOLOR(tempsprite) '                                                      get the transparent color from image  * clearcolor to come out
  1139.             _FREEIMAGE tempsprite '                                                                     temporary image no longer needed      * to the right value?
  1140.         ELSE '                                                                                          no transparency found within sheet
  1141.             transparency = 1 '                                                                          set sheet to having no alpha channel
  1142.         END IF
  1143.     ELSEIF transparency = 0 THEN '                                                   (constant SL_SET)  manually set alpha channel?
  1144.         _CLEARCOLOR clearcolor, sheetimage '                                                            yes, set color as transparent
  1145.         clearcolor = _CLEARCOLOR(sheetimage) '                                                          get the transparent color ************* again, why this hack?
  1146.     END IF
  1147.  
  1148.     ' load sprites from sheet and place into sprite array
  1149.  
  1150.     FOR x = 1 TO columns '                                                                              cycle through the sheet's columns
  1151.         FOR y = 1 TO rows '                                                                             cycle through the sheet's rows
  1152.             SL_sheet(handle, x, y).image = _NEWIMAGE(spritewidth, spriteheight, 32) '                   create software sprite image
  1153.             IF transparency < 1 THEN '                                                                  should a mask be created?
  1154.                 SL_sheet(handle, x, y).mask = _NEWIMAGE(spritewidth, spriteheight, 32) '                yes, create software sprite mask image
  1155.                 _DEST SL_sheet(handle, x, y).mask '                                                     write to the mask image
  1156.             ELSE
  1157.                 SL_sheet(handle, x, y).transparency = 0 '                                      (FALSE)  set sprite as having no transparency
  1158.             END IF
  1159.             _PUTIMAGE , sheetimage, SL_sheet(handle, x, y).image,_
  1160.                  ((x - 1) * spritewidth, (y - 1) * spriteheight)-_
  1161.                  ((x - 1) * spritewidth + spritewidth - 1, (y - 1) * spriteheight + spriteheight - 1) ' copy sprite from sheet and place in sprite image
  1162.  
  1163.             ' precalculate collision boundaries and update sprite mask if needed
  1164.  
  1165.             _SOURCE SL_sheet(handle, x, y).image '                                                      work from the software sprite image
  1166.             top = spriteheight - 1 '                                                                    set initial collision boundary markers
  1167.             left = spritewidth - 1
  1168.             bottom = 0
  1169.             right = 0
  1170.             FOR x1 = 0 TO spritewidth - 1 '                                                             cycle through the width of sprite
  1171.                 FOR y1 = 0 TO spriteheight - 1 '                                                        cycle through the height of sprite
  1172.                     IF POINT(x1, y1) <> clearcolor THEN '                                               is this pixel a transparent/background color?
  1173.                         IF x1 < left THEN left = x1 '                                                   no, save position if left-most pixel
  1174.                         IF y1 < top THEN top = y1 '                                                     save position if top-most pixel
  1175.                         IF x1 > right THEN right = x1 '                                                 save position if right-most pixel
  1176.                         IF y1 > bottom THEN bottom = y1 '                                               save position if bbottom-most pixel
  1177.                     END IF
  1178.                     IF transparency < 1 THEN '                                                          update software sprite mask?
  1179.                         IF POINT(x1, y1) = clearcolor THEN '                                            yes, is this pixel a transparent/background color?
  1180.                             PSET (x1, y1), _RGB32(255, 255, 255) '                                      yes, set as white on the mask image
  1181.                         END IF
  1182.                     END IF
  1183.                 NEXT y1
  1184.             NEXT x1
  1185.             SL_sheet(handle, x, y).collx1 = left '                                                      collision box top left x
  1186.             SL_sheet(handle, x, y).colly1 = top '                                                       collision box top left y
  1187.             SL_sheet(handle, x, y).collx2 = right '                                                     collision box bottom right x
  1188.             SL_sheet(handle, x, y).colly2 = bottom '                                                    collision box bottom right y
  1189.             SL_sheet(handle, x, y).spritewidth = spritewidth '                                          remember sprite width
  1190.             SL_sheet(handle, x, y).spriteheight = spriteheight '                                        remember sprite height
  1191.         NEXT y
  1192.     NEXT x
  1193.     _FREEIMAGE sheetimage '                                                                             sprite sheet image no longer needed
  1194.  
  1195.     ' create precalculated rotation table for the sprite sheet (0 to 359 degrees)
  1196.  
  1197.     FOR x = 1 TO 359
  1198.         'px(0) = (-spritewidth + 1) / 2 '                                                                upper left  x polar coordinate of sprite
  1199.         'py(0) = (-spriteheight + 1) / 2 '                                                               upper left  y polar coordinate of sprite
  1200.         px(0) = -spritewidth / 2 '                                                                      upper left  x polar coordinate of sprite
  1201.         py(0) = -spriteheight / 2 '                                                                     upper left  y polar coordinate of sprite
  1202.         px(1) = px(0) '                                                                                 lower left  x polar coordinate of sprite
  1203.         'py(1) = (spriteheight -1) / 2 '                                                                 lower left  y polar coordinate of sprite
  1204.         'px(2) = (spritewidth - 1) / 2 '                                                                 lower right x polar coordinate of sprite
  1205.         py(1) = spriteheight / 2 '                                                                      lower left  y polar coordinate of sprite
  1206.         px(2) = spritewidth / 2 '                                                                       lower right x polar coordinate of sprite
  1207.         py(2) = py(1) '                                                                                 lower right y polar coordinate of sprite
  1208.         px(3) = px(2) '                                                                                 upper right x polar coordinate of sprite
  1209.         py(3) = py(0) '                                                                                 upper right y polar coordinate of sprite
  1210.         sinr = SIN(-x / 57.2957795131) '                                                                calculate the sin of rotation
  1211.         cosr = COS(-x / 57.2957795131) '                                                                calculate the cosine of rotation
  1212.         bx1 = 0 '                                                                                       upper left x boundary of sprite
  1213.         by1 = 0 '                                                                                       upper left y boundary of sprite
  1214.         bx2 = 0 '                                                                                       lower right x boundary of sprite
  1215.         by2 = 0 '                                                                                       lower right y boundary of sprite
  1216.         FOR y = 0 TO 3 '                                                                                cycle through all four polar coordinates
  1217.             x2 = (px(y) * cosr + sinr * py(y)) '                                                        compute new polar coordinate location
  1218.             y2 = (py(y) * cosr - px(y) * sinr) '                                                        compute new polar coordinate location
  1219.             px(y) = x2 '                                                                                save the new polar coordinate
  1220.             py(y) = y2 '                                                                                save the new polar coordinate
  1221.             IF px(y) < bx1 THEN bx1 = px(y) '                                                           save lowest  x value seen \  NOTE: use for
  1222.             IF px(y) > bx2 THEN bx2 = px(y) '                                                           save highest x value seen  \ background image         <--------------------- LOOK
  1223.             IF py(y) < by1 THEN by1 = py(y) '                                                           save lowest  y value seen  / rectangle coordinates
  1224.             IF py(y) > by2 THEN by2 = py(y) '                                                           save highest y value seen /
  1225.         NEXT y
  1226.         SL_rotate(handle, x).rwidth = bx2 - bx1 + 1 '                                                   calculate width of rotated sprite
  1227.         SL_rotate(handle, x).rheight = by2 - by1 + 1 '                                                  calculate height of rotated sprite
  1228.         SL_rotate(handle, x).px0 = px(0) + ((bx2 - bx1 + 1) \ 2) '                                      calculate triangular coordinates
  1229.         SL_rotate(handle, x).px1 = px(1) + ((bx2 - bx1 + 1) \ 2)
  1230.         SL_rotate(handle, x).px2 = px(2) + ((bx2 - bx1 + 1) \ 2)
  1231.         SL_rotate(handle, x).px3 = px(3) + ((bx2 - bx1 + 1) \ 2)
  1232.         SL_rotate(handle, x).py0 = py(0) + ((by2 - by1 + 1) \ 2)
  1233.         SL_rotate(handle, x).py1 = py(1) + ((by2 - by1 + 1) \ 2)
  1234.         SL_rotate(handle, x).py2 = py(2) + ((by2 - by1 + 1) \ 2)
  1235.         SL_rotate(handle, x).py3 = py(3) + ((by2 - by1 + 1) \ 2)
  1236.  
  1237.         'SL_rotate(handle, x).rwidth = bx2 - bx1 '                                                       calculate width of rotated sprite
  1238.         'SL_rotate(handle, x).rheight = by2 - by1 '                                                      calculate height of rotated sprite
  1239.         'SL_rotate(handle, x).px0 = px(0) + ((bx2 - bx1) / 2) '                                          calculate triangular coordinates
  1240.         'SL_rotate(handle, x).px1 = px(1) + ((bx2 - bx1) / 2)
  1241.         'SL_rotate(handle, x).px2 = px(2) + ((bx2 - bx1) / 2)
  1242.         'SL_rotate(handle, x).px3 = px(3) + ((bx2 - bx1) / 2)
  1243.         'SL_rotate(handle, x).py0 = py(0) + ((by2 - by1) / 2)
  1244.         'SL_rotate(handle, x).py1 = py(1) + ((by2 - by1) / 2)
  1245.         'SL_rotate(handle, x).py2 = py(2) + ((by2 - by1) / 2)
  1246.         'SL_rotate(handle, x).py3 = py(3) + ((by2 - by1) / 2)
  1247.  
  1248.     NEXT x
  1249.     _SOURCE osource '                                                                                   return source to current
  1250.     _DEST odest '                                                                                       return destination to current
  1251.     SL_NEW_SHEET = handle '                                                                             return the handle number pointing to this sheet
  1252.  
  1253.  
  1254. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1255. FUNCTION SL_VALID_SPRITE (handle AS INTEGER) '                                                                                                                                         SL_VALID_SPRITE
  1256.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1257.  
  1258.     ' declare global variables
  1259.  
  1260.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1261.  
  1262.     IF handle > UBOUND(SL_SPRITE) OR (NOT SL_sprite(handle).inuse) OR handle < 1 THEN '                  is this a valid sprite handle?
  1263.         SL_VALID_SPRITE = 0 '                                                                   (FALSE)  no, return 0
  1264.     ELSE '                                                                                               yes, it is valid
  1265.         SL_VALID_SPRITE = -1 '                                                                   (TRUE)  return -1
  1266.     END IF
  1267.  
  1268.  
  1269. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1270. SUB SL_ERROR (routine AS STRING, errno AS INTEGER, info AS STRING) '                                                                                                                           SL_ERROR
  1271.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1272.  
  1273.     SCREEN 0, 0, 0, 0 '                                                                                 go to a pure text screen
  1274.     _FONT 16 '                                                                                          set the standard screen 0 font
  1275.     IF _FULLSCREEN THEN _FULLSCREEN _OFF '                                                              turn off full screen if on
  1276.     _AUTODISPLAY '                                                                                      auto update the display
  1277.     CLS '                                                                                               clear the screen
  1278.     COLOR 10, 0
  1279.     PRINT "                   **************************************" '                                 print error header
  1280.     PRINT "                   ** Sprite Library Error Encountered **"
  1281.     PRINT "                   **************************************"
  1282.     PRINT
  1283.     COLOR 15, 0
  1284.     PRINT " "; routine;
  1285.     COLOR 7, 0
  1286.     PRINT " has reported error";
  1287.     COLOR 30, 0
  1288.     PRINT STR$(errno)
  1289.     COLOR 7, 0
  1290.     PRINT
  1291.     SELECT CASE errno '                                                                                 which error number is being reported?
  1292.  
  1293.         ' general purpose errors for all subs/functions
  1294.  
  1295.         CASE 1
  1296.             PRINT "- the requested sprite does not exist"
  1297.         CASE 2
  1298.             PRINT "- invalid background restore setting supplied - valid settings are"
  1299.             PRINT "- : -1 (constant SL_SAVE)"
  1300.             PRINT "- :  0 (constant SL_NOSAVE)"
  1301.  
  1302.             ' errors belonging to SL_NEW_SHEET (100 - 109)
  1303.  
  1304.         CASE 100
  1305.             PRINT "- "; CHR$(34); info; CHR$(34); " sprite sheet does not exist"
  1306.             PRINT "- check path or spelling"
  1307.         CASE 101
  1308.             PRINT "- invalid transparency setting supplied - valid settings are"
  1309.             PRINT "- : -1 (constant SL_USESHEET)"
  1310.             PRINT "- :  0 (constant SL_SET)"
  1311.             PRINT "- :  1 (constant SL_NONE)"
  1312.         CASE 102
  1313.             PRINT "- sprite width and height must be greater than zero"
  1314.         CASE 103
  1315.             PRINT "- selecting to use a sheet's transparency only works with .PNG files"
  1316.             PRINT "- the function was passed a "; info; " file."
  1317.         CASE 104
  1318.             PRINT "- there must be at least one column and one row of sprites on sheet"
  1319.             PRINT "- the sheet being loaded does not meet these minimums"
  1320.  
  1321.             'errors belonging to SL_NEW_SPRITE (110 - 119)
  1322.  
  1323.         CASE 110
  1324.             PRINT "- the specified sprite sheet is not in use or does not exist"
  1325.         CASE 111
  1326.             PRINT "- invalid row or column selected for specified sprite sheet"
  1327.         CASE 112
  1328.             PRINT "- invalid hardware / software setting supplied - valid settings are"
  1329.             PRINT "- : -1 (constant SL_SOFTWARE)"
  1330.             PRINT "- :  0 (constant SL_HARDWARE)"
  1331.         CASE 113
  1332.             PRINT "- there is no need to restore the background with hardware sprites"
  1333.             PRINT "- change background restore setting to zero (0) (constant SL_NOSAVE)"
  1334.  
  1335.             ' errors belonging to SL_FLIP_SPRITE (120 - 129)
  1336.  
  1337.         CASE 120
  1338.             PRINT "- invalid flip setting supplied - valid settings are"
  1339.             PRINT "  : 0 (constant SL_NOFLIP)"
  1340.             PRINT "  : 1 (constant SL_HORIZONTAL)"
  1341.             PRINT "  : 2 (constant SL_VERTICAL)"
  1342.             PRINT "  : 3 (constant SL_FLIPBOTH)"
  1343.  
  1344.             ' errors belonging to SL_ZOOM_SPRITE (130 - 139)
  1345.  
  1346.         CASE 130
  1347.             PRINT "- invalid zoom level setting supplied"
  1348.             PRINT "- zoom level must be greater than zero (0)"
  1349.  
  1350.             ' errors belonging to SL_SET_ROTATION_SPEED (140 - 149)
  1351.  
  1352.         CASE 140
  1353.             PRINT "- rotation speed must be between -359 and 359 degrees"
  1354.  
  1355.             ' errors belonging to SL_SET_AUTOMOTION (150 - 159)
  1356.  
  1357.         CASE 150
  1358.             PRINT "- invalid auto motion behavior requested - valid settings are"
  1359.             PRINT "- : -1 (constant SL_START)"
  1360.             PRINT "- :  0 (constant SL_STOP)"
  1361.  
  1362.             ' errors belonging to SL_SET_AUTOROTATE (160 - 169)
  1363.  
  1364.         CASE 160
  1365.             PRINT "- invalid auto rotation behavior requested - valid settings are"
  1366.             PRINT "- : -1 (constant SL_START)"
  1367.             PRINT "- :  0 (constant SL_STOP)"
  1368.  
  1369.             ' errors belonging to SL_MOVE_SPRITE (170 - 179)
  1370.  
  1371.         CASE 170
  1372.             PRINT "- the sprite requested is already under automatic movement control"
  1373.  
  1374.             ' errors belonging to SL_ROTATE_SPRITE (180 - 189)
  1375.  
  1376.         CASE 180
  1377.             PRINT "- the sprite requested is already under automatic rotation control"
  1378.  
  1379.     END SELECT
  1380.     COLOR 12, 0
  1381.     PRINT
  1382.     PRINT " See sprite library doumentation for further explanation."
  1383.     COLOR 7, 0
  1384.     DO: LOOP UNTIL INKEY$ = "" '                                                                        clear the keyboard buffer
  1385.     END '                                                                                               end the program
  1386.  
  1387.  
  1388. '* why the long name for variables in SUB?
  1389. '* to prevent the likelihood of unintended collisions with global/shared variables or constants
  1390. FUNCTION SL_Correct_Degree_Angle_To_360% (SLCDAT360AngleParameter AS INTEGER)
  1391.     DIM SL_Correct_Degree_Angle_To_360CDAT360 AS INTEGER
  1392.     SL_Correct_Degree_Angle_To_360CDAT360 = SLCDAT360AngleParameter MOD 360
  1393.     IF SL_Correct_Degree_Angle_To_360CDAT360 < 0 THEN
  1394.         SL_Correct_Degree_Angle_To_360% = SL_Correct_Degree_Angle_To_360CDAT360 + 360
  1395.     ELSE
  1396.         SL_Correct_Degree_Angle_To_360% = SL_Correct_Degree_Angle_To_360CDAT360
  1397.     END IF
  1398.  

SL_Correct_Degree_Angle_To_360% replaces some code that reduces angles to 0-359 range, regardless of sign. It eliminates a LOT of subtraction for angles >=360 or <=-360.
a quick view since it was appended to your demo code.
Code: QB64: [Select]
  1. '* why the long name for variables in SUB?
  2. '* to prevent the likelihood of unintended collisions with global/shared variables or constants
  3. FUNCTION SL_Correct_Degree_Angle_To_360% (SLCDAT360AngleParameter AS INTEGER)
  4.     DIM SL_Correct_Degree_Angle_To_360CDAT360 AS INTEGER
  5.     SL_Correct_Degree_Angle_To_360CDAT360 = SLCDAT360AngleParameter MOD 360
  6.     IF SL_Correct_Degree_Angle_To_360CDAT360 < 0 THEN
  7.         SL_Correct_Degree_Angle_To_360% = SL_Correct_Degree_Angle_To_360CDAT360 + 360
  8.     ELSE
  9.         SL_Correct_Degree_Angle_To_360% = SL_Correct_Degree_Angle_To_360CDAT360
  10.     END IF
  11.  
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 17, 2018, 01:21:18 pm
I always forget about using MOD for things like this.

Thank you for the correction. Much better

I did create a function called SL_FIX_DEGREES yesterday to replace the many places throughout the code where degree angle needed checked/corrected. Your code now controls that function since my code was the same as the original code scattered throughout.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 18, 2018, 01:55:33 am
Animation is turning out to be a beast. I've had to rethink my strategy a few times today reorganizing the code a few times in the process.

I think I know have a plan to move forward with animation. Hopefully I'll have something significant to show tomorrow.

I'm starting to dream code at night. :-o
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 20, 2018, 02:23:40 am
I have made so many changes over the last two days that trying to explain it all here would take a book. The one major thing I did was completely rethink the way data types are processed and presented to make it easier to sort out variables. I also had to come up with a way to identify sprites not only by their column/row on a sheet, but also by cell number for animation tracking. Both of which I have now. Here is the code for anyone interested in viewing what I have so far.

Code: QB64: [Select]
  1. '** NOTES **
  2.  
  3. ' Ideas to add
  4. '
  5. ' if SL_EVENT_TRIGGER then 'check for event that was sent (add event triggers)
  6. ' - possible link sounds to events
  7. ' add gravity, attraction, repulsion  SL_SET_PHYSICS
  8. ' add mass, elasticity (bounciness?)   ^  ^  ^
  9. ' add arc calculator for things like a swinging vine or radar scope
  10. ' ability to link sprites, when one moves the other moves, break apart when collision happens SL_LINK_SPRITE
  11. ' give sprites path-following ability (bezier curves?) SL_FOLLOW_PATH
  12. ' divide work space into cells and detect when sprites enter/leave a cell
  13. ' stand-alone program to develop sprite sheets (inform)        \
  14. ' stand-alone program to develop celled work spaces (inform)   /  combine these into one program?
  15. ' when sprite interact their mass, elascticity, etc. govern the way the move and fall
  16. ' - I will need help from a math major for this
  17.  
  18. ' Planned additions
  19. '
  20. ' Mouse routines
  21. ' - detect when mouse interacts with a sprite (hover, click, double click, right click, etc..) SL_MOUSE_STATUS
  22. ' set a score value to a sprite for game score tracking, SL_SET_SCORE, SL_GET_SCORE
  23. ' 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
  24. ' reverse x and y directions for auto/manual movement, SL_MOTION_REVERSEX, SL_MOTION_REVERSEY
  25. ' set Z depth of sprite for different planes/layers (possibly incorporate this into zoom?)
  26. ' hide/unhide sprites SL_HIDE_SPRITE, SL_SHOW_SPRITE
  27. ' collision detection routines (rectangle, round, ellipticle, pixel-perfect, n-space?, prediction?) SL_SET_COLLISION, SL_GET_COLLISION, SL_COLLIDED_WITH
  28. ' - need to figure out how to rotate collision box along with sprites, not too hard
  29. ' - this will require line segment intersection algorithms for collision detection, yikes! hard, probably need help
  30. ' - possibly link sounds to collisions SL_LINK_COLLIDE_SOUND
  31. ' Parallaxing layers  SL_CREATE_PARALLAX, SL_UPDATE_PARALLAX
  32. ' Game font printing
  33. ' Sprite tiling, square for sure, isometric?
  34.  
  35. ' Things to improve
  36. '
  37. ' Naming convention of constants and their values
  38. ' Remove all for/next loops and replace with do/loop or while/wend
  39. ' Use integers wherever possible
  40. ' allow SINGLE value rotation angles for accuracy but convert to integer before sprite rotation
  41. ' - using only integer now, may not be precise enough for future improvements
  42.  
  43. ' Investigate
  44. '
  45. ' Use of _MAPTRIANGLE for 3D rotation   SL_ROTATE_3D
  46. ' _HARDWARE vs _HARDWARE1
  47.  
  48. ' Remember
  49. '
  50. ' Any code added that is OS dependant needs to detect the OS running first
  51. ' - try to create routines that are OS dependant for all OS'
  52.  
  53.  
  54.  
  55. OPTION _EXPLICIT ' need to remove before publishing library!!
  56.  
  57. '*
  58. '* constant declarations
  59. '*
  60.  
  61. '         CONSTANT NAME                                DESCRIPTION                          FUNCTIONS / SUBROUTINES THAT MAY USE THIS CONSTANT
  62. ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  63. CONST SL_RESET = -32767 '               reset a function or subroutine                      SL_ROTATE_SPRITE, SL_FLIP_SPRITE, SL_ZOOM_SPRITE, SL_CHANGE_AUTOROTATION, SL_CHANGE_AUTOMOTION
  64. CONST SL_NOFLIP = 0 '                   sprite will use no flipping                         SL_FLIP_SPRITE
  65. CONST SL_HORIZONTAL = 1 '               sprite will be flipped horizontally                 SL_FLIP_SPRITE
  66. CONST SL_VERTICAL = 2 '                 sprite will be flipped vertically                   SL_FLIP_SPRITE
  67. CONST SL_FLIPBOTH = 3 '                 sprite will be flipped horizontally & vertically    SL_FLIP_SPRITE
  68. CONST SL_USESHEET = -1 '                use sheet's transparency info (.PNG)                SL_NEW_SHEET
  69. CONST SL_SET = 0 '                      manually set transparency                           SL_NEW_SHEET
  70. CONST SL_NONE = 1 '                     don't use transparency with sheet                   SL_NEW_SHEET
  71. CONST SL_NOSAVE = 0 '                   sprite will not save background                     SL_NEW_SPRITE, SL_SOFTWARE_SPRITE
  72. CONST SL_SAVE = -1 '                    sprite will save background                         SL_NEW_SPRITE, SL_SOFTWARE_SPRITE
  73. CONST SL_HARDWARE = 0 '                 sprite in hardware mode                             SL_NEW_SPRITE
  74. CONST SL_SOFTWARE = -1 '                sprite in software mode                             SL_NEW_SPRITE
  75. CONST SL_START = -1 '                   enable auto motion / rotation                       SL_CHANGE_AUTOMOTION, SL_CHANGE_AUTOROTATION, SL_SET_AUTOANIMATION
  76. CONST SL_STOP = 0 '                     disable auto motion / rotation                      SL_CHANGE_AUTOMOTION, SL_CHANGE_AUTOROTATION, SL_SET_AUTOANIMATION
  77. CONST SL_FORWARD = 0 '                  animation cells proceed forward                     SL_SET_ANIMATTION
  78. CONST SL_BACKWARD = 1 '                 animation cells proceed backwards                   SL_SET_ANIMATION
  79. CONST SL_BACKFORTH = 2 '                animation cells toggle forward/backward             SL_SET_ANIMATION
  80. CONST SL_CURRENTCELL = -1 '             use current cell as starting animation cell         SL_SET_ANIMATION
  81.  
  82. '*
  83. '* type declarations
  84. '*
  85.  
  86. TYPE SL_SHEET ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ SPRITE SHEET DATABASE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  87.     image AS LONG '                     software sprite image
  88.     mask AS LONG '                      software mask image
  89.     swidth AS INTEGER '                 width of sprite
  90.     sheight AS INTEGER '                height of sprite
  91.     cell AS INTEGER '                   the animation cell of this sprite
  92.     collx1 AS INTEGER '                 collision box top left x
  93.     colly1 AS INTEGER '                 collision box top left y
  94.     collx2 AS INTEGER '                 collision box bottom right x
  95.     colly2 AS INTEGER '                 collision box bottom right y
  96.     transparency AS INTEGER '           -1 (TRUE) if sheet uses transparency
  97. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  98.  
  99. TYPE SL_XY ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ X,Y LOCATIONS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  100.     real AS SINGLE '                    single values of sprite x,y center point
  101.     int AS INTEGER '                    integer values of sprite x,y center point
  102.     actual AS INTEGER '                 integer values of sprite upper left x,y location
  103.     back AS INTEGER '                   integer values of sprite's background image x,y location
  104.     dir AS SINGLE '                     single values of sprite x,y motion vectors
  105. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  106.  
  107. TYPE SL_IMAGE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ IMAGES ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  108.     sprite AS LONG '                    hardware sprite image
  109.     image AS LONG '                     software sprite image
  110.     mask AS LONG '                      software sprite mask image
  111.     back AS LONG '                      software sprite saved background image
  112. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  113.  
  114. TYPE SL_ANIM ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ANIMATION SETTINGS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  115.     cell AS INTEGER '                   current animation cell
  116.     cellfrom AS INTEGER '               starting animation cell
  117.     cellto AS INTEGER '                 ending animation cell
  118.     dir AS INTEGER '                    animation direction
  119.     mode AS INTEGER '                   animation mode (forward, backward, back/forth)
  120.     framerate AS INTEGER '              sprite animation frame rate
  121.     frame AS INTEGER '                  animation frame counter
  122.     skip AS INTEGER '                   how often to skip a frame to achieve framerate
  123.     auto AS INTEGER '                   auto-animation on/off
  124. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  125.  
  126. TYPE SL_MOTION ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ MOTION SETTINGS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  127.     auto AS INTEGER '                   -1 (TRUE) if auto-motion turned on
  128.     speed AS SINGLE '                   speed of sprite during motion
  129.     angle AS INTEGER '                  direction of sprite during motion (0 - 359)
  130. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  131.  
  132. TYPE SL_ROTATION ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ROTATION SETTINGS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  133.     auto AS INTEGER '                   -1 (TRUE) if auto-rotation turned on
  134.     speed AS INTEGER '                  spin rate in degrees of sprite (0 - 359)
  135.     angle AS INTEGER '                  current rotation angle of sprite
  136. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  137.  
  138. TYPE SL_SPRITE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ SPRITE DATABASE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  139.     inuse AS INTEGER '                  this array index in use
  140.     x AS SL_XY '                        x coordinate locations
  141.     y AS SL_XY '                        y coordinate locations
  142.     gfx AS SL_IMAGE '                   image graphics
  143.     anim AS SL_ANIM '                   animation settings
  144.     motion AS SL_MOTION '               motion settings
  145.     rotation AS SL_ROTATION '           rotation settings
  146.     sheet AS INTEGER '                  sheet sprite belongs to
  147.     column AS INTEGER '                 the column on the sheet the sprite resides
  148.     row AS INTEGER '                    the row on the sheet the sprite resides
  149.     swidth AS INTEGER '                 width of sprite
  150.     sheight AS INTEGER '                height of sprite
  151.     restore AS INTEGER '                -1 (true) if sprite restores background
  152.     collx1 AS INTEGER '                 collision box top left x
  153.     colly1 AS INTEGER '                 collision box top left y
  154.     collx2 AS INTEGER '                 collision box bottom right x
  155.     colly2 AS INTEGER '                 collision box bottom right y
  156.     flip AS INTEGER '                   flip horizontally, vertically, or both
  157.     transparency AS INTEGER '           -1 (TRUE) if sprite uses transparency
  158.     zoom AS INTEGER '                   zoom level of sprite (1% - x%)
  159.     software AS INTEGER '               -1 (TRUE) if sprite is to be treated as software image
  160. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  161.  
  162. TYPE SL_ROTATE 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ PRECALCULATED ROTATION TABLE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  163.     rwidth AS INTEGER '                 width of rotated sprite
  164.     rheight AS INTEGER '                height of rotated sprite
  165.     px0 AS INTEGER '                    rectangular rotation coordinates
  166.     px1 AS INTEGER
  167.     px2 AS INTEGER
  168.     px3 AS INTEGER
  169.     py0 AS INTEGER
  170.     py1 AS INTEGER
  171.     py2 AS INTEGER
  172.     py3 AS INTEGER
  173. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  174.  
  175. '*
  176. '* global dynamic array declarations
  177. '*
  178.  
  179. REDIM SL_sheet(1, 1, 1) AS SL_SHEET '   master sprite sheet array
  180. REDIM SL_sprite(1) AS SL_SPRITE '       master working sprite array
  181. REDIM SL_rotate(1, 359) AS SL_ROTATE '  precalculated rotation values
  182.  
  183. '*
  184. '* global variable declarations
  185. '*
  186.  
  187. DIM SL_framerate AS INTEGER '           the global frame rate
  188.  
  189. '*
  190. '* main code (for testing)
  191. '*
  192.  
  193. DIM kongsheet AS INTEGER
  194. DIM mysprite AS INTEGER
  195. DIM mysprite2 AS INTEGER
  196. DIM angle AS INTEGER
  197.  
  198. SL_SET_FRAMERATE 30
  199.  
  200. kongsheet = SL_NEW_SHEET("dkong.png", 64, 64, SL_SET, _RGB32(255, 0, 255))
  201. mysprite = SL_NEW_SPRITE(kongsheet, 1, 1, SL_HARDWARE, SL_NOSAVE)
  202. mysprite2 = SL_NEW_SPRITE(kongsheet, 1, 1, SL_SOFTWARE, SL_NOSAVE)
  203.  
  204. 'SL_FLIP_SPRITE mysprite, SL_HORIZONTAL
  205. 'SL_SET_ZOOM mysprite, 125
  206.  
  207. SL_SET_MOTION mysprite, 135, .1, SL_START
  208. SL_SET_ROTATION mysprite, 0, 1, SL_START
  209. SL_SET_ROTATION mysprite2, 180, 10, SL_START
  210.  
  211. SCREEN _NEWIMAGE(640, 480, 32)
  212. CIRCLE (128, 128), 64, _RGB32(255, 255, 255)
  213.  
  214. SL_PUT_SPRITE 128, 128, mysprite
  215. SL_PUT_SPRITE 128, 128, mysprite2
  216.  
  217.     _LIMIT SL_GET_FRAMERATE
  218.     x = x + 1
  219.     IF x = 15 THEN
  220.         SL_CHANGE_MOTION_SPEED mysprite, SL_GET_MOTION_SPEED(mysprite) + .3
  221.         SL_CHANGE_ROTATION_SPEED mysprite, SL_GET_ROTATION_SPEED(mysprite) + 1
  222.         x = 0
  223.     END IF
  224.     SL_UPDATE_AUTO_SPRITES
  225.     _DISPLAY
  226.  
  227. SL_FREE_SPRITE mysprite
  228. SL_FREE_SPRITE mysprite2
  229.  
  230.  
  231.  
  232. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  233. SUB SL_SET_FRAMERATE (framerate AS INTEGER) '                                                                                                                                          SL_SET_FRAMERATE
  234.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  235.  
  236.     ' declare global variables
  237.  
  238.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  239.     SHARED SL_framerate AS INTEGER '    global frame rate
  240.  
  241.     ' declare local variables
  242.  
  243.     DIM handle AS INTEGER '             cycle counter through sprite handles
  244.  
  245.     ' perform error checks
  246.  
  247.     ' add check for valid framerate <----------------- LOOK
  248.  
  249.     ' set local variables
  250.  
  251.     SL_framerate = framerate '                                                                          set global frame rate
  252.     handle = 0 '                                                                                        reset handle counter
  253.  
  254.     DO '                                                                                                update all available sprites
  255.         handle = handle + 1 '                                                                           increment sprite pointer
  256.         IF SL_sprite(handle).inuse THEN '                                                               is this sprite in use?
  257.             IF SL_sprite(handle).anim.framerate THEN '                                                  yes, does it contain an animation frame rate?
  258.                 SL_sprite(handle).anim.skip = SL_framerate / (SL_framerate - SL_sprite(handle).anim.framerate) ' yes, recalculate skip rate
  259.             END IF
  260.         END IF
  261.     LOOP UNTIL handle = UBOUND(SL_sprite) '                                                             leave when all sprites updated
  262.  
  263.  
  264. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  265. FUNCTION SL_GET_FRAMERATE () '                                                                                                                                                         SL_GET_FRAMERATE
  266.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  267.  
  268.     ' declare global variables
  269.  
  270.     SHARED SL_framerate AS INTEGER '    global frame rate
  271.  
  272.     SL_GET_FRAMERATE = SL_framerate
  273.  
  274.  
  275. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  276. SUB SL_NEXT_ANIMATION_CELL () '                                                                                                                                                  SL_NEXT_ANIMATION_CELL
  277.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  278.     ' manual sprite animation control
  279.  
  280.  
  281. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  282. SUB SL_PREVIOUS_ANIMATION_CELL () '                                                                                                                                          SL_PREVIOUS_ANIMATION_CELL
  283.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  284.     ' manual sprite animation control
  285.  
  286.  
  287. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  288. SUB SL_CHANGE_ANIMATION_CELLS () '                                                                                                                                            SL_CHANGE_ANIMATION_CELLS
  289.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  290.     ' change a sprite's animation sequence
  291.  
  292.  
  293. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  294. SUB SL_CHANGE_ANIMATION_FRAMERATE () '                                                                                                                                    SL_CHANGE_ANIMATION_FRAMERATE
  295.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  296.     ' change a sprite's animation rate
  297.  
  298.  
  299. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  300. SUB SL_CHANGE_AUTOANIMATION (handle AS INTEGER, auto AS INTEGER) '                                                                                                              SL_CHANGE_AUTOANIMATION
  301.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  302.  
  303.     ' declare global variables
  304.  
  305.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  306.  
  307.     ' perform error checks
  308.  
  309.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  310.         SL_ERROR "SL_CHANGE_AUTOANIMATION", 1, "" '                                                     no, report error to programmer
  311.     END IF
  312.     ' add check for correct auto value <-------------- LOOK
  313.  
  314.     SL_sprite(handle).anim.auto = auto '                                          (SL_START & SL_STOP)  set auto-animation
  315.  
  316.  
  317. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  318. 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
  319.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  320.  
  321.     ' declare global variables
  322.  
  323.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  324.     SHARED SL_framerate AS INTEGER '    global frame rate
  325.  
  326.     ' perform error checks
  327.  
  328.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  329.         SL_ERROR "SL_SET_ANIMATION", 1, "" '                                                            no, report error to programmer
  330.     END IF
  331.     ' add check for rate >0 and < SL_framerate + 1
  332.     ' add check for correct mode
  333.     ' add check for valid cellto/cellfrom <-------------------- LOOK
  334.     ' add check for correct auto value
  335.  
  336.     IF cellfrom = -1 THEN '                                                           (SL_CURRENTCELL)  use current cell as start cell?
  337.         SL_sprite(handle).anim.cellfrom = SL_sprite(handle).anim.cell '                                 yes, set first cell as current cell
  338.     ELSE '                                                                                              no
  339.         SL_sprite(handle).anim.cellfrom = cellfrom '                                                    set first cell in animation
  340.     END IF
  341.     SL_sprite(handle).anim.cellto = cellto '                                                            last cell in animation
  342.  
  343.     IF SL_framerate = framerate THEN '                                                                  animation and global frame rates the same?
  344.         SL_sprite(handle).anim.skip = 0 '                                                               yes, perform no skipping fo frames
  345.     ELSE '                                                                                              no, frame rates are different
  346.         SL_sprite(handle).anim.framerate = framerate
  347.         SL_sprite(handle).anim.skip = SL_framerate / (SL_framerate - framerate) '                       calculate skip rate
  348.     END IF
  349.     SL_sprite(handle).anim.frame = 0 '                                                                  reset skip frame counter
  350.     SL_sprite(handle).anim.mode = mode '                     (SL_FORWARD & SL_BACKWARD & SL_BACKFORTH)  set animation mode
  351.     IF mode = 0 OR mode = 2 THEN '                                        (SL_FORWARD or SL_BACKFORTH)  forward or back and forth?
  352.         SL_sprite(handle).anim.dir = 1 '                                                                yes, set animation direction forward
  353.     ELSE '                                                                               (SL_BACKWARD)  no, backward
  354.         SL_sprite(handle).anim.dir = -1 '                                                               set animation direction backward
  355.     END IF
  356.     SL_sprite(handle).anim.auto = auto '                                          (SL_START & SL_STOP)  set auto-animation
  357.  
  358.  
  359. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  360. FUNCTION SL_GET_ROW (sheet AS INTEGER, cell AS INTEGER) '                                                                                                                                    SL_GET_ROW
  361.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  362.  
  363.     ' declare global variables
  364.  
  365.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  366.  
  367.     ' declare local variables
  368.  
  369.     DIM row AS INTEGER '                row cell is located in
  370.  
  371.     ' perform error checks
  372.  
  373.     IF NOT SL_VALID_SHEET(sheet) THEN '                                                                 is this a valid sheet?
  374.         SL_ERROR "SL_GET_ROW", 5, "" '                                                                  no, report error to programmer
  375.     END IF
  376.  
  377.     row = cell MOD SL_sheet(sheet, 0, 0).sheight '                                                      calculate row cell is in
  378.     IF row = 0 THEN '                                                                                   bottom-most row?
  379.         row = SL_sheet(sheet, 0, 0).sheight '                                                           yes, cell is in greatest row number
  380.     END IF
  381.  
  382.     SL_GET_ROW = row '                                                                                  return row cell is located in
  383.  
  384.  
  385. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  386. FUNCTION SL_GET_COLUMN (sheet AS INTEGER, cell AS INTEGER) '                                                                                                                              SL_GET_COLUMN
  387.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  388.  
  389.     ' declare global variables
  390.  
  391.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  392.  
  393.     ' declare local variables
  394.  
  395.     DIM column AS INTEGER '             column cell is located in
  396.  
  397.     ' perform error checks
  398.  
  399.     IF NOT SL_VALID_SHEET(sheet) THEN '                                                                 is this a valid sheet?
  400.         SL_ERROR "SL_GET_COLUMN", 5, "" '                                                               no, report error to programmer
  401.     END IF
  402.  
  403.     column = cell MOD SL_sheet(sheet, 0, 0).swidth '                                                    calculate column cell is in
  404.     IF column = 0 THEN '                                                                                right-most column?
  405.         column = SL_sheet(sheet, 0, 0).swidth ' '                                                       yes, cell is in greatest column number
  406.     END IF
  407.  
  408.     SL_GET_COLUMN = column '                                                                            return column cell is located in
  409.  
  410.  
  411. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  412. FUNCTION SL_GET_CELL (handle AS INTEGER) '                                                                                                                                                  SL_GET_CELL
  413.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  414.  
  415.     ' declare global variables
  416.  
  417.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  418.  
  419.     ' perform error checks
  420.  
  421.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  422.         SL_ERROR "SL_GET_CELL", 1, "" '                                                                 no, report error to programmer
  423.     END IF
  424.  
  425.     SL_GET_CELL = SL_sprite(handle).anim.cell '                                                         return animation cell of this sprite
  426.  
  427.  
  428. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  429. FUNCTION SL_GET_REALX (handle AS INTEGER) '                                                                                                                                                SL_GET_REALX
  430.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  431.  
  432.     ' declare global variables
  433.  
  434.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  435.  
  436.     ' perform error checks
  437.  
  438.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  439.         SL_ERROR "SL_GET_REALX", 1, "" '                                                                no, report error to programmer
  440.     END IF
  441.  
  442.     SL_GET_REALX = SL_sprite(handle).x.real '                                                           return real number center point x
  443.  
  444.  
  445. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  446. FUNCTION SL_GET_REALY (handle AS INTEGER) '                                                                                                                                                SL_GET_REALY
  447.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  448.  
  449.     ' declare global variables
  450.  
  451.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  452.  
  453.     ' perform error checks
  454.  
  455.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  456.         SL_ERROR "SL_GET_REALY", 1, "" '                                                                no, report error to programmer
  457.     END IF
  458.  
  459.     SL_GET_REALY = SL_sprite(handle).y.real '                                                           return real number center point y
  460.  
  461.  
  462. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  463. FUNCTION SL_GET_INTX (handle AS INTEGER) '                                                                                                                                                  SL_GET_INTX
  464.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  465.  
  466.     ' declare global variables
  467.  
  468.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  469.  
  470.     ' perform error checks
  471.  
  472.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  473.         SL_ERROR "SL_GET_INTX", 1, "" '                                                                 no, report error to programmer
  474.     END IF
  475.  
  476.     SL_GET_INTX = SL_sprite(handle).x.int '                                                             return integer number center point x
  477.  
  478.  
  479. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  480. FUNCTION SL_GET_INTY (handle AS INTEGER) '                                                                                                                                                  SL_GET_INTY
  481.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  482.  
  483.     ' declare global variables
  484.  
  485.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  486.  
  487.     ' perform error checks
  488.  
  489.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  490.         SL_ERROR "SL_GET_INTY", 1, "" '                                                                 no, report error to programmer
  491.     END IF
  492.  
  493.     SL_GET_INTY = SL_sprite(handle).y.int '                                                             return integer number center point x
  494.  
  495.  
  496. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  497. FUNCTION SL_GET_ACTUALX (handle AS INTEGER) '                                                                                                                                            SL_GET_ACTUALX
  498.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  499.  
  500.     ' declare global variables
  501.  
  502.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  503.  
  504.     ' perform error checks
  505.  
  506.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  507.         SL_ERROR "SL_GET_ACTUALX", 1, "" '                                                              no, report error to programmer
  508.     END IF
  509.  
  510.     SL_GET_ACTUALX = SL_sprite(handle).x.actual '                                                       return integer number upper left point x
  511.  
  512.  
  513. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  514. FUNCTION SL_GET_ACTUALY (handle AS INTEGER) '                                                                                                                                            SL_GET_ACTUALY
  515.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  516.  
  517.     ' declare global variables
  518.  
  519.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  520.  
  521.     ' perform error checks
  522.  
  523.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  524.         SL_ERROR "SL_GET_ACTUALY", 1, "" '                                                              no, report error to programmer
  525.     END IF
  526.  
  527.     SL_GET_ACTUALY = SL_sprite(handle).y.actual '                                                       return integer number upper left point y
  528.  
  529.  
  530. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  531. FUNCTION SL_COPY_SPRITE (handle AS INTEGER) '                                                                                                                                            SL_COPY_SPRITE
  532.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  533.  
  534.     ' declare global variables
  535.  
  536.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  537.  
  538.     ' declare local variables
  539.  
  540.     DIM newhandle AS INTEGER '          handle of copied sprite
  541.  
  542.     ' perform error checks
  543.  
  544.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  545.         SL_ERROR "SL_COPY_SPRITE", 1, "" '                                                              no, report error to programmer
  546.     END IF
  547.  
  548.     newhandle = 0 '                                                                                     initialize new handle counter
  549.  
  550.     ' increase sprite array's size if needed
  551.  
  552.     DO '                                                                                                look for next available handle
  553.         newhandle = newhandle + 1 '                                                                     increment to next handle value
  554.     LOOP UNTIL (NOT SL_sprite(newhandle).inuse) OR newhandle = UBOUND(SL_sprite) '                      stop looking when valid handle found
  555.     IF SL_sprite(newhandle).inuse THEN '                                                                is the last array element in use?
  556.         newhandle = newhandle + 1 '                                                                     yes, increment to next handle value
  557.         REDIM _PRESERVE SL_sprite(newhandle) AS SL_SPRITE '                                             increase the size of the sprite array
  558.     END IF
  559.  
  560.     ' copy new sprite
  561.  
  562.     SL_sprite(newhandle) = SL_sprite(handle) '                                                          copy entire sprite contents
  563.     SL_sprite(newhandle).gfx.sprite = _COPYIMAGE(SL_sprite(handle).gfx.sprite, 33) '                    create an actual copy of the hardware sprite
  564.     SL_sprite(newhandle).gfx.image = _COPYIMAGE(SL_sprite(handle).gfx.image, 32) '                      create an actual copy of the software image
  565.     IF SL_sprite(handle).gfx.mask THEN '                                                                does the original contain a mask image?
  566.         SL_sprite(newhandle).gfx.mask = _COPYIMAGE(SL_sprite(handle).gfx.mask, 32) '                    yes, create an actual copy of the software mask image
  567.     END IF
  568.  
  569.     SL_COPY_SPRITE = newhandle '                                                                        return new sprite's handle pointer
  570.  
  571.  
  572. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  573. SUB SL_STAMP_SPRITE (x AS INTEGER, y AS INTEGER, sheet AS INTEGER, column AS INTEGER, row AS INTEGER, degrees AS INTEGER, flip AS INTEGER, zoom AS INTEGER) '                           SL_STAMP_SPRITE
  574.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  575.  
  576.     ' declare global variables
  577.  
  578.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  579.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  580.  
  581.     ' declare local variables
  582.  
  583.     DIM tempsprite AS LONG '            temporary sprite to stamp
  584.     DIM degree AS INTEGER '             rotation degree passed in
  585.  
  586.     ' set local variables
  587.  
  588.     degree = SL_FIX_DEGREES(degrees) '                                                                  get rotation degree passed in
  589.  
  590.     ' perform error checks
  591.  
  592.     IF NOT SL_VALID_SHEET(sheet) THEN '                                                                 is this a valid sheet?
  593.         SL_ERROR "SL_STAMP_SPRITE", 5, "" '                                                             no, report error to programmer
  594.     END IF
  595.     IF column > UBOUND(SL_sheet, 2) OR row > UBOUND(SL_sheet, 3) OR row < 1 OR column < 1 THEN '        valid row and column requested?
  596.         SL_ERROR "SL_STAMP_SPRITE", 6, "" '                                                             no, report error to programmer
  597.     END IF
  598.     IF flip < 0 OR flip > 3 THEN '                                                                      valid flip behavior requested?
  599.         SL_ERROR "SL_STAMP_SPRITE", 3, "" '                                                             no, report error to programmer
  600.     END IF
  601.     IF zoom < 1 THEN '                                                                                  valid zoom level requested?
  602.         SL_ERROR "SL_STAMP_SPRITE", 4, "" '                                                             no, report error to programmer
  603.     END IF
  604.  
  605.     tempsprite = SL_NEW_SPRITE(sheet, column, row, 0, 0) '                                              create new temporary sprite
  606.     SL_sprite(tempsprite).rotation.speed = degree '                                                     set speed of rotation
  607.     SL_sprite(tempsprite).flip = flip '                                                                 set flipping behavior
  608.     SL_sprite(tempsprite).zoom = zoom '                                                                 set zoom level
  609.     SL_PUT_SPRITE x, y, tempsprite '                                                                    place sprite on current destination
  610.     SL_FREE_SPRITE tempsprite '                                                                         temporary sprite no longer needed
  611.  
  612.  
  613. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  614. SUB SL_UPDATE_AUTO_SPRITES () '                                                                                                                                                  SL_UPDATE_AUTO_SPRITES
  615.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  616.  
  617.     ' declare global variables
  618.  
  619.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  620.  
  621.     ' declare local variables
  622.  
  623.     DIM handle AS INTEGER '             handle of sprite
  624.     DIM nextcell AS INTEGER '           next animation cell
  625.  
  626.     ' local variable setup
  627.  
  628.     handle = 0 '                                                                                        initialize handle counter
  629.     DO '                                                                                                cycle through all sprite indexes
  630.         handle = handle + 1 '                                                                           increment to next sprite handle
  631.         IF SL_sprite(handle).inuse AND (SL_sprite(handle).motion.auto OR _
  632.                                         SL_sprite(handle).rotation.auto OR _
  633.                                         SL_sprite(handle).anim.auto) THEN '                             is this sprite being used and automagically controlled?
  634.             IF SL_sprite(handle).motion.auto THEN '                                                     yes, is auto motion enabled?
  635.                 SL_sprite(handle).x.real = SL_sprite(handle).x.real + SL_sprite(handle).x.dir '         yes, update x location
  636.                 SL_sprite(handle).y.real = SL_sprite(handle).y.real + SL_sprite(handle).y.dir '         update y location
  637.             END IF
  638.             IF SL_sprite(handle).rotation.auto THEN '                                                   is auto rotation enabled?
  639.                 SL_sprite(handle).rotation.angle = SL_FIX_DEGREES(SL_sprite(handle).rotation.angle_
  640.                                                                 + SL_sprite(handle).rotation.speed) '   yes, rotate sprite to next degree angle
  641.             END IF
  642.             IF SL_sprite(handle).anim.auto THEN '                                                       is auto animation enabled?
  643.                 SL_sprite(handle).anim.frame = SL_sprite(handle).anim.frame + 1 '                       increment animation frame counter
  644.                 IF SL_sprite(handle).anim.frame <> SL_sprite(handle).anim.skip OR SL_sprite(handle).anim.skip = 0 THEN ' draw this frame?
  645.                     nextcell = SL_sprite(handle).anim.cell + SL_sprite(handle).anim.dir '               yes, get next animation cell based on direction
  646.                     SELECT CASE SL_sprite(handle).anim.mode '                                           which animation mode is this sprite using?
  647.                         CASE 0 '                                                          (SL_FORWARD)  move forward through the cells
  648.                             IF nextcell > SL_sprite(handle).anim.cellto THEN '                          has the last cell been reached?
  649.                                 SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cellfrom '         yes, reset back to the first cell
  650.                             END IF
  651.                         CASE 1 '                                                         (SL_BACKWARD)  move backward through the cells
  652.                             IF nextcell < SL_sprite(handle).anim.cellfrom THEN '                        has the first cell been reached?
  653.                                 SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cellto '           yes, reset back to the last cell
  654.                             END IF
  655.                         CASE 2 '                                                        (SL_BACKFORTH)  ping-pong back and forth through the cells
  656.                             SL_sprite(handle).anim.cell = nextcell '                                    make this cell the current
  657.                             IF nextcell = SL_sprite(handle).anim.cellto OR nextcell = SL_sprite(handle).anim.cellfrom THEN ' was this the first or last cell?
  658.                                 SL_sprite(handle).anim.dir = -SL_sprite(handle).anim.dir '              yes, reverse animation direction
  659.                             END IF
  660.                     END SELECT
  661.                     SL_sprite(handle).column = SL_GET_COLUMN(SL_sprite(handle).sheet, SL_sprite(handle).anim.cell) ' get cell column on sheet
  662.                     SL_sprite(handle).row = SL_GET_ROW(SL_sprite(handle).sheet, SL_sprite(handle).anim.cell) '       get cell row on sheet
  663.                 ELSE '                                                                                  no, skip this frame
  664.                     SL_sprite(handle).anim.frame = 0 '                                                  reset frame counter
  665.                 END IF
  666.             END IF
  667.             SL_PUT_SPRITE SL_sprite(handle).x.real, SL_sprite(handle).y.real, handle '                  update sprite location, rotation, and animation
  668.         END IF
  669.     LOOP UNTIL handle = UBOUND(SL_sprite) '                                                             leave when all indexes checked
  670.  
  671.  
  672. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  673. SUB SL_UPDATE_MOTION (handle AS INTEGER) '                                                                                                                                             SL_UPDATE_MOTION
  674.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  675.  
  676.     ' declare global variables
  677.  
  678.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  679.  
  680.     ' perform error checks
  681.  
  682.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  683.         SL_ERROR "SL_UPDATE_MOTION", 1, "" '                                                              no, report error to programmer
  684.     END IF
  685.     IF SL_sprite(handle).motion.auto THEN '                                                             attempt to move sprite under automatic control?
  686.         SL_ERROR "SL_UPDATE_MOTION", 170, "" '                                                            yes, report error to programmer
  687.     END IF
  688.  
  689.     SL_sprite(handle).x.real = SL_sprite(handle).x.real + SL_sprite(handle).x.dir '                     update x location
  690.     SL_sprite(handle).y.real = SL_sprite(handle).y.real + SL_sprite(handle).y.dir '                     update y location
  691.     SL_PUT_SPRITE SL_sprite(handle).x.real, SL_sprite(handle).y.real, handle '                          update sprite location
  692.  
  693.  
  694. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  695. SUB SL_UPDATE_ROTATION (handle AS INTEGER) '                                                                                                                                         SL_UPDATE_ROTATION
  696.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  697.  
  698.     ' declare global variables
  699.  
  700.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  701.  
  702.     ' perform error checks
  703.  
  704.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  705.         SL_ERROR "SL_UPDATE_ROTATION", 1, "" '                                                          no, report error to programmer
  706.     END IF
  707.     IF SL_sprite(handle).rotation.auto THEN '                                                           attempt to rotate sprite under automatic control?
  708.         SL_ERROR "SL_UPDATE_ROTATION", 180, "" '                                                        yes, report error to programmer
  709.     END IF
  710.  
  711.     SL_ROTATE_SPRITE handle, SL_sprite(handle).rotation.angle + SL_sprite(handle).rotation.speed '       rotate sprite to next degree angle
  712.     SL_PUT_SPRITE SL_sprite(handle).x.real, SL_sprite(handle).y.real, handle '                          update sprite rotation
  713.  
  714.  
  715. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  716. SUB SL_SET_MOTION (handle AS INTEGER, degrees AS INTEGER, speed AS SINGLE, auto AS INTEGER) '                                                                                            SL_SET_MOTION
  717.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  718.  
  719.     ' declare global variables
  720.  
  721.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  722.  
  723.     ' perform error checks
  724.  
  725.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  726.         SL_ERROR "SL_SET_DIRECTION", 1, "" '                                                            no, report error to programmer
  727.     END IF
  728.     IF auto < -1 OR auto > 0 THEN '                                               (SL_START & SL_STOP)  valid on/off switch supplied?
  729.         SL_ERROR "SL_CHANGE_AUTOMOTION", 7, "" '                                                           no, report error to programmer
  730.     END IF
  731.  
  732.     SL_sprite(handle).motion.speed = speed '                                                            set motion speed of sprite
  733.     SL_CHANGE_MOTION_DIRECTION handle, degrees '                                                           set motion angle of sprite
  734.     SL_sprite(handle).motion.auto = auto '                                        (SL_START & SL_STOP)  set auto-motion of sprite
  735.  
  736.  
  737.  
  738. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  739. SUB SL_CHANGE_MOTION_DIRECTION (handle AS INTEGER, degrees AS INTEGER) '                                                                                                     SL_CHANGE_MOTION_DIRECTION
  740.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  741.  
  742.     ' declare global variables
  743.  
  744.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  745.  
  746.     ' delcare local variables
  747.  
  748.     DIM degree AS INTEGER '             degree angle passed in
  749.  
  750.     ' perform error checks
  751.  
  752.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  753.         SL_ERROR "SL_CHANGE_MOTION_DIRECTION", 1, "" '                                                  no, report error to programmer
  754.     END IF
  755.  
  756.     degree = SL_FIX_DEGREES(degrees) '                                                                  get degree angle passed in
  757.  
  758.     SL_sprite(handle).motion.angle = degree '                                                           set motion degree angle
  759.     SL_sprite(handle).x.dir = SIN(degree * 3.1415926 / 180) * SL_sprite(handle).motion.speed '          calculate x vector
  760.     SL_sprite(handle).y.dir = -COS(degree * 3.1415926 / 180) * SL_sprite(handle).motion.speed '         calculate y vector
  761.  
  762.  
  763. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  764. FUNCTION SL_GET_MOTION_DIRECTION (handle AS INTEGER) '                                                                                                                          SL_GET_MOTION_DIRECTION
  765.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  766.  
  767.     ' declare global variables
  768.  
  769.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  770.  
  771.     ' perform error checks
  772.  
  773.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  774.         SL_ERROR "SL_GET_MOTION_DIRECTION", 1, "" '                                                     no, report error to programmer
  775.     END IF
  776.  
  777.     SL_GET_MOTION_DIRECTION = SL_sprite(handle).motion.angle '                                          return direction sprite currently set to
  778.  
  779.  
  780. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  781. SUB SL_CHANGE_MOTION_SPEED (handle AS INTEGER, speed AS SINGLE) '                                                                                                                SL_CHANGE_MOTION_SPEED
  782.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  783.  
  784.     ' declare global variables
  785.  
  786.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  787.  
  788.     ' perform error checks
  789.  
  790.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  791.         SL_ERROR "SL_CHANGE_MOTION_SPEED", 1, "" '                                                      no, report error to programmer
  792.     END IF
  793.  
  794.     SL_sprite(handle).motion.speed = speed '                                                            set sprite motion speed
  795.     SL_sprite(handle).x.dir = SIN(SL_sprite(handle).motion.angle * 3.1415926 / 180) * speed '           calculate x vector
  796.     SL_sprite(handle).y.dir = -COS(SL_sprite(handle).motion.angle * 3.1415926 / 180) * speed '          calculate y vector
  797.  
  798.  
  799. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  800. FUNCTION SL_GET_MOTION_SPEED (handle AS INTEGER) '                                                                                                                                  SL_GET_MOTION_SPEED
  801.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  802.  
  803.     ' declare global variables
  804.  
  805.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  806.  
  807.     ' perform error checks
  808.  
  809.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  810.         SL_ERROR "SL_GET_MOTION_SPEED", 1, "" '                                                         no, report error to programmer
  811.     END IF
  812.  
  813.     SL_GET_MOTION_SPEED = SL_sprite(handle).motion.speed '                                              return current sprite motion speed
  814.  
  815.  
  816. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  817. SUB SL_CHANGE_AUTOMOTION (handle AS INTEGER, auto AS INTEGER) '                                                                                                                    SL_CHANGE_AUTOMOTION
  818.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  819.  
  820.     ' declare global variables
  821.  
  822.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  823.  
  824.     IF auto = -32767 THEN '                                                                 (SL_RESET)  reset auto motion?
  825.         SL_sprite(handle).motion.auto = 0 '                                                    (FALSE)  yes, turn auto motion off
  826.         EXIT SUB '                                                                                      leave subroutine
  827.     END IF
  828.  
  829.     ' perform error checks
  830.  
  831.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  832.         SL_ERROR "SL_CHANGE_AUTOMOTION", 1, "" '                                                        no, report error to programmer
  833.     END IF
  834.     IF auto < -1 OR auto > 0 THEN '                                               (SL_START & SL_STOP)  valid on/off switch supplied?
  835.         SL_ERROR "SL_CHANGE_AUTOMOTION", 7, "" '                                                        no, report error to programmer
  836.     END IF
  837.  
  838.     SL_sprite(handle).motion.auto = auto '                                              (TRUE & FALSE)  set auto motion status
  839.  
  840.  
  841. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  842. FUNCTION SL_GET_AUTOMOTION (handle AS INTEGER) '                                                                                                                                      SL_GET_AUTOMOTION
  843.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  844.  
  845.     ' declare global variables
  846.  
  847.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  848.  
  849.     ' perform error checks
  850.  
  851.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  852.         SL_ERROR "SL_GET_AUTOMOTION", 1, "" '                                                           no, report error to programmer
  853.     END IF
  854.  
  855.     SL_GET_AUTOMOTION = SL_sprite(handle).motion.auto '                                 (TRUE & FALSE)  return auto motion status
  856.  
  857.  
  858. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  859. SUB SL_SET_ROTATION (handle AS INTEGER, degrees AS INTEGER, speed AS INTEGER, auto AS INTEGER) '                                                                                        SL_SET_ROTATION
  860.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  861.  
  862.     ' declare global variables
  863.  
  864.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  865.  
  866.     ' perform error checks
  867.  
  868.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  869.         SL_ERROR "SL_SET_ROTATION", 1, "" '                                                             no, report error to programmer
  870.     END IF
  871.     IF auto < -1 OR auto > 0 THEN '                                               (SL_START & SL_STOP)  valid on/off switch supplied?
  872.         SL_ERROR "SL_SET_ROTATION", 8, "" '                                                             no, report error to programmer
  873.     END IF
  874.     IF ABS(degrees) > 359 THEN '                                                                        degree requested between -359 and 359?
  875.         SL_ERROR "SL_SET_ROTATION", 9, "" '                                                             no, report error to programmer
  876.     END IF
  877.  
  878.     SL_sprite(handle).rotation.speed = speed '                                                          set rotation speed
  879.     SL_ROTATE_SPRITE handle, degrees '                                                                  set start angle
  880.     SL_sprite(handle).rotation.auto = auto '                                                            set auto-rotation
  881.  
  882.  
  883. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  884. SUB SL_CHANGE_AUTOROTATION (handle AS INTEGER, auto AS INTEGER) '                                                                                                                SL_CHANGE_AUTOROTATION
  885.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  886.  
  887.     ' declare global variables
  888.  
  889.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  890.  
  891.     IF auto = -32767 THEN '                                                                 (SL_RESET)  reset auto rotate?
  892.         SL_sprite(handle).rotation.auto = 0 '                                                  (FALSE)  yes, turn auto rotation off
  893.         EXIT SUB '                                                                                      leave subroutine
  894.     END IF
  895.  
  896.     ' perform error checks
  897.  
  898.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  899.         SL_ERROR "SL_CHANGE_AUTOROTATION", 1, "" '                                                      no, report error to programmer
  900.     END IF
  901.     IF auto < -1 OR auto > 0 THEN '                                               (SL_START & SL_STOP)  valid on/off switch supplied?
  902.         SL_ERROR "SL_CHANGE_AUTOROTATION", 8, "" '                                                      no, report error to programmer
  903.     END IF
  904.  
  905.     SL_sprite(handle).rotation.auto = auto '                                            (TRUE & FALSE)  set auto rotation status
  906.  
  907.  
  908. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  909. FUNCTION SL_GET_AUTOROTATION (handle AS INTEGER) '                                                                                                                                  SL_GET_AUTOROTATION
  910.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  911.  
  912.     ' declare global variables
  913.  
  914.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  915.  
  916.     ' perform error checks
  917.  
  918.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  919.         SL_ERROR "SL_GET_AUTOROTATION", 1, "" '                                                         no, report error to programmer
  920.     END IF
  921.  
  922.     SL_GET_AUTOROTATION = SL_sprite(handle).rotation.auto '                               (TRUE & FALSE)  return auto rotation status
  923.  
  924.  
  925. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  926. SUB SL_CHANGE_ROTATION_SPEED (handle AS INTEGER, degrees AS INTEGER) '                                                                                                         SL_CHANGE_ROTATION_SPEED
  927.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  928.  
  929.     ' declare global variables
  930.  
  931.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  932.  
  933.     ' perform error checks
  934.  
  935.     IF degrees = -32767 THEN '                                                              (SL_RESET)  reset requested?
  936.         SL_sprite(handle).rotation.speed = 0 '                                               (SL_STOP)  turn auto spin off
  937.         EXIT SUB '                                                                                      leave subroutine
  938.     END IF
  939.  
  940.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  941.         SL_ERROR "SL_CHANGE_ROTATION_SPEED", 1, "" '                                                    no, report error to programmer
  942.     END IF
  943.     IF ABS(degrees) > 359 THEN '                                                                        degree requested between -359 and 359?
  944.         SL_ERROR "SL_CHANGE_ROTATION_SPEED", 9, "" '                                                    no, report error to programmer
  945.     END IF
  946.  
  947.     SL_sprite(handle).rotation.speed = degrees '                                                        set sprite spin rate
  948.  
  949.  
  950. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  951. FUNCTION SL_GET_ROTATION_SPEED (handle AS INTEGER) '                                                                                                                              SL_GET_ROTATION_SPEED
  952.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  953.  
  954.     ' declare global variables
  955.  
  956.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  957.  
  958.     ' perform error checks
  959.  
  960.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  961.         SL_ERROR "SL_GET_ROTATION_SPEED", 1, "" '                                                       no, report error to programmer
  962.     END IF
  963.  
  964.     SL_GET_ROTATION_SPEED = SL_sprite(handle).rotation.speed '                                          return current sprite spin rate
  965.  
  966.  
  967. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  968. 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
  969.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  970.  
  971.     'declare local variables
  972.  
  973.     DIM a AS INTEGER '                  side a of triangle
  974.     DIM b AS INTEGER '                  side b of triangle
  975.  
  976.     'solve for c (hypotenuse)
  977.  
  978.     a = x1 - x2 '                                                                                       get length of side a
  979.     b = y1 = y2 '                                                                                       get length of side b
  980.  
  981.     SL_GET_DISTANCE_POINT_TO_POINT = INT(SQR(a * a + b * b)) '                                          return length of side c
  982.  
  983.  
  984. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  985. FUNCTION SL_GET_DISTANCE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                 SL_GET_DISTANCE_TO_SPRITE
  986.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  987.  
  988.     ' declare global variables
  989.  
  990.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  991.  
  992.     'perform error checks
  993.  
  994.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  995.         SL_ERROR "SL_GET_DISTANCE_TO_SPRITE", 1, "" '                                                   no, report error to programmer
  996.     END IF
  997.  
  998.     SL_GET_DISTANCE_TO_SPRITE = SL_GET_DISTANCE_POINT_TO_POINT(SL_sprite(handle1).x.int, SL_sprite(handle1).y.int, _
  999.                                                                SL_sprite(handle2).x.int, SL_sprite(handle2).y.int) '  return distance to sprite 2
  1000.  
  1001.  
  1002. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1003. FUNCTION SL_GET_DISTANCE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                                                            SL_GET_DISTANCE_TO_POINT
  1004.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1005.  
  1006.     ' declare global variables
  1007.  
  1008.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1009.  
  1010.     'perform error checks
  1011.  
  1012.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1013.         SL_ERROR "SL_GET_DISTANCE_TO_POINT", 1, "" '                                                    no, report error to programmer
  1014.     END IF
  1015.  
  1016.     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
  1017.  
  1018.  
  1019. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1020. 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
  1021.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1022.  
  1023.     'declare local variables
  1024.  
  1025.     DIM angle AS INTEGER '              angle from first x,y location to second x,y location
  1026.  
  1027.     IF y1 = y2 THEN '                                                                                   both y values same?
  1028.         IF x1 = x2 THEN '                                                                               yes, both x values same?
  1029.             EXIT FUNCTION '                                                                             yes, there is no angle (0), leave
  1030.         END IF
  1031.         IF x2 > x1 THEN '                                                                               is second x to the right of first x?
  1032.             SL_GET_ANGLE_POINT_TO_POINT = 90 '                                                          yes, the angle must be 90 degrees
  1033.         ELSE '                                                                                          no, second x is to the left of first x
  1034.             SL_GET_ANGLE_POINT_TO_POINT = 270 '                                                         the angle must be 270 degrees
  1035.         END IF
  1036.         EXIT FUNCTION '                                                                                 leave function, angle computed
  1037.     END IF
  1038.     IF x1 = x2 THEN '                                                                                   both x values same?
  1039.         IF y2 > y1 THEN '                                                                               yes, is second y lower than first y?
  1040.             SL_GET_ANGLE_POINT_TO_POINT = 180 '                                                         yes, the angle must be 180
  1041.         END IF
  1042.         EXIT FUNCTION '                                                                                 leave function, angle computed (angle is 0 if no calculation done)
  1043.     END IF
  1044.     angle = ATN((x2 - x1) / (y2 - y1)) * -57.2957795131 '                                               calculate initial angle
  1045.     IF y2 < y1 THEN '                                                                                   is second y higher than first y?
  1046.         IF x2 > x1 THEN '                                                                               yes, is second x to right of first x?
  1047.             SL_GET_ANGLE_POINT_TO_POINT = angle '                                                       yes, angle needs no adjustment
  1048.         ELSE '                                                                                          no, second x is to left of first x
  1049.             SL_GET_ANGLE_POINT_TO_POINT = angle + 360 '                                                 adjust angle accordingly
  1050.         END IF
  1051.     ELSE '                                                                                              no, second y is lower than first y
  1052.         SL_GET_ANGLE_POINT_TO_POINT = angle + 180 '                                                     adjust angle accordingly
  1053.     END IF
  1054.  
  1055.  
  1056. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1057. FUNCTION SL_GET_ANGLE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                       SL_GET_ANGLE_TO_SPRITE
  1058.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1059.  
  1060.     ' declare global variables
  1061.  
  1062.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1063.  
  1064.     'perform error checks
  1065.  
  1066.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  1067.         SL_ERROR "SL_GET_ANGLE_TO_SPRITE", 1, "" '                                                      no, report error to programmer
  1068.     END IF
  1069.  
  1070.     SL_GET_ANGLE_TO_SPRITE = SL_GET_ANGLE_POINT_TO_POINT(SL_sprite(handle1).x.int, SL_sprite(handle1).y.int, _
  1071.                                                          SL_sprite(handle2).x.int, SL_sprite(handle2).y.int) ' return angle to sprite 2
  1072.  
  1073.  
  1074. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1075. FUNCTION SL_GET_ANGLE_FROM_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                   SL_GET_ANGLE_FROM_SPRITE
  1076.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1077.  
  1078.     ' declare global variables
  1079.  
  1080.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1081.  
  1082.     'perform error checks
  1083.  
  1084.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  1085.         SL_ERROR "SL_GET_ANGLE_FROM_SPRITE", 1, "" '                                                    no, report error to programmer
  1086.     END IF
  1087.  
  1088.     SL_GET_ANGLE_FROM_SPRITE = SL_GET_ANGLE_POINT_TO_POINT(SL_sprite(handle2).x.int, SL_sprite(handle2).y.int, _
  1089.                                                            SL_sprite(handle1).x.int, SL_sprite(handle1).y.int) '  return angle from sprite 2
  1090.  
  1091.  
  1092. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1093. FUNCTION SL_GET_ANGLE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                                                                  SL_GET_ANGLE_TO_POINT
  1094.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1095.  
  1096.     ' declare global variables
  1097.  
  1098.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1099.  
  1100.     'perform error checks
  1101.  
  1102.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1103.         SL_ERROR "SL_GET_ANGLE_TO_POINT", 1, "" '                                                       no, report error to programmer
  1104.     END IF
  1105.  
  1106.     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
  1107.  
  1108.  
  1109. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1110. FUNCTION SL_GET_ANGLE_FROM_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                                                              SL_GET_ANGLE_FROM_POINT
  1111.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1112.  
  1113.     ' declare global variables
  1114.  
  1115.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1116.  
  1117.     'perform error checks
  1118.  
  1119.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1120.         SL_ERROR "SL_GET_ANGLE_FROM_POINT", 1, "" '                                                     no, report error to programmer
  1121.     END IF
  1122.  
  1123.     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
  1124.  
  1125.  
  1126. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1127. SUB SL_SET_SOFTWARE (handle AS INTEGER, restores AS INTEGER) '                                                                                                                          SL_SET_SOFTWARE
  1128.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1129.  
  1130.     ' declare global variables
  1131.  
  1132.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1133.  
  1134.     'perform error checks
  1135.  
  1136.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1137.         SL_ERROR "SL_SET_SOFTWARE", 1, "" '                                                             no, report error to programmer
  1138.     END IF
  1139.     IF restores < -1 OR restores > 0 THEN '                                                             valid background restoration behavior requested?
  1140.         SL_ERROR "SL_SET_SOFTWARE", 2, "" '                                                             no, report error to programmer
  1141.     END IF
  1142.  
  1143.     SL_sprite(handle).software = -1 '                                                    (SL_SOFTWARE)  set sprite to software mode
  1144.     SL_sprite(handle).restore = restores '                                       (SL_SAVE & SL_NOSAVE)  set background saving behavior
  1145.  
  1146.  
  1147. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1148. SUB SL_SET_HARDWARE (handle AS INTEGER) '                                                                                                                                               SL_SET_HARDWARE
  1149.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1150.  
  1151.     ' declare global variables
  1152.  
  1153.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1154.  
  1155.     'perform error checks
  1156.  
  1157.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1158.         SL_ERROR "SL_SET_HARDWARE", 1, "" '                                                             no, report error to programmer
  1159.     END IF
  1160.  
  1161.     SL_sprite(handle).software = 0 '                                                     (SL_HARDWARE)  set sprite to hardware mode
  1162.  
  1163.  
  1164. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1165. SUB SL_SET_ZOOM (handle AS INTEGER, zoom AS INTEGER) '                                                                                                                                      SL_SET_ZOOM
  1166.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1167.  
  1168.     ' declare global variables
  1169.  
  1170.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1171.  
  1172.     IF zoom = -32767 THEN '                                                                 (SL_RESET)  reset zoom level?
  1173.         SL_sprite(handle).zoom = 100 '                                                                  yes, reset level to normal
  1174.         EXIT SUB '                                                                                      leave subroutine
  1175.     END IF
  1176.  
  1177.     ' perform error checks (errors 130-139)
  1178.  
  1179.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1180.         SL_ERROR "SL_SET_ZOOM", 1, "" '                                                                 no, report error to programmer
  1181.     END IF
  1182.     IF zoom < 1 THEN '                                                                                  valid zoom level requested?
  1183.         SL_ERROR "SL_SET_ZOOM", 4, "" '                                                                 no, report error to programmer
  1184.     END IF
  1185.  
  1186.     SL_sprite(handle).zoom = zoom '                                                                     set zoom level
  1187.  
  1188.  
  1189.  
  1190. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1191. SUB SL_ROTATE_SPRITE (handle AS INTEGER, degrees AS INTEGER) '                                                                                                                         SL_ROTATE_SPRITE
  1192.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1193.  
  1194.     ' declare global variables
  1195.  
  1196.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1197.  
  1198.     ' declare local variables
  1199.  
  1200.     DIM degree AS INTEGER '             degree angle passed in
  1201.  
  1202.     ' perform error checks
  1203.  
  1204.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1205.         SL_ERROR "SL_ROTATE_SPRITE", 1, "" '                                                            no, report error to programmer
  1206.     END IF
  1207.  
  1208.     'handle reset request
  1209.  
  1210.     IF degrees = -32767 THEN '                                                              (SL_RESET)  reset sprite rotation?
  1211.         SL_sprite(handle).rotation.angle = 0 '                                                          reset rotation angle
  1212.         EXIT SUB '                                                                                      leave subroutine
  1213.     END IF
  1214.  
  1215.     degree = SL_FIX_DEGREES(degrees) '                                                                  get degree angle passed in
  1216.     SL_sprite(handle).rotation.angle = degree '                                                         set degree of rotation
  1217.  
  1218.  
  1219. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1220. SUB SL_FLIP_SPRITE (handle AS INTEGER, flip AS INTEGER) '                                                                                                                                SL_FLIP_SPRITE
  1221.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1222.  
  1223.     ' declare global variables
  1224.  
  1225.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1226.  
  1227.     ' check for subroutine reset
  1228.  
  1229.     IF flip = -32767 THEN '                                                                 (SL_RESET)  reset flipping behavior?
  1230.         SL_sprite(handle).flip = 0 '                                                       (SL_NOFLIP)  yes, reset flip value
  1231.         EXIT SUB '                                                                                      leave subroutine
  1232.     END IF
  1233.  
  1234.     ' perform error checks
  1235.  
  1236.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1237.         SL_ERROR "SL_FLIP_SPRITE", 1, "" '                                                              no, report error to programmer
  1238.     END IF
  1239.     IF flip < 0 OR flip > 3 THEN '                                                                      valid flip behavior requested?
  1240.         SL_ERROR "SL_FLIP_SPRITE", 3, "" '                                                              no, report error to programmer
  1241.     END IF
  1242.  
  1243.     SL_sprite(handle).flip = flip '                                                                     set flipping behavior
  1244.  
  1245.  
  1246. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1247. SUB SL_PUT_SPRITE (x AS SINGLE, y AS SINGLE, handle AS INTEGER) '                                                                                                                         SL_PUT_SPRITE
  1248.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1249.  
  1250.     ' declare global variables
  1251.  
  1252.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  1253.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1254.     SHARED SL_rotate() AS SL_ROTATE '   precalculated rotation table
  1255.  
  1256.     ' declare local variables
  1257.  
  1258.     DIM xa AS INTEGER '                 actual x location of sprite on screen
  1259.     DIM ya AS INTEGER '                 actual y location of sprite on screen
  1260.     DIM sw AS INTEGER '                 width of sprite to be drawn
  1261.     DIM sh AS INTEGER '                 height of sprite to be drawn
  1262.     DIM rw AS INTEGER '                 precalculated rotated sprite width
  1263.     DIM rh AS INTEGER '                 precalculated rotated sprite height
  1264.     DIM px0 AS INTEGER '                precalculated triangular coordinates
  1265.     DIM px1 AS INTEGER
  1266.     DIM px2 AS INTEGER
  1267.     DIM px3 AS INTEGER
  1268.     DIM py0 AS INTEGER
  1269.     DIM py1 AS INTEGER
  1270.     DIM py2 AS INTEGER
  1271.     DIM py3 AS INTEGER
  1272.     DIM image AS LONG '                 software sprite image
  1273.     DIM mask AS LONG '                  software sprite image mask
  1274.     DIM sprite AS LONG '                hardware sprite image
  1275.  
  1276.     ' perform error checks
  1277.  
  1278.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1279.         SL_ERROR "SL_PUT_SPRITE", 1, "" '                                                               no, report error to programmer
  1280.     END IF
  1281.  
  1282.     ' check for auto motion
  1283.  
  1284.     'IF SL_sprite(handle).automotion THEN '                                                              is this sprite auto motion?
  1285.     '    EXIT SUB '                                                                                      yes, SL_UPDATE_AUTO_SPRITES handles it, leave subroutine
  1286.     'END IF
  1287.  
  1288.     'local variable setup
  1289.  
  1290.     SL_sprite(handle).x.real = x '                                                            (SINGLE)  save requested x center location
  1291.     SL_sprite(handle).y.real = y '                                                            (SINGLE)  save requested y center location
  1292.     SL_sprite(handle).x.int = INT(x) '                                                       (INTEGER)  save screen x center location
  1293.     SL_sprite(handle).y.int = INT(y) '                                                       (INTEGER)  save screen y center location
  1294.     image = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).image '  get image from sprite sheet
  1295.     mask = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).mask '    get mask from sprite sheet
  1296.     sw = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).swidth 'get default sprite width from sprite sheet
  1297.     sh = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).sheight 'get default sprite height from sprite sheet
  1298.  
  1299.     'free existing images
  1300.  
  1301.     _FREEIMAGE SL_sprite(handle).gfx.sprite '                                                           free hardware sprite image
  1302.     _FREEIMAGE SL_sprite(handle).gfx.image '                                                            free software sprite image
  1303.     IF SL_sprite(handle).gfx.mask THEN _FREEIMAGE SL_sprite(handle).gfx.mask '                          free software mask image
  1304.     IF SL_sprite(handle).restore THEN '                                                                 is sprite holding a background image?
  1305.         IF SL_sprite(handle).gfx.back THEN '                                                            yes, has a background image been saved yet?
  1306.             _PUTIMAGE (SL_sprite(handle).x.back, SL_sprite(handle).y.back), SL_sprite(handle).gfx.back 'yes, replace background with image
  1307.             _FREEIMAGE SL_sprite(handle).gfx.back '                                                     free hardware background image
  1308.         END IF
  1309.         IF NOT SL_sprite(handle).software THEN '                                                        was the sprite type changed?
  1310.             SL_sprite(handle).restore = 0 '                                                (SL_NOSAVE)  yes, stop saving background
  1311.         END IF
  1312.     END IF
  1313.  
  1314.     'adjust sprite rotation if needed
  1315.  
  1316.     IF SL_sprite(handle).rotation.angle THEN '                                                          rotate sprite?
  1317.         px0 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).px0 '                      yes, get precalculated triangular coordinates
  1318.         px1 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).px1
  1319.         px2 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).px2
  1320.         px3 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).px3
  1321.         py0 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).py0
  1322.         py1 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).py1
  1323.         py2 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).py2
  1324.         py3 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).py3
  1325.         rw = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).rwidth '                    get precalculated rotated sprite width
  1326.         rh = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).rheight '                   get precalculated rotated sprite height
  1327.         SL_sprite(handle).gfx.image = _NEWIMAGE(rw, rh, 32) '                                           create image using precalculated width/height
  1328.         _MAPTRIANGLE (0, 0)-(0, sh-1)-(sw-1, sh-1), image TO _
  1329.                      (px0, py0)-(px1, py1)-(px2, py2), SL_sprite(handle).gfx.image '                    map rotated sprite onto image
  1330.         _MAPTRIANGLE (0, 0)-(sw-1, 0)-(sw-1, sh-1), image TO _
  1331.                      (px0, py0)-(px3, py3)-(px2, py2), SL_sprite(handle).gfx.image
  1332.         IF SL_sprite(handle).transparency THEN '                                                        does this sprite have a mask?
  1333.             SL_sprite(handle).gfx.mask = _NEWIMAGE(rw, rh, 32) '                                        yes, create mask image
  1334.             _MAPTRIANGLE (0, 0)-(0, sh-1)-(sw-1, sh-1), mask TO _
  1335.                          (px0, py0)-(px1, py1)-(px2, py2), SL_sprite(handle).gfx.mask '                 map rotated mask onto image
  1336.             _MAPTRIANGLE (0, 0)-(sw-1, 0)-(sw-1, sh-1), mask TO _
  1337.                          (px0, py0)-(px3, py3)-(px2, py2), SL_sprite(handle).gfx.mask
  1338.         END IF
  1339.         sw = rw '                                                                                       save new sprite width
  1340.         sh = rh '                                                                                       save new sprite height
  1341.     ELSE '                                                                                              no rotation needed
  1342.         SL_sprite(handle).gfx.image = _COPYIMAGE(image, 32) '                                           copy software image from sprite sheet
  1343.         IF SL_sprite(handle).transparency THEN '                                                        does this sprite have a mask?
  1344.             SL_sprite(handle).gfx.mask = _COPYIMAGE(mask, 32) '                                         yes, copy software mask from sprite sheet
  1345.         END IF
  1346.     END IF
  1347.  
  1348.     'create hardware sprite
  1349.  
  1350.     SL_sprite(handle).gfx.sprite = _COPYIMAGE(SL_sprite(handle).gfx.image, 33) '                        create hardware sprite of image
  1351.  
  1352.     'adjust zoom level if needed
  1353.  
  1354.     IF SL_sprite(handle).zoom <> 100 THEN '                                                             zoom sprite in/out?
  1355.         sw = sw * SL_sprite(handle).zoom \ 100 '                                                        yes, calculate new zoom width
  1356.         sh = sh * SL_sprite(handle).zoom \ 100 '                                                        calculate new zoom height
  1357.     END IF
  1358.  
  1359.     'calculate actual sprite screen coordinates
  1360.  
  1361.     xa = SL_sprite(handle).x.int - sw \ 2 '                                                             calculate actual screen x location from center
  1362.     ya = SL_sprite(handle).y.int - sh \ 2 '                                                             calculate actual screen y location from center
  1363.     SL_sprite(handle).x.actual = xa '                                                        (INTEGER)  save actual screen x location
  1364.     SL_sprite(handle).y.actual = ya '                                                        (INTEGER)  save actual screen y location
  1365.  
  1366.     'get background image before placing sprite if necessary
  1367.  
  1368.     IF SL_sprite(handle).restore THEN '                                                                 is this sprite storing background images?
  1369.         SL_sprite(handle).gfx.back = _NEWIMAGE(sw, sh, 32) '                                            yes, create background image
  1370.         _PUTIMAGE , _DEST, SL_sprite(handle).gfx.back, (xa, ya)-(xa + sw - 1, ya + sh - 1) '            get background area from current destination
  1371.         SL_sprite(handle).x.back = xa '                                                                 record background x location
  1372.         SL_sprite(handle).y.back = ya '                                                                 record background y location
  1373.     END IF
  1374.  
  1375.     'use hardware or software image
  1376.  
  1377.     IF SL_sprite(handle).software THEN '                                                                is this a software sprite?
  1378.         sprite = SL_sprite(handle).gfx.image '                                                          yes, use the software image
  1379.     ELSE '                                                                                              no
  1380.         sprite = SL_sprite(handle).gfx.sprite '                                                         use the hardware image
  1381.     END IF
  1382.  
  1383.     ' place sprite on the current destination
  1384.  
  1385.     SELECT CASE SL_sprite(handle).flip '                                                                which flipping style is selected?
  1386.         CASE 0 '                                                                           (SL_NOFLIP)  normal, no flipping
  1387.             _PUTIMAGE (xa, ya)-(xa + sw - 1, ya + sh - 1), sprite '                                     draw normal sprite
  1388.         CASE 1 '                                                                       (SL_HORIZONTAL)  flip horizontally
  1389.             _PUTIMAGE (xa + sw - 1, ya)-(xa, ya + sh - 1), sprite '                                     draw horizontally flipped sprite
  1390.         CASE 2 '                                                                         (SL_VERTICAL)  flip vertically
  1391.             _PUTIMAGE (xa, ya + sh - 1)-(xa + sw - 1, ya), sprite '                                     draw vertically flipped sprite
  1392.         CASE 3 '                                                                         (SL_FLIPBOTH)  flip vertically and horizontally
  1393.             _PUTIMAGE (xa + sw - 1, ya + sh - 1)-(xa, ya), sprite '                                     draw horizontally and vertically flipped sprite
  1394.     END SELECT
  1395.  
  1396.  
  1397. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1398. FUNCTION SL_NEW_SPRITE (sheet AS INTEGER, column AS INTEGER, row AS INTEGER, software AS INTEGER, restores AS INTEGER) '                                                                  SL_NEW_SPRITE
  1399.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1400.  
  1401.     ' declare global variables
  1402.  
  1403.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  1404.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1405.  
  1406.     ' declare local variables
  1407.  
  1408.     DIM handle AS INTEGER '             handle (pointer) number of new sprite
  1409.  
  1410.     ' perform error checks
  1411.  
  1412.     IF NOT SL_VALID_SHEET(sheet) THEN '                                                                 is this a valid sprite sheet?
  1413.         SL_ERROR "SL_NEW_SPRITE", 5, "" '                                                               no, report error to programmer
  1414.     END IF
  1415.     IF column > UBOUND(SL_sheet, 2) OR row > UBOUND(SL_sheet, 3) OR row < 1 OR column < 1 THEN '        valid row and column requested?
  1416.         SL_ERROR "SL_NEW_SPRITE", 6, "" '                                                               no, report error to programmer
  1417.     END IF
  1418.     IF restores < -1 OR restores > 0 THEN '                                                             valid background restoration behavior requested?
  1419.         SL_ERROR "SL_NEW_SPRITE", 2, "" '                                                               no, report error to programmer
  1420.     END IF
  1421.     IF software < -1 OR software > 0 THEN '                                                             valid hardware / software setting requested?
  1422.         SL_ERROR "SL_NEW_SPRITE", 112, "" '                                                             no, report error to programmer
  1423.     END IF
  1424.     IF (NOT software) AND restores THEN '                                                               hardware image that restores background?
  1425.         SL_ERROR "SL_NEW_SPRITE", 113, "" '                                                             yes, report error to programmer
  1426.     END IF
  1427.  
  1428.     ' local variable setup
  1429.  
  1430.     handle = 0 '                                                                                        initialize handle value
  1431.  
  1432.     ' increase sprite array's size if needed
  1433.  
  1434.     DO '                                                                                                look for next available handle
  1435.         handle = handle + 1 '                                                                           increment to next handle value
  1436.     LOOP UNTIL (NOT SL_sprite(handle).inuse) OR handle = UBOUND(SL_sprite) '                            stop looking when valid handle found
  1437.     IF SL_sprite(handle).inuse THEN '                                                                   is the last array element in use?
  1438.         handle = handle + 1 '                                                                           yes, increment to next handle value
  1439.         REDIM _PRESERVE SL_sprite(handle) AS SL_SPRITE '                                                increase the size of the sprite array
  1440.     END IF
  1441.  
  1442.     ' populate sprite array, general settings
  1443.  
  1444.     SL_sprite(handle).inuse = -1 '                                                              (TRUE)  mark array index as in use
  1445.     SL_sprite(handle).sheet = sheet '                                                                   point to sheet where sprite resides
  1446.     SL_sprite(handle).column = column '                                                                 point to column on sheet where sprite located
  1447.     SL_sprite(handle).row = row '                                                                       point to row on sheet where sprite located
  1448.     SL_sprite(handle).software = software '                                (SL_SOFTWARE & SL_HARDWARE)  sprite treated as software or hardware image
  1449.     SL_sprite(handle).restore = restores '                                       (SL_SAVE & SL_NOSAVE)  background restore behavior of sprite
  1450.     SL_sprite(handle).swidth = SL_sheet(sheet, column, row).swidth '                                    get width of sprite
  1451.     SL_sprite(handle).sheight = SL_sheet(sheet, column, row).sheight '                                  get height of sprite
  1452.     SL_sprite(handle).collx1 = SL_sheet(sheet, column, row).collx1 '                                    get sprite's collision box boundaries
  1453.     SL_sprite(handle).colly1 = SL_sheet(sheet, column, row).colly1
  1454.     SL_sprite(handle).collx2 = SL_sheet(sheet, column, row).collx2
  1455.     SL_sprite(handle).colly2 = SL_sheet(sheet, column, row).colly2
  1456.     SL_sprite(handle).flip = 0 '                                                                        no sprite flipping
  1457.     SL_sprite(handle).zoom = 100 '                                                                      zoom normal at 100%
  1458.  
  1459.     ' animation settings
  1460.  
  1461.     SL_sprite(handle).anim.cell = SL_sheet(sheet, column, row).cell '                                   the animation cell this sprite is in
  1462.     SL_sprite(handle).anim.cellfrom = 0 '                                                               reset sprite beginning animation cell
  1463.     SL_sprite(handle).anim.cellto = 0 '                                                                 reset sprite ending animation cell
  1464.     SL_sprite(handle).anim.dir = 0 '                           (SL_FORWARD, SL_BACKWARD & SLBACKFORTH)  reset sprite animation direction
  1465.     SL_sprite(handle).anim.mode = 0 '                                                                   reset sprite animation mode
  1466.     SL_sprite(handle).anim.frame = 0 '                                                                  reset sprite animation frame counter
  1467.     SL_sprite(handle).anim.skip = 0 '                                                                   reset sprite animation skip rate
  1468.     SL_sprite(handle).anim.auto = 0 '                                                          (FALSE)  sprite has no auto animation
  1469.  
  1470.     ' x,y locations
  1471.  
  1472.     SL_sprite(handle).x.real = 0 '                                                                      reset x location of sprite (center x)
  1473.     SL_sprite(handle).y.real = 0 '                                                                      reset y location of sprite (center y)
  1474.     SL_sprite(handle).x.int = 0 '                                                                       reset x location of sprite on screen INT(xreal) (center x)
  1475.     SL_sprite(handle).y.int = 0 '                                                                       reset y location of sprite on screen INT(yreal) (center y)
  1476.     SL_sprite(handle).x.actual = 0 '                                                                    reset x location of sprite on screen (upper left x)
  1477.     SL_sprite(handle).y.actual = 0 '                                                                    reset y location of sprite on screen (upper left y)
  1478.     SL_sprite(handle).x.dir = 0 '                                                                       x direction during motion
  1479.     SL_sprite(handle).y.dir = 0 '                                                                       y direction during motion
  1480.  
  1481.     ' graphics images
  1482.  
  1483.     SL_sprite(handle).gfx.back = 0 '                                                                    no background image saved yet
  1484.     SL_sprite(handle).gfx.sprite = _COPYIMAGE(SL_sheet(sheet, column, row).image, 33) '                 create hardware sprite image
  1485.     SL_sprite(handle).gfx.image = _COPYIMAGE(SL_sheet(sheet, column, row).image, 32) '                  copy software sprite image from sheet
  1486.     IF SL_sheet(sheet, column, row).transparency THEN '                                                 does this sprite use transparency?
  1487.         SL_sprite(handle).gfx.mask = _COPYIMAGE(SL_sheet(sheet, column, row).mask, 32) '                yes, copy software sprite mask image from sheet
  1488.         SL_sprite(handle).transparency = -1 '                                                   (TRUE)  remember this sprite has a transparency layer
  1489.     ELSE '                                                                                              no transparency
  1490.         SL_sprite(handle).gfx.mask = 0 '                                                                no mask will be brought in
  1491.         SL_sprite(handle).transparency = 0 '                                                   (FALSE)  remember this sprite has no transparency layer
  1492.     END IF
  1493.  
  1494.     ' rotation settings
  1495.  
  1496.     SL_sprite(handle).rotation.angle = 0 '                                                              no sprite rotation angle
  1497.     SL_sprite(handle).rotation.speed = 0 '                                                              no spin rate
  1498.     SL_sprite(handle).rotation.auto = 0 '                                                      (FALSE)  auto rotation disabled
  1499.  
  1500.     ' motion settings
  1501.  
  1502.     SL_sprite(handle).motion.speed = 0 '                                                                speed during motion
  1503.     SL_sprite(handle).motion.angle = 0 '                                                                direction during motion (0 - 359)
  1504.     SL_sprite(handle).motion.auto = 0 '                                                        (FALSE)  auto motion disabled
  1505.  
  1506.     SL_NEW_SPRITE = handle '                                                                            return pointer value of new sprite
  1507.  
  1508.  
  1509. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1510. SUB SL_FREE_SPRITE (handle AS INTEGER) '                                                                                                                                                 SL_FREE_SPRITE
  1511.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1512.  
  1513.     ' declare global variables
  1514.  
  1515.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1516.  
  1517.     ' check for errors
  1518.  
  1519.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1520.         SL_ERROR "SL_PUT_SPRITE", 1, "" '                                                               no, report error to programmer
  1521.     END IF
  1522.  
  1523.     ' restore background if this sprite saving background
  1524.  
  1525.     IF SL_sprite(handle).restore THEN '                                                                 is there a background image to restore?
  1526.         _PUTIMAGE (SL_sprite(handle).x.back, SL_sprite(handle).y.back), SL_sprite(handle).gfx.back '    yes, restore the image
  1527.         _FREEIMAGE SL_sprite(handle).gfx.back '                                                         free background image
  1528.     END IF
  1529.  
  1530.     ' free all image data associated with sprite
  1531.  
  1532.     IF SL_sprite(handle).gfx.back THEN _FREEIMAGE SL_sprite(handle).gfx.back '                          free background image if present
  1533.     IF SL_sprite(handle).gfx.mask THEN _FREEIMAGE SL_sprite(handle).gfx.mask '                          free sprite mask image if present
  1534.     _FREEIMAGE SL_sprite(handle).gfx.sprite '                                                           free hardware sprite image
  1535.     _FREEIMAGE SL_sprite(handle).gfx.image '                                                            free software sprite image
  1536.  
  1537.     IF handle = UBOUND(sl_sprite) AND handle <> 1 THEN '                                                is handle the last element in array?
  1538.         REDIM _PRESERVE SL_sprite(handle - 1) AS SL_SPRITE '                                            yes, remove index and resize array
  1539.     ELSE '                                                                                              no, index somewhere else
  1540.         SL_sprite(handle).inuse = 0 '                                                          (FALSE)  mark index as usable later
  1541.     END IF
  1542.  
  1543.  
  1544. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1545. FUNCTION SL_NEW_SHEET (filename AS STRING, swidth AS INTEGER, sheight AS INTEGER, transparency AS INTEGER, transcolor AS _UNSIGNED LONG) '                                       SL_NEW_SHEET
  1546.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1547.  
  1548.     ' declare global variables
  1549.  
  1550.     SHARED SL_sheet() AS SL_SHEET '    master sprite sheet array
  1551.     SHARED SL_rotate() AS SL_ROTATE '  precalculated rotation table
  1552.  
  1553.     ' declare local variables
  1554.  
  1555.     DIM handle AS INTEGER '             handle (pointer) number of new sprite sheet
  1556.     DIM x AS INTEGER '                  generic counter to cycle through sheet sprite columns
  1557.     DIM y AS INTEGER '                  generic counter to cycle through sheet sprite rows
  1558.     DIM x1 AS INTEGER '                 generic counter to cycle though sprite for collision boundaries and mask creation
  1559.     DIM y1 AS INTEGER '                 generic ocunter to cycle though sprite for collision boundaries and mask creation
  1560.     DIM osource AS LONG '               original source image before this function was called
  1561.     DIM odest AS LONG '                 original destination image before this function was called
  1562.     DIM pixel AS _UNSIGNED LONG '       pixel color at each coordinate in sprite sheet
  1563.     DIM alpha AS _UNSIGNED LONG '       alpha level of current pixel
  1564.     DIM top AS INTEGER '                upper boundary of sprite image
  1565.     DIM bottom AS INTEGER '             lower boundary of sprite image
  1566.     DIM left AS INTEGER '               left boundary of sprite image
  1567.     DIM right AS INTEGER '              right boundary of sprite image
  1568.     DIM sheetimage AS LONG '            sprite sheet image
  1569.     DIM sheetwidth AS INTEGER '         width of sprite sheet in pixels
  1570.     DIM sheetheight AS INTEGER '        height of sprite sheet in pixels
  1571.     DIM rows AS INTEGER '               number of sprite rows contained on sheet
  1572.     DIM columns AS INTEGER '            number of sprite columns contained on sheet
  1573.     DIM clearcolor AS _UNSIGNED LONG '  transcolor passed in will be modified
  1574.     DIM tempsprite AS LONG '            temporary sprite for _CLEARCOLOR detection
  1575.     DIM px(3) AS DOUBLE '               polar x coordinates of maptriangle
  1576.     DIM py(3) AS DOUBLE '               polar y coordinates of maptriangle
  1577.     DIM sinr AS DOUBLE '                sin rotation calculation
  1578.     DIM cosr AS DOUBLE '                cosine rotation claculation
  1579.     DIM bx1 AS DOUBLE '                 max boundaries of rotated sprite
  1580.     DIM bx2 AS DOUBLE
  1581.     DIM by1 AS DOUBLE
  1582.     DIM by2 AS DOUBLE
  1583.     DIM x2 AS DOUBLE '                  new computed polar coordinates
  1584.     DIM y2 AS DOUBLE
  1585.  
  1586.     ' perform error checks
  1587.  
  1588.     IF NOT _FILEEXISTS(filename) THEN '                                                                 does the sprite sheet exist?
  1589.         SL_ERROR "SL_NEW_SHEET", 100, filename '                                                        no, report error to programmer
  1590.     END IF
  1591.     IF ABS(transparency) > 1 THEN '                                                                     valid transparency setting?
  1592.         SL_ERROR "SL_NEW_SHEET", 101, "" '                                                              no, report error to programmer
  1593.     END IF
  1594.     IF swidth < 1 OR sheight < 1 THEN '                                                                 valid sprite width/height supplied?
  1595.         SL_ERROR "SL_NEW_SHEET", 102, "" '                                                              no, report error to programmer
  1596.     END IF
  1597.     IF transparency = -1 AND UCASE$(RIGHT$(filename, 4)) <> ".PNG" THEN '                               wrong file type for transparency?
  1598.         SL_ERROR "SL_NEW_SHEET", 103, UCASE$(RIGHT$(filename, 4)) '                                     yes, report error to programmer
  1599.     END IF
  1600.  
  1601.     ' local variable setup
  1602.  
  1603.     sheetimage = _LOADIMAGE(filename, 32) '                                                             load sprite sheet file
  1604.     sheetwidth = _WIDTH(sheetimage) '                                                                   get width of sheet
  1605.     sheetheight = _HEIGHT(sheetimage) '                                                                 get height of sheet
  1606.     columns = sheetwidth \ swidth '                                                                     get number of whole columns of sprites
  1607.     rows = sheetheight \ sheight '                                                                      get number of whole rows of sprites
  1608.     IF columns < 1 OR rows < 1 THEN '                                                                   at least one sprite column and row on sheet?
  1609.         SL_ERROR "SL_NEW_SHEET", 104, "" '                                                              no, report error to programmer
  1610.     END IF
  1611.     osource = _SOURCE '                                                                                 remember current source image
  1612.     odest = _DEST '                                                                                     remember current destination image
  1613.     handle = 0 '                                                                                        initialize handle value
  1614.     clearcolor = transcolor '                                                                           get background/transparent color passed in
  1615.  
  1616.     ' increase sheet array's 1st dimension if needed to create a new sprite sheet
  1617.  
  1618.     DO '                                                                                                look for the next available handle
  1619.         handle = handle + 1 '                                                                           increment the handle value
  1620.     LOOP UNTIL (NOT SL_sheet(handle, 0, 0).image) OR handle = UBOUND(SL_sheet) '                        stop looking when valid handle value found
  1621.     IF SL_sheet(handle, 0, 0).image = -1 THEN '                                                 (TRUE)  is the last array element in use?
  1622.         handle = handle + 1 '                                                                           yes, increment the handle value
  1623.         REDIM _PRESERVE SL_sheet(handle, UBOUND(SL_sheet, 2), UBOUND(SL_sheet, 3)) AS SL_SHEET '        create new sheet in sprite array
  1624.         REDIM _PRESERVE SL_rotate(handle, UBOUND(SL_rotate, 2)) AS SL_ROTATE
  1625.     END IF
  1626.  
  1627.     ' increase sheet array's 2nd and 3rd dimensions if needed to match number of rows and columns
  1628.  
  1629.     IF columns > UBOUND(SL_sheet, 2) THEN '                                                             more columns in this sheet than others?
  1630.         REDIM _PRESERVE SL_sheet(handle, columns, UBOUND(SL_sheet, 3)) AS SL_SHEET '                    yes, increase the array's 2nd dimension to match
  1631.     END IF
  1632.     IF rows > UBOUND(SL_sheet, 3) THEN '                                                                more rows in this sheet than others?
  1633.         REDIM _PRESERVE SL_sheet(handle, UBOUND(SL_sheet, 2), rows) AS SL_SHEET '                       yes, increase the array's 3rd dimension to match
  1634.     END IF
  1635.  
  1636.     ' the variables in SL_sheet(x, 0, 0) will serve a dual purpose
  1637.     ' SL_sheet(x, 0, 0).image will contain either -1 (true) or 0 (false) to indicate the first dimension of the array is in use.
  1638.     ' SL_sheet(x, 0, 0).swidth will contain the number of columns contained in the sheet (the array's 2nd dimension)
  1639.     ' SL_sheet(x, 0, 0).sheight will contain the number of rows contained in the sheet (the array's 3rd dimension)
  1640.  
  1641.     SL_sheet(handle, 0, 0).image = -1 '                                                         (TRUE)  mark as in use
  1642.     SL_sheet(handle, 0, 0).swidth = columns '                                                           remember number of columns in sheet
  1643.     SL_sheet(handle, 0, 0).sheight = rows '                                                             remember number of rows in sheet
  1644.  
  1645.     ' identify transparency of sprite sheet if requested
  1646.  
  1647.     IF transparency = -1 THEN '                                                 (constant SL_USESHEET)  sheet have alpha channel?
  1648.         x = 0 '                                                                                         yes, start at upper left x of sheet
  1649.         y = 0 '                                                                                         start at upper left y of sheet
  1650.         alpha = 255 '                                                                                   assume no alpha channel
  1651.         _SOURCE sheetimage '                                                                            set sprite sheet image as source image
  1652.         DO '                                                                                            start looping through the sheet's pixels
  1653.             pixel = POINT(x, y) '                                                                       get the pixel's color attributes
  1654.             alpha = _ALPHA32(pixel) '                                                                   get the alpha level (0 - 255)
  1655.             IF alpha = 0 THEN EXIT DO '                                                                 if it is transparent then leave the loop
  1656.             x = x + 1 '                                                                                 move right one pixel
  1657.             IF x > sheetwidth THEN '                                                                    have we gone off the sheet?
  1658.                 x = 0 '                                                                                 yes, reset back to the left beginning
  1659.                 y = y + 1 '                                                                             move down one pixel
  1660.             END IF
  1661.         LOOP UNTIL y > sheetheight '                                                                    don't stop until the entire sheet has been checked
  1662.         IF alpha = 0 THEN '                                                                             did we find a transparent pixel?
  1663.             tempsprite = _NEWIMAGE(1, 1, 32) '                                                          yes, create a temporary image         * why did I have to do
  1664.             _CLEARCOLOR pixel, tempsprite '                                                             set pixel found as transparent        * this hack to get
  1665.             clearcolor = _CLEARCOLOR(tempsprite) '                                                      get the transparent color from image  * clearcolor to come out
  1666.             _FREEIMAGE tempsprite '                                                                     temporary image no longer needed      * to the right value?
  1667.         ELSE '                                                                                          no transparency found within sheet
  1668.             transparency = 1 '                                                                          set sheet to having no alpha channel
  1669.         END IF
  1670.     ELSEIF transparency = 0 THEN '                                                   (constant SL_SET)  manually set alpha channel?
  1671.         _CLEARCOLOR clearcolor, sheetimage '                                                            yes, set color as transparent
  1672.         clearcolor = _CLEARCOLOR(sheetimage) '                                                          get the transparent color ************* again, why this hack?
  1673.     END IF
  1674.  
  1675.     ' load sprites from sheet and place into sprite array
  1676.  
  1677.     FOR x = 1 TO columns '                                                                              cycle through the sheet's columns
  1678.         FOR y = 1 TO rows '                                                                             cycle through the sheet's rows
  1679.             SL_sheet(handle, x, y).cell = (y - 1) * columns + x '                                       record animation cell this sprite is in
  1680.             SL_sheet(handle, x, y).image = _NEWIMAGE(swidth, sheight, 32) '                             create software sprite image
  1681.             IF transparency < 1 THEN '                                                                  should a mask be created?
  1682.                 SL_sheet(handle, x, y).mask = _NEWIMAGE(swidth, sheight, 32) '                          yes, create software sprite mask image
  1683.                 _DEST SL_sheet(handle, x, y).mask '                                                     write to the mask image
  1684.             ELSE
  1685.                 SL_sheet(handle, x, y).transparency = 0 '                                      (FALSE)  set sprite as having no transparency
  1686.             END IF
  1687.             _PUTIMAGE , sheetimage, SL_sheet(handle, x, y).image,_
  1688.                  ((x - 1) * swidth, (y - 1) * sheight)-_
  1689.                  ((x - 1) * swidth + swidth - 1, (y - 1) * sheight + sheight - 1) ' copy sprite from sheet and place in sprite image
  1690.  
  1691.             ' precalculate collision boundaries and update sprite mask if needed
  1692.  
  1693.             _SOURCE SL_sheet(handle, x, y).image '                                                      work from the software sprite image
  1694.             top = sheight - 1 '                                                                         set initial collision boundary markers
  1695.             left = swidth - 1
  1696.             bottom = 0
  1697.             right = 0
  1698.             FOR x1 = 0 TO swidth - 1 '                                                                  cycle through the width of sprite
  1699.                 FOR y1 = 0 TO sheight - 1 '                                                             cycle through the height of sprite
  1700.                     IF POINT(x1, y1) <> clearcolor THEN '                                               is this pixel a transparent/background color?
  1701.                         IF x1 < left THEN left = x1 '                                                   no, save position if left-most pixel
  1702.                         IF y1 < top THEN top = y1 '                                                     save position if top-most pixel
  1703.                         IF x1 > right THEN right = x1 '                                                 save position if right-most pixel
  1704.                         IF y1 > bottom THEN bottom = y1 '                                               save position if bbottom-most pixel
  1705.                     END IF
  1706.                     IF transparency < 1 THEN '                                                          update software sprite mask?
  1707.                         IF POINT(x1, y1) = clearcolor THEN '                                            yes, is this pixel a transparent/background color?
  1708.                             PSET (x1, y1), _RGB32(255, 255, 255) '                                      yes, set as white on the mask image
  1709.                         END IF
  1710.                     END IF
  1711.                 NEXT y1
  1712.             NEXT x1
  1713.             SL_sheet(handle, x, y).collx1 = left '                                                      collision box top left x
  1714.             SL_sheet(handle, x, y).colly1 = top '                                                       collision box top left y
  1715.             SL_sheet(handle, x, y).collx2 = right '                                                     collision box bottom right x
  1716.             SL_sheet(handle, x, y).colly2 = bottom '                                                    collision box bottom right y
  1717.             SL_sheet(handle, x, y).swidth = swidth '                                                    remember sprite width
  1718.             SL_sheet(handle, x, y).sheight = sheight '                                                  remember sprite height
  1719.         NEXT y
  1720.     NEXT x
  1721.     _FREEIMAGE sheetimage '                                                                             sprite sheet image no longer needed
  1722.  
  1723.     ' create precalculated rotation table for the sprite sheet (1 to 359 degrees)
  1724.  
  1725.     FOR x = 1 TO 359
  1726.         'px(0) = (-swidth + 1) / 2 '                                                                     upper left  x polar coordinate of sprite
  1727.         'py(0) = (-sheight + 1) / 2 '                                                                    upper left  y polar coordinate of sprite
  1728.         px(0) = -swidth / 2 '                                                                           upper left  x polar coordinate of sprite
  1729.         py(0) = -sheight / 2 '                                                                          upper left  y polar coordinate of sprite
  1730.         px(1) = px(0) '                                                                                 lower left  x polar coordinate of sprite
  1731.         'py(1) = (sheight -1) / 2 '                                                                      lower left  y polar coordinate of sprite
  1732.         'px(2) = (swidth - 1) / 2 '                                                                      lower right x polar coordinate of sprite
  1733.         py(1) = sheight / 2 '                                                                           lower left  y polar coordinate of sprite
  1734.         px(2) = swidth / 2 '                                                                            lower right x polar coordinate of sprite
  1735.         py(2) = py(1) '                                                                                 lower right y polar coordinate of sprite
  1736.         px(3) = px(2) '                                                                                 upper right x polar coordinate of sprite
  1737.         py(3) = py(0) '                                                                                 upper right y polar coordinate of sprite
  1738.         sinr = SIN(-x / 57.2957795131) '                                                                calculate the sin of rotation
  1739.         cosr = COS(-x / 57.2957795131) '                                                                calculate the cosine of rotation
  1740.         bx1 = 0 '                                                                                       upper left x boundary of sprite
  1741.         by1 = 0 '                                                                                       upper left y boundary of sprite
  1742.         bx2 = 0 '                                                                                       lower right x boundary of sprite
  1743.         by2 = 0 '                                                                                       lower right y boundary of sprite
  1744.         FOR y = 0 TO 3 '                                                                                cycle through all four polar coordinates
  1745.             x2 = (px(y) * cosr + sinr * py(y)) '                                                        compute new polar coordinate location
  1746.             y2 = (py(y) * cosr - px(y) * sinr) '                                                        compute new polar coordinate location
  1747.             px(y) = x2 '                                                                                save the new polar coordinate
  1748.             py(y) = y2 '                                                                                save the new polar coordinate
  1749.             IF px(y) < bx1 THEN bx1 = px(y) '                                                           save lowest  x value seen \  NOTE: use for
  1750.             IF px(y) > bx2 THEN bx2 = px(y) '                                                           save highest x value seen  \ background image         <--------------------- LOOK
  1751.             IF py(y) < by1 THEN by1 = py(y) '                                                           save lowest  y value seen  / rectangle coordinates
  1752.             IF py(y) > by2 THEN by2 = py(y) '                                                           save highest y value seen /
  1753.         NEXT y
  1754.         SL_rotate(handle, x).rwidth = bx2 - bx1 + 1 '                                                   calculate width of rotated sprite
  1755.         SL_rotate(handle, x).rheight = by2 - by1 + 1 '                                                  calculate height of rotated sprite
  1756.         SL_rotate(handle, x).px0 = px(0) + ((bx2 - bx1 + 1) \ 2) '                                      calculate triangular coordinates
  1757.         SL_rotate(handle, x).px1 = px(1) + ((bx2 - bx1 + 1) \ 2)
  1758.         SL_rotate(handle, x).px2 = px(2) + ((bx2 - bx1 + 1) \ 2)
  1759.         SL_rotate(handle, x).px3 = px(3) + ((bx2 - bx1 + 1) \ 2)
  1760.         SL_rotate(handle, x).py0 = py(0) + ((by2 - by1 + 1) \ 2)
  1761.         SL_rotate(handle, x).py1 = py(1) + ((by2 - by1 + 1) \ 2)
  1762.         SL_rotate(handle, x).py2 = py(2) + ((by2 - by1 + 1) \ 2)
  1763.         SL_rotate(handle, x).py3 = py(3) + ((by2 - by1 + 1) \ 2)
  1764.  
  1765.         'SL_rotate(handle, x).rwidth = bx2 - bx1 '                                                       calculate width of rotated sprite
  1766.         'SL_rotate(handle, x).rheight = by2 - by1 '                                                      calculate height of rotated sprite
  1767.         'SL_rotate(handle, x).px0 = px(0) + ((bx2 - bx1) / 2) '                                          calculate triangular coordinates
  1768.         'SL_rotate(handle, x).px1 = px(1) + ((bx2 - bx1) / 2)
  1769.         'SL_rotate(handle, x).px2 = px(2) + ((bx2 - bx1) / 2)
  1770.         'SL_rotate(handle, x).px3 = px(3) + ((bx2 - bx1) / 2)
  1771.         'SL_rotate(handle, x).py0 = py(0) + ((by2 - by1) / 2)
  1772.         'SL_rotate(handle, x).py1 = py(1) + ((by2 - by1) / 2)
  1773.         'SL_rotate(handle, x).py2 = py(2) + ((by2 - by1) / 2)
  1774.         'SL_rotate(handle, x).py3 = py(3) + ((by2 - by1) / 2)
  1775.  
  1776.     NEXT x
  1777.     _SOURCE osource '                                                                                   return source to current
  1778.     _DEST odest '                                                                                       return destination to current
  1779.     SL_NEW_SHEET = handle '                                                                             return the handle number pointing to this sheet
  1780.  
  1781.  
  1782. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1783. FUNCTION SL_VALID_SPRITE (handle AS INTEGER) '                                                                                                                                         SL_VALID_SPRITE
  1784.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1785.  
  1786.     ' declare global variables
  1787.  
  1788.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1789.  
  1790.     IF handle > UBOUND(SL_SPRITE) OR (NOT SL_sprite(handle).inuse) OR handle < 1 THEN '                  is this a valid sprite handle?
  1791.         SL_VALID_SPRITE = 0 '                                                                   (FALSE)  no, return 0
  1792.     ELSE '                                                                                               yes, it is valid
  1793.         SL_VALID_SPRITE = -1 '                                                                   (TRUE)  return -1
  1794.     END IF
  1795.  
  1796.  
  1797. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1798. FUNCTION SL_VALID_SHEET (sheet AS INTEGER) '                                                                                                                                             SL_VALID_SHEET
  1799.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1800.  
  1801.     ' declare global variables
  1802.  
  1803.     SHARED SL_sheet() AS SL_SHEET '    master sprite sheet array
  1804.  
  1805.     IF sheet > UBOUND(SL_sheet) OR sheet < 1 THEN '                                                     is this a valid sheet?
  1806.         SL_VALID_SHEET = 0 '                                                                   (FALSE)  no, return false
  1807.     ELSEIF NOT SL_sheet(sheet, 0, 0).image THEN '                                                       is sprite sheet in use?
  1808.         SL_VALID_SHEET = 0 '                                                                   (FALSE)  no, return false
  1809.     ELSE '                                                                                              everything checks out
  1810.         SL_VALID_SHEET = -1 '                                                                   (TRUE)  return true
  1811.     END IF
  1812.  
  1813.  
  1814. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1815. FUNCTION SL_FIX_DEGREES (degrees AS INTEGER) '                                                                                                                                           SL_FIX_DEGREES
  1816.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1817.  
  1818.     ' Credits: this function uses code contriibuted by codeguy
  1819.     '          https://www.qb64.org/forum/index.php?topic=537.15
  1820.  
  1821.     'declare local variables
  1822.  
  1823.     DIM degree AS INTEGER '             degree angle passed in
  1824.  
  1825.     ' set local variables
  1826.  
  1827.     degree = degrees MOD 360 '                                                                          get -359 to 359
  1828.     IF degree < 0 THEN '                                                                                need to make positive?
  1829.         SL_FIX_DEGREES = degree + 360 '                                                                 yes, correct value and return degree angle
  1830.     ELSE
  1831.         SL_FIX_DEGREES = degree '                                                                       no correction needed, return degree angle
  1832.     END IF
  1833.  
  1834.  
  1835. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1836. SUB SL_ERROR (routine AS STRING, errno AS INTEGER, info AS STRING) '                                                                                                                           SL_ERROR
  1837.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1838.  
  1839.     SCREEN 0, 0, 0, 0 '                                                                                 go to a pure text screen
  1840.     _FONT 16 '                                                                                          set the standard screen 0 font
  1841.     IF _FULLSCREEN THEN _FULLSCREEN _OFF '                                                              turn off full screen if on
  1842.     _AUTODISPLAY '                                                                                      auto update the display
  1843.     CLS '                                                                                               clear the screen
  1844.     COLOR 10, 0
  1845.     PRINT "                   **************************************" '                                 print error header
  1846.     PRINT "                   ** Sprite Library Error Encountered **"
  1847.     PRINT "                   **************************************"
  1848.     PRINT
  1849.     COLOR 15, 0
  1850.     PRINT " "; routine;
  1851.     COLOR 7, 0
  1852.     PRINT " has reported error";
  1853.     COLOR 30, 0
  1854.     PRINT STR$(errno)
  1855.     COLOR 7, 0
  1856.     PRINT
  1857.     SELECT CASE errno '                                                                                 which error number is being reported?
  1858.  
  1859.         ' general purpose errors for all subs/functions
  1860.  
  1861.         CASE 1
  1862.             PRINT "- the requested sprite does not exist"
  1863.         CASE 2
  1864.             PRINT "- invalid background restore setting supplied - valid settings are"
  1865.             PRINT "- : -1 (constant SL_SAVE)"
  1866.             PRINT "- :  0 (constant SL_NOSAVE)"
  1867.         CASE 3
  1868.             PRINT "- invalid flip setting supplied - valid settings are"
  1869.             PRINT "  : 0 (constant SL_NOFLIP)"
  1870.             PRINT "  : 1 (constant SL_HORIZONTAL)"
  1871.             PRINT "  : 2 (constant SL_VERTICAL)"
  1872.             PRINT "  : 3 (constant SL_FLIPBOTH)"
  1873.         CASE 4
  1874.             PRINT "- invalid zoom level setting supplied"
  1875.             PRINT "- zoom level must be greater than zero (0)"
  1876.         CASE 5
  1877.             PRINT "- the specified sprite sheet is not in use or does not exist"
  1878.         CASE 6
  1879.             PRINT "- invalid row or column selected for specified sprite sheet"
  1880.         CASE 7
  1881.             PRINT "- invalid auto motion behavior requested - valid settings are"
  1882.             PRINT "- : -1 (constant SL_START)"
  1883.             PRINT "- :  0 (constant SL_STOP)"
  1884.         CASE 8
  1885.             PRINT "- invalid auto rotation behavior requested - valid settings are"
  1886.             PRINT "- : -1 (constant SL_START)"
  1887.             PRINT "- :  0 (constant SL_STOP)"
  1888.         CASE 9
  1889.             PRINT "- rotation speed must be between -359 and 359 degrees"
  1890.  
  1891.  
  1892.  
  1893.             ' errors belonging to SL_NEW_SHEET (100 - 109)
  1894.  
  1895.         CASE 100
  1896.             PRINT "- "; CHR$(34); info; CHR$(34); " sprite sheet does not exist"
  1897.             PRINT "- check path or spelling"
  1898.         CASE 101
  1899.             PRINT "- invalid transparency setting supplied - valid settings are"
  1900.             PRINT "- : -1 (constant SL_USESHEET)"
  1901.             PRINT "- :  0 (constant SL_SET)"
  1902.             PRINT "- :  1 (constant SL_NONE)"
  1903.         CASE 102
  1904.             PRINT "- sprite width and height must be greater than zero"
  1905.         CASE 103
  1906.             PRINT "- selecting to use a sheet's transparency only works with .PNG files"
  1907.             PRINT "- the function was passed a "; info; " file."
  1908.         CASE 104
  1909.             PRINT "- there must be at least one column and one row of sprites on sheet"
  1910.             PRINT "- the sheet being loaded does not meet these minimums"
  1911.  
  1912.             'errors belonging to SL_NEW_SPRITE (110 - 119)
  1913.  
  1914.             'CASE 110
  1915.             '    PRINT "- the specified sprite sheet is not in use or does not exist"
  1916.             'CASE 111
  1917.             '    PRINT "- invalid row or column selected for specified sprite sheet"
  1918.         CASE 112
  1919.             PRINT "- invalid hardware / software setting supplied - valid settings are"
  1920.             PRINT "- : -1 (constant SL_SOFTWARE)"
  1921.             PRINT "- :  0 (constant SL_HARDWARE)"
  1922.         CASE 113
  1923.             PRINT "- there is no need to restore the background with hardware sprites"
  1924.             PRINT "- change background restore setting to zero (0) (constant SL_NOSAVE)"
  1925.  
  1926.             ' errors belonging to SL_FLIP_SPRITE (120 - 129)
  1927.  
  1928.             'CASE 120
  1929.             '    PRINT "- invalid flip setting supplied - valid settings are"
  1930.             '    PRINT "  : 0 (constant SL_NOFLIP)"
  1931.             '    PRINT "  : 1 (constant SL_HORIZONTAL)"
  1932.             '    PRINT "  : 2 (constant SL_VERTICAL)"
  1933.             '    PRINT "  : 3 (constant SL_FLIPBOTH)"
  1934.  
  1935.             ' errors belonging to SL_ZOOM_SPRITE (130 - 139)
  1936.  
  1937.             'CASE 130
  1938.             '    PRINT "- invalid zoom level setting supplied"
  1939.             '    PRINT "- zoom level must be greater than zero (0)"
  1940.  
  1941.             ' errors belonging to SL_CHANGE_ROTATION_SPEED (140 - 149)
  1942.  
  1943.             'CASE 140
  1944.             '    PRINT "- rotation speed must be between -359 and 359 degrees"
  1945.  
  1946.             ' errors belonging to SL_CHANGE_AUTOMOTION (150 - 159)
  1947.  
  1948.             'CASE 150
  1949.             '    PRINT "- invalid auto motion behavior requested - valid settings are"
  1950.             '    PRINT "- : -1 (constant SL_START)"
  1951.             '    PRINT "- :  0 (constant SL_STOP)"
  1952.  
  1953.             ' errors belonging to SL_CHANGE_AUTOROTATION (160 - 169)
  1954.  
  1955.             'CASE 160
  1956.             '    PRINT "- invalid auto rotation behavior requested - valid settings are"
  1957.             '    PRINT "- : -1 (constant SL_START)"
  1958.             '    PRINT "- :  0 (constant SL_STOP)"
  1959.  
  1960.             ' errors belonging to SL_UPDATE_MOTION (170 - 179)
  1961.  
  1962.         CASE 170
  1963.             PRINT "- the sprite requested is already under automatic movement control"
  1964.  
  1965.             ' errors belonging to SL_UPDATE_ROTATION (180 - 189)
  1966.  
  1967.         CASE 180
  1968.             PRINT "- the sprite requested is already under automatic rotation control"
  1969.  
  1970.     END SELECT
  1971.     COLOR 12, 0
  1972.     PRINT
  1973.     PRINT " See sprite library doumentation for further explanation."
  1974.     COLOR 7, 0
  1975.     DO: LOOP UNTIL INKEY$ = "" '                                                                        clear the keyboard buffer
  1976.     END '                                                                                               end the program
  1977.  
  1978.  
  1979.  
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 22, 2018, 01:29:36 pm
I had a LOT of bugs to work out over the past few days. I believe they are all sorted out now. There are currently 63 commands in the new library and counting with many more to go. Here is the code so far for those keeping track:

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. ' Mouse routines
  23. ' - detect when mouse interacts with a sprite (hover, click, double click, right click, etc..) SL_MOUSE_STATUS
  24. ' ** DONE ** set a score value to a sprite for game score tracking, SL_SET_SCORE, SL_GET_SCORE ** DONE **
  25. ' 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
  26. ' reverse x and y directions for auto/manual movement, SL_MOTION_REVERSEX, SL_MOTION_REVERSEY
  27. ' set Z depth of sprite for different planes/layers (possibly incorporate this into zoom?)
  28. ' hide/unhide sprites SL_HIDE_SPRITE, SL_SHOW_SPRITE
  29. ' collision detection routines (rectangle, round, ellipticle, pixel-perfect, n-space?, prediction?) SL_SET_COLLISION, SL_GET_COLLISION, SL_COLLIDED_WITH
  30. ' - need to figure out how to rotate collision box along with sprites, not too hard
  31. ' - this will require line segment intersection algorithms for collision detection, yikes! hard, probably need help
  32. ' - possibly link sounds to collisions SL_LINK_COLLIDE_SOUND
  33. ' Parallaxing layers  SL_CREATE_PARALLAX, SL_UPDATE_PARALLAX
  34. ' Game font printing
  35. ' Sprite tiling, square for sure, isometric?
  36.  
  37. ' Things to improve
  38. '
  39. ' Naming convention of constants and their values
  40. ' ** DONE ** Remove all for/next loops and replace with do/loop or while/wend ** DONE **
  41. ' Use integers wherever possible
  42. ' allow SINGLE value rotation angles for accuracy but convert to integer before sprite rotation
  43. ' - using only integer now, may not be precise enough for future improvements
  44.  
  45. ' Investigate
  46. '
  47. ' Use of _MAPTRIANGLE for 3D rotation   SL_ROTATE_3D
  48. ' _HARDWARE vs _HARDWARE1
  49.  
  50. ' Remember
  51. '
  52. ' Any code added that is OS dependant needs to detect the OS running first
  53. ' - try to create routines that are OS dependant for all OS'
  54.  
  55.  
  56.  
  57. OPTION _EXPLICIT ' need to remove before publishing library!!
  58.  
  59. '*
  60. '* constant declarations
  61. '*
  62.  
  63. '      CONSTANT NAME                   DESCRIPTION                                                       FUNCTIONS / SUBROUTINES THAT MAY USE THIS CONSTANT
  64. ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  65. 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
  66. CONST SL_NOFLIP = 0 '       sprite will use no flipping                 SL_FLIP_SPRITE
  67. CONST SL_HORIZONTAL = 1 '   sprite will be flipped horizontally         SL_FLIP_SPRITE
  68. CONST SL_VERTICAL = 2 '     sprite will be flipped vertically           SL_FLIP_SPRITE
  69. CONST SL_FLIPBOTH = 3 '     sprite will be flipped both direction       SL_FLIP_SPRITE
  70. CONST SL_USESHEET = -1 '    use sheet's transparency info (.PNG)        SL_NEW_SHEET
  71. CONST SL_SET = 0 '          manually set transparency                   SL_NEW_SHEET
  72. CONST SL_NONE = 1 '         don't use transparency with sheet           SL_NEW_SHEET
  73. CONST SL_NOSAVE = 0 '       sprite will not save background             SL_NEW_SPRITE, SL_SET_SOFTWARE
  74. CONST SL_SAVE = -1 '        sprite will save background                 SL_NEW_SPRITE, SL_SET_SOFTWARE
  75. CONST SL_HARDWARE = 0 '     sprite in hardware mode                     SL_NEW_SPRITE
  76. CONST SL_SOFTWARE = -1 '    sprite in software mode                     SL_NEW_SPRITE
  77. 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
  78. 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
  79. CONST SL_FORWARD = 0 '      animation cells proceed forward             SL_SET_ANIMATION
  80. CONST SL_BACKWARD = 1 '     animation cells proceed backwards           SL_SET_ANIMATION
  81. CONST SL_BACKFORTH = 2 '    animation cells toggle forward/backward     SL_SET_ANIMATION
  82. CONST SL_CURRENTCELL = -1 ' use current cell as starting cell           SL_SET_ANIMATION, SL_CHANGE_ANIMATION_CELLS
  83.  
  84. '*
  85. '* type declarations
  86. '*
  87.  
  88. TYPE SL_SHEET ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ SPRITE SHEET DATABASE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  89.     image AS LONG '                     software sprite image
  90.     mask AS LONG '                      software mask image
  91.     swidth AS INTEGER '                 width of sprite
  92.     sheight AS INTEGER '                height of sprite
  93.     cell AS INTEGER '                   the animation cell of this sprite
  94.     collx1 AS INTEGER '                 collision box top left x
  95.     colly1 AS INTEGER '                 collision box top left y
  96.     collx2 AS INTEGER '                 collision box bottom right x
  97.     colly2 AS INTEGER '                 collision box bottom right y
  98.     transparency AS INTEGER '           -1 (TRUE) if sheet uses transparency
  99. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  100.  
  101. TYPE SL_XY ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ X,Y LOCATIONS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  102.     real AS SINGLE '                    single values of sprite x,y center point
  103.     int AS INTEGER '                    integer values of sprite x,y center point
  104.     actual AS INTEGER '                 integer values of sprite upper left x,y location
  105.     back AS INTEGER '                   integer values of sprite's background image x,y location
  106.     dir AS SINGLE '                     single values of sprite x,y motion vectors
  107. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  108.  
  109. TYPE SL_IMAGE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ IMAGES ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  110.     sprite AS LONG '                    hardware sprite image
  111.     image AS LONG '                     software sprite image
  112.     mask AS LONG '                      software sprite mask image
  113.     back AS LONG '                      software sprite saved background image
  114. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  115.  
  116. TYPE SL_ANIM ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ANIMATION SETTINGS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  117.     cell AS INTEGER '                   current animation cell
  118.     cellfrom AS INTEGER '               starting animation cell
  119.     cellto AS INTEGER '                 ending animation cell
  120.     dir AS INTEGER '                    animation direction
  121.     mode AS INTEGER '                   animation mode (forward, backward, back/forth)
  122.     framerate AS INTEGER '              sprite animation frame rate
  123.     frame AS INTEGER '                  animation frame counter
  124.     skip AS INTEGER '                   how often to skip a frame to achieve framerate
  125.     auto AS INTEGER '                   auto-animation on/off
  126. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  127.  
  128. TYPE SL_MOTION ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ MOTION SETTINGS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  129.     auto AS INTEGER '                   -1 (TRUE) if auto-motion turned on
  130.     speed AS SINGLE '                   speed of sprite during motion
  131.     angle AS INTEGER '                  direction of sprite during motion (0 - 359)
  132. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  133.  
  134. TYPE SL_ROTATION ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ROTATION SETTINGS ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  135.     auto AS INTEGER '                   -1 (TRUE) if auto-rotation turned on
  136.     speed AS INTEGER '                  spin rate in degrees of sprite (0 - 359)
  137.     angle AS INTEGER '                  current rotation angle of sprite
  138. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  139.  
  140. TYPE SL_SPRITE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ SPRITE DATABASE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  141.     inuse AS INTEGER '                  this array index in use
  142.     x AS SL_XY '                        x coordinate locations
  143.     y AS SL_XY '                        y coordinate locations
  144.     gfx AS SL_IMAGE '                   image graphics
  145.     anim AS SL_ANIM '                   animation settings
  146.     motion AS SL_MOTION '               motion settings
  147.     rotation AS SL_ROTATION '           rotation settings
  148.     sheet AS INTEGER '                  sheet sprite belongs to
  149.     column AS INTEGER '                 the column on the sheet the sprite resides
  150.     row AS INTEGER '                    the row on the sheet the sprite resides
  151.     swidth AS INTEGER '                 width of sprite
  152.     sheight AS INTEGER '                height of sprite
  153.     restore AS INTEGER '                -1 (true) if sprite restores background
  154.     collx1 AS INTEGER '                 collision box top left x
  155.     colly1 AS INTEGER '                 collision box top left y
  156.     collx2 AS INTEGER '                 collision box bottom right x
  157.     colly2 AS INTEGER '                 collision box bottom right y
  158.     flip AS INTEGER '                   flip horizontally, vertically, or both
  159.     transparency AS INTEGER '           -1 (TRUE) if sprite uses transparency
  160.     zoom AS INTEGER '                   zoom level of sprite (1% - x%)
  161.     software AS INTEGER '               -1 (TRUE) if sprite is to be treated as software image
  162.     score AS INTEGER '                  point score of sprite
  163. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  164.  
  165. TYPE SL_ROTATE 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ PRECALCULATED ROTATION TABLE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  166.     rwidth AS INTEGER '                 width of rotated sprite
  167.     rheight AS INTEGER '                height of rotated sprite
  168.     px0 AS INTEGER '                    rectangular rotation coordinates
  169.     px1 AS INTEGER
  170.     px2 AS INTEGER
  171.     px3 AS INTEGER
  172.     py0 AS INTEGER
  173.     py1 AS INTEGER
  174.     py2 AS INTEGER
  175.     py3 AS INTEGER
  176. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  177.  
  178. '*
  179. '* global dynamic array declarations
  180. '*
  181.  
  182. REDIM SL_sheet(1, 1, 1) AS SL_SHEET '   master sprite sheet array
  183. REDIM SL_sprite(1) AS SL_SPRITE '       master working sprite array
  184. REDIM SL_rotate(1, 359) AS SL_ROTATE '  precalculated rotation values
  185.  
  186. '*
  187. '* global variable declarations
  188. '*
  189.  
  190. DIM SL_framerate AS INTEGER '           the global frame rate
  191.  
  192. '*
  193. '* main code (for testing)
  194. '*
  195.  
  196. DIM kongsheet AS INTEGER
  197. DIM mysprite AS INTEGER
  198. DIM mysprite2 AS INTEGER
  199. DIM angle AS INTEGER
  200.  
  201. SL_SET_FRAMERATE 30
  202.  
  203. kongsheet = SL_NEW_SHEET("dkong.png", 64, 64, SL_SET, _RGB32(255, 0, 255))
  204. mysprite = SL_NEW_SPRITE(kongsheet, 1, 1, SL_HARDWARE, SL_NOSAVE)
  205. 'mysprite2 = SL_NEW_SPRITE(kongsheet, 1, 1, SL_SOFTWARE, SL_NOSAVE)
  206.  
  207. 'SL_FLIP_SPRITE mysprite, SL_HORIZONTAL
  208. 'SL_SET_ZOOM mysprite, 125
  209.  
  210. 'SL_SET_MOTION mysprite, 90, 3, SL_START
  211. SL_SET_ROTATION mysprite, 0, 5, SL_START
  212. 'SL_SET_ROTATION mysprite2, 180, 10, SL_START
  213.  
  214. SL_SET_ANIMATION mysprite, 1, 3, SL_FORWARD, 10, SL_START
  215.  
  216. SCREEN _NEWIMAGE(640, 480, 32)
  217.  
  218. CIRCLE (128, 128), 64, _RGB32(255, 255, 255)
  219.  
  220. SL_PUT_SPRITE 128, 128, mysprite
  221. 'SL_PUT_SPRITE 128, 128, mysprite2
  222.  
  223.     _LIMIT SL_GET_FRAMERATE
  224.     x = x + 1
  225.     IF x = 15 THEN
  226.         'SL_CHANGE_MOTION_SPEED mysprite, SL_GET_MOTION_SPEED(mysprite) * 1.1
  227.         'SL_CHANGE_ROTATION_SPEED mysprite, SL_GET_ROTATION_SPEED(mysprite) + 1
  228.         x = 0
  229.     END IF
  230.     SL_UPDATE_AUTO_SPRITES
  231.     _DISPLAY
  232.  
  233. SL_FREE_SPRITE mysprite
  234. 'SL_FREE_SPRITE mysprite2
  235.  
  236.  
  237.  
  238. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  239. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  240. '                                                                     ----------==========                    ==========----------
  241. '                                                                     ----------========== ANIMATION ROUTINES ==========----------
  242. '                                                                     ----------==========                    ==========----------
  243. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  244. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  245.  
  246. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  247. SUB SL_SET_FRAMERATE (framerate AS INTEGER) '                                                                                                                                          SL_SET_FRAMERATE
  248.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  249.  
  250.     ' declare global variables
  251.  
  252.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  253.     SHARED SL_framerate AS INTEGER '    global frame rate
  254.  
  255.     ' declare local variables
  256.  
  257.     DIM handle AS INTEGER '             cycle counter through sprite handles
  258.  
  259.     ' perform error checks
  260.  
  261.     IF framerate < 1 THEN '                                                                             valid frame rate?
  262.         SL_ERROR "SL_SET_FRAMERATE", 10, "" '                                                           no, report error to programmer
  263.     END IF
  264.  
  265.     ' set local variables
  266.  
  267.     SL_framerate = framerate '                                                                          set global frame rate
  268.     handle = 0 '                                                                                        reset handle counter
  269.  
  270.     DO '                                                                                                update all available sprites
  271.         handle = handle + 1 '                                                                           increment sprite pointer
  272.         IF SL_sprite(handle).inuse THEN '                                                               is this sprite in use?
  273.             IF SL_sprite(handle).anim.framerate THEN '                                                  yes, does it contain an animation frame rate?
  274.                 IF SL_framerate < SL_sprite(handle).anim.framerate THEN '                               is new global frame rate less than sprite's frame rate?
  275.                     SL_sprite(handle).anim.framerate = SL_framerate '                                   yes, set sprite's frame rate to global frame rate
  276.                 END IF
  277.                 IF SL_framerate = SL_sprite(handle).anim.framerate THEN '                               animation and global frame rates the same?
  278.                     SL_sprite(handle).anim.skip = 0 '                                                   yes, nothing needs to be done with frames
  279.                 ELSEIF SL_sprite(handle).anim.framerate >= SL_framerate \ 2 THEN '                      no, sprite frame rate 1/2 or less of master frame rate?
  280.                     SL_sprite(handle).anim.skip = SL_framerate \ (SL_framerate - SL_sprite(handle).anim.framerate) ' yes, calculate every frame to skip
  281.                 ELSE '                                                                                  no, sprite frame rate is greater than 1/2 of master frame rate
  282.                     SL_sprite(handle).anim.skip = SL_framerate \ SL_sprite(handle).anim.framerate '     calculate every frame to draw
  283.                 END IF
  284.             END IF
  285.         END IF
  286.     LOOP UNTIL handle = UBOUND(SL_sprite) '                                                             leave when all sprites updated
  287.  
  288.  
  289. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  290. FUNCTION SL_GET_FRAMERATE () '                                                                                                                                                         SL_GET_FRAMERATE
  291.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  292.  
  293.     ' declare global variables
  294.  
  295.     SHARED SL_framerate AS INTEGER '    global frame rate
  296.  
  297.     SL_GET_FRAMERATE = SL_framerate '                                                                   return global frame rate
  298.  
  299.  
  300. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  301. SUB SL_NEXT_ANIMATION_CELL (handle AS INTEGER) '                                                                                                                                 SL_NEXT_ANIMATION_CELL
  302.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  303.  
  304.     ' declare global variables
  305.  
  306.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  307.  
  308.     ' perform error checks
  309.  
  310.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  311.         SL_ERROR "SL_NEXT_ANIMATION_CELL", 1, "" '                                                      no, report error to programmer
  312.     END IF
  313.     IF NOT SL_sprite(handle).anim.cellfrom THEN '                                                       has animation been assigned to this sprite?
  314.         SL_ERROR "SL_NEXT_ANIMATION_CELL", 15, "" '                                                     no, report error to programmer
  315.     END IF
  316.     IF SL_sprite(handle).anim.auto THEN '                                                               is this sprite under auto animation control?
  317.         SL_ERROR "SL_NETXT_ANIMATION_CELL", 18, "" '                                                    yes, report error to programmer
  318.     END IF
  319.  
  320.     SELECT CASE SL_sprite(handle).anim.mode '                                                           which animation mode is this sprite using?
  321.         CASE 0 '                                                                          (SL_FORWARD)  move forward through the cells
  322.             SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cell + 1 '                             increment animation cell
  323.             IF SL_sprite(handle).anim.cell > SL_sprite(handle).anim.cellto THEN '                       passed the last cell?
  324.                 SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cellfrom '                         yes, go back to first cell
  325.             END IF
  326.         CASE 1 '                                                                         (SL_BACKWARD)  move backward through the cells
  327.             SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cell - 1 '                             decrement animation cell
  328.             IF SL_sprite(handle).anim.cell < SL_sprite(handle).anim.cellfrom THEN '                     passed the first cell?
  329.                 SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cellto '                           yes, go back to last cell
  330.             END IF
  331.         CASE 2 '                                                                        (SL_BACKFORTH)  ping-pong back and forth through the cells
  332.             SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cell + SL_sprite(handle).anim.dir '    increment/decrement animation cell
  333.             IF SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cellto OR _
  334.                SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cellfrom THEN '                     is this the first or last cell?
  335.                 SL_sprite(handle).anim.dir = -SL_sprite(handle).anim.dir '                              yes, reverse animation direction
  336.             END IF
  337.     END SELECT
  338.  
  339.     SL_sprite(handle).column = SL_GET_COLUMN(SL_sprite(handle).sheet, SL_sprite(handle).anim.cell) '    get cell column on sheet and save
  340.     SL_sprite(handle).row = SL_GET_ROW(SL_sprite(handle).sheet, SL_sprite(handle).anim.cell) '          get cell row on sheet and save
  341.  
  342.  
  343. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  344. SUB SL_CHANGE_ANIMATION_CELLS (handle AS INTEGER, cellfrom AS INTEGER, cellto AS INTEGER) '                                                                                   SL_CHANGE_ANIMATION_CELLS
  345.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  346.     ' change a sprite's animation sequence
  347.  
  348.     ' declare global variables
  349.  
  350.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  351.  
  352.     ' perform error checks
  353.  
  354.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  355.         SL_ERROR "SL_CHANGE_ANIMATION_CELLS", 1, "" '                                                   no, report error to programmer
  356.     END IF
  357.     IF NOT SL_sprite(handle).anim.cellfrom THEN '                                                       has animation been assigned to this sprite?
  358.         SL_ERROR "SL_CHANGE_ANIMATION_CELLS", 15, "" '                                                  no, report error to programmer
  359.     END IF
  360.     IF cellfrom <> -1 THEN '                                                          (SL_CURRENTCELL)  is the current cell being requested for cellfrom?
  361.         IF cellfrom < 1 OR (NOT SL_VALID_CELL(SL_sprite(handle).sheet, cellfrom)) THEN '                no, is this a valid cell request?
  362.             SL_ERROR "SL_CHANGE_ANIMATION_CELLS", 13, "" '                                              no, report error to rpogrammer
  363.         END IF
  364.     END IF
  365.     IF cellto < 1 OR (NOT SL_VALID_CELL(SL_sprite(handle).sheet, cellto)) THEN '                        is this valid cell request?
  366.         SL_ERROR "SL_CHANGE_ANIMATION_CELLS", 13, "" '                                                  no, report error to programmer
  367.     END IF
  368.  
  369.     IF cellfrom = -1 THEN '                                                           (SL_CURRENTCELL)  use current cell as start cell?
  370.         SL_sprite(handle).anim.cellfrom = SL_sprite(handle).anim.cell '                                 yes, set first cell as current cell
  371.     ELSE '                                                                                              no
  372.         SL_sprite(handle).anim.cellfrom = cellfrom '                                                    set first cell in animation
  373.     END IF
  374.     SL_sprite(handle).anim.cellto = cellto '                                                            set last cell in animation
  375.     SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cellfrom '                                     set current cell to first cell
  376.  
  377.     IF SL_sprite(handle).anim.cellto <= SL_sprite(handle).anim.cellfrom THEN '                          is cellto greater than cellfrom?
  378.         SL_ERROR "SL_CHANGE_ANIMATION_CELLS", 19, "" '                                                  no, report error to programmer
  379.     END IF
  380.  
  381.  
  382. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  383. SUB SL_CHANGE_ANIMATION_FRAMERATE (handle AS INTEGER, framerate AS INTEGER) '                                                                                             SL_CHANGE_ANIMATION_FRAMERATE
  384.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  385.     ' declare global variables
  386.  
  387.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  388.     SHARED SL_framerate AS INTEGER '    global frame rate
  389.  
  390.     ' perform error checks
  391.  
  392.     IF framerate < 1 OR framerate > SL_framerate THEN '                                                 valid frame rate supplied?
  393.         SL_ERROR "SL_CHANGE_ANIMATION_FRAMERATE", 11, "" '                                              no, report error to programmer
  394.     END IF
  395.  
  396.     SL_sprite(handle).anim.framerate = framerate '                                                      save sprite frame rate
  397.     IF SL_framerate = framerate THEN '                                                                  animation and global frame rates the same?
  398.         SL_sprite(handle).anim.skip = 0 '                                                               yes, nothing needs to be done with frames
  399.     ELSEIF framerate >= SL_framerate \ 2 THEN '                                                         no, sprite frame rate 1/2 or less of master frame rate?
  400.         SL_sprite(handle).anim.skip = SL_framerate \ (SL_framerate - framerate) '                       yes, calculate every frame to skip
  401.     ELSE '                                                                                              no, sprite frame rate is greater than 1/2 of master frame rate
  402.         SL_sprite(handle).anim.skip = SL_framerate \ framerate '                                        calculate every frame to draw
  403.     END IF
  404.  
  405.  
  406. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  407. SUB SL_CHANGE_AUTOANIMATION (handle AS INTEGER, auto AS INTEGER) '                                                                                                              SL_CHANGE_AUTOANIMATION
  408.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  409.  
  410.     ' declare global variables
  411.  
  412.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  413.  
  414.     ' perform error checks
  415.  
  416.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  417.         SL_ERROR "SL_CHANGE_AUTOANIMATION", 1, "" '                                                     no, report error to programmer
  418.     END IF
  419.     IF auto < -1 OR auto > 0 THEN '                                                                     valid auto animation value?
  420.         SL_ERROR "SL_CHANGE_ANIMATION", 14, "" '                                                        no, report error to programmer
  421.     END IF
  422.  
  423.     SL_sprite(handle).anim.auto = auto '                                          (SL_START & SL_STOP)  set auto-animation
  424.  
  425.  
  426. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  427. 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
  428.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  429.  
  430.     ' declare global variables
  431.  
  432.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  433.     SHARED SL_framerate AS INTEGER '    global frame rate
  434.  
  435.     ' perform error checks
  436.  
  437.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  438.         SL_ERROR "SL_SET_ANIMATION", 1, "" '                                                            no, report error to programmer
  439.     END IF
  440.     IF framerate < 1 OR framerate > SL_framerate THEN '                                                 valid frame rate supplied?
  441.         SL_ERROR "SL_SET_ANIMATION", 11, "" '                                                           no, report error to programmer
  442.     END IF
  443.     IF mode < 0 OR mode > 2 THEN '                                                                      valid animation mode supplied?
  444.         SL_ERROR "SL_SET_ANIMATION", 12, "" '                                                           no, report error to programmer
  445.     END IF
  446.     IF cellfrom <> -1 THEN '                                                          (SL_CURRENTCELL)  is the current cell being requested for cellfrom?
  447.         IF cellfrom < 1 OR (NOT SL_VALID_CELL(SL_sprite(handle).sheet, cellfrom)) THEN '                no, is this a valid cell request?
  448.             SL_ERROR "SL_SET_ANIMATION", 13, "" '                                                       no, report error to rpogrammer
  449.         END IF
  450.     END IF
  451.     IF cellto < 1 OR (NOT SL_VALID_CELL(SL_sprite(handle).sheet, cellto)) THEN '                        is this valid cell request?
  452.         SL_ERROR "SL_SET_ANIMATION", 13, "" '                                                           no, report error to programmer
  453.     END IF
  454.     IF auto < -1 OR auto > 0 THEN '                                                                     valid auto animation value?
  455.         SL_ERROR "SL_SET_ANIMATION", 14, "" '                                                           no, report error to programmer
  456.     END IF
  457.  
  458.     IF cellfrom = -1 THEN '                                                           (SL_CURRENTCELL)  use current cell as start cell?
  459.         SL_sprite(handle).anim.cellfrom = SL_sprite(handle).anim.cell '                                 yes, set first cell as current cell
  460.     ELSE '                                                                                              no
  461.         SL_sprite(handle).anim.cell = cellfrom '                                                        set starting cell
  462.         SL_sprite(handle).anim.cellfrom = cellfrom '                                                    set first cell in animation
  463.     END IF
  464.     SL_sprite(handle).anim.cellto = cellto '                                                            set last cell in animation
  465.  
  466.     IF cellto <= cellfrom THEN '                                                                        is cellto greater than cellfrom?
  467.         SL_ERROR "SL_SET_ANIMATION", 19, "" '                                                           no, report error to programmer
  468.     END IF
  469.  
  470.     SL_sprite(handle).column = SL_GET_COLUMN(SL_sprite(handle).sheet, SL_sprite(handle).anim.cell) '    get cell column on sheet
  471.     SL_sprite(handle).row = SL_GET_ROW(SL_sprite(handle).sheet, SL_sprite(handle).anim.cell) '          get cell row on sheet
  472.     SL_sprite(handle).anim.framerate = framerate '                                                      save sprite frame rate
  473.     IF SL_framerate = framerate THEN '                                                                  animation and global frame rates the same?
  474.         SL_sprite(handle).anim.skip = 0 '                                                               yes, nothing needs to be done with frames
  475.     ELSEIF framerate >= SL_framerate \ 2 THEN '                                                         no, sprite frame rate 1/2 or less of master frame rate?
  476.         SL_sprite(handle).anim.skip = SL_framerate \ (SL_framerate - framerate) '                       yes, calculate every frame to skip
  477.     ELSE '                                                                                              no, sprite frame rate is greater than 1/2 of master frame rate
  478.         SL_sprite(handle).anim.skip = SL_framerate \ framerate '                                        calculate every frame to draw
  479.     END IF
  480.     SL_sprite(handle).anim.frame = 0 '                                                                  reset skip frame counter
  481.     SL_sprite(handle).anim.mode = mode '                     (SL_FORWARD & SL_BACKWARD & SL_BACKFORTH)  set animation mode
  482.     IF mode = 0 OR mode = 2 THEN '                                        (SL_FORWARD or SL_BACKFORTH)  forward or back and forth?
  483.         SL_sprite(handle).anim.dir = 1 '                                                                yes, set animation direction forward
  484.     ELSE '                                                                               (SL_BACKWARD)  no, backward
  485.         SL_sprite(handle).anim.dir = -1 '                                                               set animation direction backward
  486.     END IF
  487.     SL_sprite(handle).anim.auto = auto '                                          (SL_START & SL_STOP)  set auto-animation
  488.  
  489.  
  490. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  491. FUNCTION SL_GET_ROW (sheet AS INTEGER, cell AS INTEGER) '                                                                                                                                    SL_GET_ROW
  492.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  493.  
  494.     ' declare global variables
  495.  
  496.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  497.  
  498.     ' perform error checks
  499.  
  500.     IF NOT SL_VALID_SHEET(sheet) THEN '                                                                 is this a valid sheet?
  501.         SL_ERROR "SL_GET_ROW", 5, "" '                                                                  no, report error to programmer
  502.     END IF
  503.     IF NOT SL_VALID_CELL(sheet, cell) THEN '                                                            is this a valid cell?
  504.         SL_ERROR "SL_GET_ROW", 13, "" '                                                                 no, report error to programmer
  505.     END IF
  506.  
  507.     IF cell MOD SL_sheet(sheet, 0, 0).swidth = 0 THEN '                                                 right-most column?
  508.         SL_GET_ROW = cell \ SL_sheet(sheet, 0, 0).swidth '                                              yes, calculate and return row
  509.     ELSE '                                                                                              no, in another column
  510.         SL_GET_ROW = cell \ SL_sheet(sheet, 0, 0).swidth + 1 '                                          calculate and return row
  511.     END IF
  512.  
  513.  
  514. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  515. FUNCTION SL_GET_COLUMN (sheet AS INTEGER, cell AS INTEGER) '                                                                                                                              SL_GET_COLUMN
  516.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  517.  
  518.     ' declare global variables
  519.  
  520.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  521.  
  522.     ' declare local variables
  523.  
  524.     DIM column AS INTEGER '             column cell is located in
  525.  
  526.     ' perform error checks
  527.  
  528.     IF NOT SL_VALID_SHEET(sheet) THEN '                                                                 is this a valid sheet?
  529.         SL_ERROR "SL_GET_COLUMN", 5, "" '                                                               no, report error to programmer
  530.     END IF
  531.     IF NOT SL_VALID_CELL(sheet, cell) THEN '                                                            is this a valid cell?
  532.         SL_ERROR "SL_GET_COLUMN", 13, "" '                                                              no, report error to programmer
  533.     END IF
  534.  
  535.     column = cell MOD SL_sheet(sheet, 0, 0).swidth '                                                    get column sprite is in
  536.     IF column = 0 THEN '                                                                                right-most column?
  537.         SL_GET_COLUMN = SL_sheet(sheet, 0, 0).swidth '                                                  return right-most column value
  538.     ELSE '                                                                                              no, in another column
  539.         SL_GET_COLUMN = column '                                                                        return the column sprite is in
  540.     END IF
  541.  
  542.  
  543. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  544. FUNCTION SL_GET_CELL (handle AS INTEGER) '                                                                                                                                                  SL_GET_CELL
  545.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  546.  
  547.     ' declare global variables
  548.  
  549.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  550.  
  551.     ' perform error checks
  552.  
  553.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  554.         SL_ERROR "SL_GET_CELL", 1, "" '                                                                 no, report error to programmer
  555.     END IF
  556.  
  557.     SL_GET_CELL = SL_sprite(handle).anim.cell '                                                         return animation cell of this sprite
  558.  
  559.  
  560. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  561. FUNCTION SL_VALID_CELL (sheet AS INTEGER, cell AS INTEGER) '                                                                                                                              SL_VALID_CELL
  562.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  563.  
  564.     ' declare global variables
  565.  
  566.     SHARED SL_sheet() AS SL_SHEET '    master sprite sheet array
  567.  
  568.     IF NOT SL_VALID_SHEET(sheet) THEN '                                                                 is this a valid sheet?
  569.         SL_ERROR "SL_VALID_CELL", 5, "" '                                                               no, report error to programmer
  570.     END IF
  571.  
  572.     IF (cell > SL_sheet(sheet, 0, 0).swidth * SL_sheet(sheet, 0, 0).sheight) OR (cell < 1) THEN '       does cell exceed total cells on sheet or less than one?
  573.         SL_VALID_CELL = 0 '                                                                    (FALSE)  yes, return false for invalid cell
  574.     ELSE '                                                                                              no, within total cells
  575.         SL_VALID_CELL = -1 '                                                                    (TRUE)  return true for valid cell
  576.     END IF
  577.  
  578.  
  579. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  580. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  581. '                                                                       ----------==========                 ==========----------
  582. '                                                                       ----------========== MOTION ROUTINES ==========----------
  583. '                                                                       ----------==========                 ==========----------
  584. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  585. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  586.  
  587. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  588. SUB SL_REVERSE_MOTIONX (handle AS INTEGER) '                                                                                                                                         SL_REVERSE_MOTIONX
  589.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  590.  
  591.     ' declare global variables
  592.  
  593.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  594.  
  595.     ' perform error checks
  596.  
  597.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  598.         SL_ERROR "SL_REVERSE_MOTIONX", 1, "" '                                                          no, report error to programmer
  599.     END IF
  600.  
  601.     SL_sprite(handle).x.dir = -SL_sprite(handle).x.dir '                                                reverse x motion direction
  602.  
  603.  
  604.  
  605. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  606. SUB SL_REVERSE_MOTIONY (handle AS INTEGER) '                                                                                                                                         SL_REVERSE_MOTIONY
  607.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  608.  
  609.     ' declare global variables
  610.  
  611.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  612.  
  613.     ' perform error checks
  614.  
  615.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  616.         SL_ERROR "SL_REVERSE_MOTIONY", 1, "" '                                                          no, report error to programmer
  617.     END IF
  618.  
  619.     SL_sprite(handle).y.dir = -SL_sprite(handle).y.dir '                                                reverse y motion direction
  620.  
  621.  
  622.  
  623. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  624. FUNCTION SL_GET_MOTIONX (handle AS INTEGER) '                                                                                                                                            SL_GET_MOTIONX
  625.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  626.  
  627.     ' declare global variables
  628.  
  629.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  630.  
  631.     ' perform error checks
  632.  
  633.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  634.         SL_ERROR "SL_GET_MOTIONX", 1, "" '                                                              no, report error to programmer
  635.     END IF
  636.  
  637.     SL_GET_MOTIONX = SL_sprite(handle).x.dir '                                                          return x motion direction
  638.  
  639.  
  640. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  641. FUNCTION SL_GET_MOTIONY (handle AS INTEGER) '                                                                                                                                            SL_GET_MOTIONY
  642.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  643.  
  644.     ' declare global variables
  645.  
  646.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  647.  
  648.     ' perform error checks
  649.  
  650.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  651.         SL_ERROR "SL_GET_MOTIONY", 1, "" '                                                              no, report error to programmer
  652.     END IF
  653.  
  654.     SL_GET_MOTIONY = SL_sprite(handle).y.dir '                                                          return y motion direction
  655.  
  656.  
  657. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  658. SUB SL_SET_MOTIONX (handle AS INTEGER, xdir AS SINGLE) '                                                                                                                                 SL_SET_MOTIONX
  659.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  660.     ' declare global variables
  661.  
  662.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  663.  
  664.     ' perform error checks
  665.  
  666.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  667.         SL_ERROR "SL_SET_MOTIONX", 1, "" '                                                              no, report error to programmer
  668.     END IF
  669.  
  670.     SL_sprite(handle).x.dir = xdir '                                                                    set x motion direction
  671.  
  672.  
  673. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  674. SUB SL_SET_MOTIONY (handle AS INTEGER, ydir AS SINGLE) '                                                                                                                                 SL_SET_MOTIONY
  675.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  676.  
  677.     ' declare global variables
  678.  
  679.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  680.  
  681.     ' perform error checks
  682.  
  683.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  684.         SL_ERROR "SL_SET_MOTIONY", 1, "" '                                                              no, report error to programmer
  685.     END IF
  686.  
  687.     SL_sprite(handle).y.dir = ydir '                                                                    set y motion direction
  688.  
  689.  
  690. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  691. SUB SL_UPDATE_MOTION (handle AS INTEGER) '                                                                                                                                             SL_UPDATE_MOTION
  692.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  693.  
  694.     ' declare global variables
  695.  
  696.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  697.  
  698.     ' perform error checks
  699.  
  700.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  701.         SL_ERROR "SL_UPDATE_MOTION", 1, "" '                                                            no, report error to programmer
  702.     END IF
  703.     IF SL_sprite(handle).motion.auto THEN '                                                             attempt to move sprite under automatic control?
  704.         SL_ERROR "SL_UPDATE_MOTION", 16, "" '                                                           yes, report error to programmer
  705.     END IF
  706.  
  707.     SL_sprite(handle).x.real = SL_sprite(handle).x.real + SL_sprite(handle).x.dir '                     update x location
  708.     SL_sprite(handle).y.real = SL_sprite(handle).y.real + SL_sprite(handle).y.dir '                     update y location
  709.     SL_PUT_SPRITE SL_sprite(handle).x.real, SL_sprite(handle).y.real, handle '                          update sprite location
  710.  
  711.  
  712. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  713. SUB SL_SET_MOTION (handle AS INTEGER, degrees AS INTEGER, speed AS SINGLE, auto AS INTEGER) '                                                                                            SL_SET_MOTION
  714.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  715.  
  716.     ' declare global variables
  717.  
  718.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  719.  
  720.     ' perform error checks
  721.  
  722.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  723.         SL_ERROR "SL_SET_DIRECTION", 1, "" '                                                            no, report error to programmer
  724.     END IF
  725.     IF auto < -1 OR auto > 0 THEN '                                               (SL_START & SL_STOP)  valid on/off switch supplied?
  726.         SL_ERROR "SL_CHANGE_AUTOMOTION", 7, "" '                                                        no, report error to programmer
  727.     END IF
  728.  
  729.     SL_sprite(handle).motion.speed = speed '                                                            set motion speed of sprite
  730.     SL_CHANGE_MOTION_DIRECTION handle, degrees '                                                        set motion angle of sprite
  731.     SL_sprite(handle).motion.auto = auto '                                        (SL_START & SL_STOP)  set auto-motion of sprite
  732.  
  733.  
  734. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  735. SUB SL_CHANGE_MOTION_DIRECTION (handle AS INTEGER, degrees AS INTEGER) '                                                                                                     SL_CHANGE_MOTION_DIRECTION
  736.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  737.  
  738.     ' declare global variables
  739.  
  740.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  741.  
  742.     ' delcare local variables
  743.  
  744.     DIM degree AS INTEGER '             degree angle passed in
  745.  
  746.     ' perform error checks
  747.  
  748.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  749.         SL_ERROR "SL_CHANGE_MOTION_DIRECTION", 1, "" '                                                  no, report error to programmer
  750.     END IF
  751.  
  752.     degree = SL_FIX_DEGREES(degrees) '                                                                  get degree angle passed in
  753.  
  754.     SL_sprite(handle).motion.angle = degree '                                                           set motion degree angle
  755.     SL_sprite(handle).x.dir = SIN(degree * .017453292) * SL_sprite(handle).motion.speed '               calculate x vector
  756.     SL_sprite(handle).y.dir = -COS(degree * .017453292) * SL_sprite(handle).motion.speed '              calculate y vector
  757.  
  758.  
  759. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  760. FUNCTION SL_GET_MOTION_DIRECTION (handle AS INTEGER) '                                                                                                                          SL_GET_MOTION_DIRECTION
  761.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  762.  
  763.     ' declare global variables
  764.  
  765.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  766.  
  767.     ' perform error checks
  768.  
  769.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  770.         SL_ERROR "SL_GET_MOTION_DIRECTION", 1, "" '                                                     no, report error to programmer
  771.     END IF
  772.  
  773.     SL_GET_MOTION_DIRECTION = SL_sprite(handle).motion.angle '                                          return direction sprite currently set to
  774.  
  775.  
  776. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  777. SUB SL_CHANGE_MOTION_SPEED (handle AS INTEGER, speed AS SINGLE) '                                                                                                                SL_CHANGE_MOTION_SPEED
  778.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  779.  
  780.     ' declare global variables
  781.  
  782.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  783.  
  784.     ' perform error checks
  785.  
  786.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  787.         SL_ERROR "SL_CHANGE_MOTION_SPEED", 1, "" '                                                      no, report error to programmer
  788.     END IF
  789.  
  790.     SL_sprite(handle).motion.speed = speed '                                                            set sprite motion speed
  791.     SL_sprite(handle).x.dir = SIN(SL_sprite(handle).motion.angle * .017453292) * speed '                calculate x vector
  792.     SL_sprite(handle).y.dir = -COS(SL_sprite(handle).motion.angle * .017453292) * speed '               calculate y vector
  793.  
  794.  
  795. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  796. FUNCTION SL_GET_MOTION_SPEED (handle AS INTEGER) '                                                                                                                                  SL_GET_MOTION_SPEED
  797.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  798.  
  799.     ' declare global variables
  800.  
  801.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  802.  
  803.     ' perform error checks
  804.  
  805.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  806.         SL_ERROR "SL_GET_MOTION_SPEED", 1, "" '                                                         no, report error to programmer
  807.     END IF
  808.  
  809.     SL_GET_MOTION_SPEED = SL_sprite(handle).motion.speed '                                              return current sprite motion speed
  810.  
  811.  
  812. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  813. SUB SL_CHANGE_AUTOMOTION (handle AS INTEGER, auto AS INTEGER) '                                                                                                                    SL_CHANGE_AUTOMOTION
  814.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  815.  
  816.     ' declare global variables
  817.  
  818.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  819.  
  820.     IF auto = -32767 THEN '                                                                 (SL_RESET)  reset auto motion?
  821.         SL_sprite(handle).motion.auto = 0 '                                                    (FALSE)  yes, turn auto motion off
  822.         EXIT SUB '                                                                                      leave subroutine
  823.     END IF
  824.  
  825.     ' perform error checks
  826.  
  827.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  828.         SL_ERROR "SL_CHANGE_AUTOMOTION", 1, "" '                                                        no, report error to programmer
  829.     END IF
  830.     IF auto < -1 OR auto > 0 THEN '                                               (SL_START & SL_STOP)  valid on/off switch supplied?
  831.         SL_ERROR "SL_CHANGE_AUTOMOTION", 7, "" '                                                        no, report error to programmer
  832.     END IF
  833.  
  834.     SL_sprite(handle).motion.auto = auto '                                              (TRUE & FALSE)  set auto motion status
  835.  
  836.  
  837. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  838. FUNCTION SL_GET_AUTOMOTION (handle AS INTEGER) '                                                                                                                                      SL_GET_AUTOMOTION
  839.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  840.  
  841.     ' declare global variables
  842.  
  843.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  844.  
  845.     ' perform error checks
  846.  
  847.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  848.         SL_ERROR "SL_GET_AUTOMOTION", 1, "" '                                                           no, report error to programmer
  849.     END IF
  850.  
  851.     SL_GET_AUTOMOTION = SL_sprite(handle).motion.auto '                                 (TRUE & FALSE)  return auto motion status
  852.  
  853.  
  854. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  855. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  856. '                                                                      ----------==========                   ==========----------
  857. '                                                                      ----------========== ROTATION ROUTINES ==========----------
  858. '                                                                      ----------==========                   ==========----------
  859. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  860. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  861.  
  862. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  863. SUB SL_UPDATE_ROTATION (handle AS INTEGER) '                                                                                                                                         SL_UPDATE_ROTATION
  864.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  865.  
  866.     ' declare global variables
  867.  
  868.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  869.  
  870.     ' perform error checks
  871.  
  872.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  873.         SL_ERROR "SL_UPDATE_ROTATION", 1, "" '                                                          no, report error to programmer
  874.     END IF
  875.     IF SL_sprite(handle).rotation.auto THEN '                                                           attempt to rotate sprite under automatic control?
  876.         SL_ERROR "SL_UPDATE_ROTATION", 17, "" '                                                         yes, report error to programmer
  877.     END IF
  878.  
  879.     SL_ROTATE_SPRITE handle, SL_sprite(handle).rotation.angle + SL_sprite(handle).rotation.speed '      rotate sprite to next degree angle
  880.     SL_PUT_SPRITE SL_sprite(handle).x.real, SL_sprite(handle).y.real, handle '                          update sprite rotation
  881.  
  882.  
  883.  
  884. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  885. SUB SL_SET_ROTATION (handle AS INTEGER, degrees AS INTEGER, speed AS INTEGER, auto AS INTEGER) '                                                                                        SL_SET_ROTATION
  886.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  887.  
  888.     ' declare global variables
  889.  
  890.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  891.  
  892.     ' perform error checks
  893.  
  894.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  895.         SL_ERROR "SL_SET_ROTATION", 1, "" '                                                             no, report error to programmer
  896.     END IF
  897.     IF auto < -1 OR auto > 0 THEN '                                               (SL_START & SL_STOP)  valid on/off switch supplied?
  898.         SL_ERROR "SL_SET_ROTATION", 8, "" '                                                             no, report error to programmer
  899.     END IF
  900.     IF ABS(degrees) > 359 THEN '                                                                        degree requested between -359 and 359?
  901.         SL_ERROR "SL_SET_ROTATION", 9, "" '                                                             no, report error to programmer
  902.     END IF
  903.  
  904.     SL_sprite(handle).rotation.speed = speed '                                                          set rotation speed
  905.     SL_ROTATE_SPRITE handle, degrees '                                                                  set start angle
  906.     SL_sprite(handle).rotation.auto = auto '                                                            set auto-rotation
  907.  
  908.  
  909. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  910. SUB SL_CHANGE_AUTOROTATION (handle AS INTEGER, auto AS INTEGER) '                                                                                                                SL_CHANGE_AUTOROTATION
  911.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  912.  
  913.     ' declare global variables
  914.  
  915.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  916.  
  917.     IF auto = -32767 THEN '                                                                 (SL_RESET)  reset auto rotate?
  918.         SL_sprite(handle).rotation.auto = 0 '                                                  (FALSE)  yes, turn auto rotation off
  919.         EXIT SUB '                                                                                      leave subroutine
  920.     END IF
  921.  
  922.     ' perform error checks
  923.  
  924.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  925.         SL_ERROR "SL_CHANGE_AUTOROTATION", 1, "" '                                                      no, report error to programmer
  926.     END IF
  927.     IF auto < -1 OR auto > 0 THEN '                                               (SL_START & SL_STOP)  valid on/off switch supplied?
  928.         SL_ERROR "SL_CHANGE_AUTOROTATION", 8, "" '                                                      no, report error to programmer
  929.     END IF
  930.  
  931.     SL_sprite(handle).rotation.auto = auto '                                            (TRUE & FALSE)  set auto rotation status
  932.  
  933.  
  934. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  935. FUNCTION SL_GET_AUTOROTATION (handle AS INTEGER) '                                                                                                                                  SL_GET_AUTOROTATION
  936.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  937.  
  938.     ' declare global variables
  939.  
  940.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  941.  
  942.     ' perform error checks
  943.  
  944.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  945.         SL_ERROR "SL_GET_AUTOROTATION", 1, "" '                                                         no, report error to programmer
  946.     END IF
  947.  
  948.     SL_GET_AUTOROTATION = SL_sprite(handle).rotation.auto '                             (TRUE & FALSE)  return auto rotation status
  949.  
  950.  
  951. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  952. SUB SL_CHANGE_ROTATION_SPEED (handle AS INTEGER, degrees AS INTEGER) '                                                                                                         SL_CHANGE_ROTATION_SPEED
  953.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  954.  
  955.     ' declare global variables
  956.  
  957.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  958.  
  959.     ' perform error checks
  960.  
  961.     IF degrees = -32767 THEN '                                                              (SL_RESET)  reset requested?
  962.         SL_sprite(handle).rotation.speed = 0 '                                               (SL_STOP)  turn auto spin off
  963.         EXIT SUB '                                                                                      leave subroutine
  964.     END IF
  965.  
  966.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  967.         SL_ERROR "SL_CHANGE_ROTATION_SPEED", 1, "" '                                                    no, report error to programmer
  968.     END IF
  969.     IF ABS(degrees) > 359 THEN '                                                                        degree requested between -359 and 359?
  970.         SL_ERROR "SL_CHANGE_ROTATION_SPEED", 9, "" '                                                    no, report error to programmer
  971.     END IF
  972.  
  973.     SL_sprite(handle).rotation.speed = degrees '                                                        set sprite spin rate
  974.  
  975.  
  976. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  977. FUNCTION SL_GET_ROTATION_SPEED (handle AS INTEGER) '                                                                                                                              SL_GET_ROTATION_SPEED
  978.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  979.  
  980.     ' declare global variables
  981.  
  982.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  983.  
  984.     ' perform error checks
  985.  
  986.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  987.         SL_ERROR "SL_GET_ROTATION_SPEED", 1, "" '                                                       no, report error to programmer
  988.     END IF
  989.  
  990.     SL_GET_ROTATION_SPEED = SL_sprite(handle).rotation.speed '                                          return current sprite spin rate
  991.  
  992.  
  993. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  994. SUB SL_ROTATE_SPRITE (handle AS INTEGER, degrees AS INTEGER) '                                                                                                                         SL_ROTATE_SPRITE
  995.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  996.  
  997.     ' declare global variables
  998.  
  999.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1000.  
  1001.     ' perform error checks
  1002.  
  1003.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1004.         SL_ERROR "SL_ROTATE_SPRITE", 1, "" '                                                            no, report error to programmer
  1005.     END IF
  1006.  
  1007.     IF degrees = -32767 THEN '                                                              (SL_RESET)  reset sprite rotation?
  1008.         SL_sprite(handle).rotation.angle = 0 '                                                          reset rotation angle
  1009.     ELSE
  1010.         SL_sprite(handle).rotation.angle = SL_FIX_DEGREES(degrees) '                                    set degree of rotation
  1011.     END IF
  1012.  
  1013.  
  1014. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1015. FUNCTION SL_FIX_DEGREES (degrees AS INTEGER) '                                                                                                                                           SL_FIX_DEGREES
  1016.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1017.  
  1018.     ' Credits: this function uses code contriibuted by codeguy
  1019.     '          https://www.qb64.org/forum/index.php?topic=537.15
  1020.  
  1021.     'declare local variables
  1022.  
  1023.     DIM degree AS INTEGER '             degree angle passed in
  1024.  
  1025.     ' set local variables
  1026.  
  1027.     degree = degrees MOD 360 '                                                                          get -359 to 359
  1028.     IF degree < 0 THEN '                                                                                need to make positive?
  1029.         SL_FIX_DEGREES = degree + 360 '                                                                 yes, correct value and return degree angle
  1030.     ELSE
  1031.         SL_FIX_DEGREES = degree '                                                                       no correction needed, return degree angle
  1032.     END IF
  1033.  
  1034.  
  1035. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1036. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1037. '                                                                      ----------==========                   ==========----------
  1038. '                                                                      ----------========== LOCATION ROUTINES ==========----------
  1039. '                                                                      ----------==========                   ==========----------
  1040. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1041. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1042.  
  1043. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1044. FUNCTION SL_GET_REALX (handle AS INTEGER) '                                                                                                                                                SL_GET_REALX
  1045.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1046.  
  1047.     ' declare global variables
  1048.  
  1049.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1050.  
  1051.     ' perform error checks
  1052.  
  1053.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1054.         SL_ERROR "SL_GET_REALX", 1, "" '                                                                no, report error to programmer
  1055.     END IF
  1056.  
  1057.     SL_GET_REALX = SL_sprite(handle).x.real '                                                           return real number center point x
  1058.  
  1059.  
  1060. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1061. FUNCTION SL_GET_REALY (handle AS INTEGER) '                                                                                                                                                SL_GET_REALY
  1062.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1063.  
  1064.     ' declare global variables
  1065.  
  1066.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1067.  
  1068.     ' perform error checks
  1069.  
  1070.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1071.         SL_ERROR "SL_GET_REALY", 1, "" '                                                                no, report error to programmer
  1072.     END IF
  1073.  
  1074.     SL_GET_REALY = SL_sprite(handle).y.real '                                                           return real number center point y
  1075.  
  1076.  
  1077. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1078. FUNCTION SL_GET_INTX (handle AS INTEGER) '                                                                                                                                                  SL_GET_INTX
  1079.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1080.  
  1081.     ' declare global variables
  1082.  
  1083.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1084.  
  1085.     ' perform error checks
  1086.  
  1087.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1088.         SL_ERROR "SL_GET_INTX", 1, "" '                                                                 no, report error to programmer
  1089.     END IF
  1090.  
  1091.     SL_GET_INTX = SL_sprite(handle).x.int '                                                             return integer number center point x
  1092.  
  1093.  
  1094. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1095. FUNCTION SL_GET_INTY (handle AS INTEGER) '                                                                                                                                                  SL_GET_INTY
  1096.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1097.  
  1098.     ' declare global variables
  1099.  
  1100.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1101.  
  1102.     ' perform error checks
  1103.  
  1104.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1105.         SL_ERROR "SL_GET_INTY", 1, "" '                                                                 no, report error to programmer
  1106.     END IF
  1107.  
  1108.     SL_GET_INTY = SL_sprite(handle).y.int '                                                             return integer number center point x
  1109.  
  1110.  
  1111. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1112. FUNCTION SL_GET_ACTUALX (handle AS INTEGER) '                                                                                                                                            SL_GET_ACTUALX
  1113.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1114.  
  1115.     ' declare global variables
  1116.  
  1117.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1118.  
  1119.     ' perform error checks
  1120.  
  1121.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1122.         SL_ERROR "SL_GET_ACTUALX", 1, "" '                                                              no, report error to programmer
  1123.     END IF
  1124.  
  1125.     SL_GET_ACTUALX = SL_sprite(handle).x.actual '                                                       return integer number upper left point x
  1126.  
  1127.  
  1128. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1129. FUNCTION SL_GET_ACTUALY (handle AS INTEGER) '                                                                                                                                            SL_GET_ACTUALY
  1130.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1131.  
  1132.     ' declare global variables
  1133.  
  1134.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1135.  
  1136.     ' perform error checks
  1137.  
  1138.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1139.         SL_ERROR "SL_GET_ACTUALY", 1, "" '                                                              no, report error to programmer
  1140.     END IF
  1141.  
  1142.     SL_GET_ACTUALY = SL_sprite(handle).y.actual '                                                       return integer number upper left point y
  1143.  
  1144.  
  1145. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1146. 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
  1147.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1148.  
  1149.     'declare local variables
  1150.  
  1151.     DIM a AS INTEGER '                  side a of triangle
  1152.     DIM b AS INTEGER '                  side b of triangle
  1153.  
  1154.     'solve for c (hypotenuse)
  1155.  
  1156.     a = x1 - x2 '                                                                                       get length of side a
  1157.     b = y1 = y2 '                                                                                       get length of side b
  1158.  
  1159.     SL_GET_DISTANCE_POINT_TO_POINT = INT(SQR(a * a + b * b)) '                                          return length of side c
  1160.  
  1161.  
  1162. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1163. FUNCTION SL_GET_DISTANCE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                 SL_GET_DISTANCE_TO_SPRITE
  1164.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1165.  
  1166.     ' declare global variables
  1167.  
  1168.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1169.  
  1170.     'perform error checks
  1171.  
  1172.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  1173.         SL_ERROR "SL_GET_DISTANCE_TO_SPRITE", 1, "" '                                                   no, report error to programmer
  1174.     END IF
  1175.  
  1176.     SL_GET_DISTANCE_TO_SPRITE = SL_GET_DISTANCE_POINT_TO_POINT(SL_sprite(handle1).x.int, SL_sprite(handle1).y.int, _
  1177.                                                                SL_sprite(handle2).x.int, SL_sprite(handle2).y.int) '  return distance to sprite 2
  1178.  
  1179.  
  1180. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1181. FUNCTION SL_GET_DISTANCE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                                                            SL_GET_DISTANCE_TO_POINT
  1182.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1183.  
  1184.     ' declare global variables
  1185.  
  1186.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1187.  
  1188.     'perform error checks
  1189.  
  1190.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1191.         SL_ERROR "SL_GET_DISTANCE_TO_POINT", 1, "" '                                                    no, report error to programmer
  1192.     END IF
  1193.  
  1194.     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
  1195.  
  1196.  
  1197. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1198. 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
  1199.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1200.  
  1201.     'declare local variables
  1202.  
  1203.     DIM angle AS INTEGER '              angle from first x,y location to second x,y location
  1204.  
  1205.     IF y1 = y2 THEN '                                                                                   both y values same?
  1206.         IF x1 = x2 THEN '                                                                               yes, both x values same?
  1207.             EXIT FUNCTION '                                                                             yes, there is no angle (0), leave
  1208.         END IF
  1209.         IF x2 > x1 THEN '                                                                               is second x to the right of first x?
  1210.             SL_GET_ANGLE_POINT_TO_POINT = 90 '                                                          yes, the angle must be 90 degrees
  1211.         ELSE '                                                                                          no, second x is to the left of first x
  1212.             SL_GET_ANGLE_POINT_TO_POINT = 270 '                                                         the angle must be 270 degrees
  1213.         END IF
  1214.         EXIT FUNCTION '                                                                                 leave function, angle computed
  1215.     END IF
  1216.     IF x1 = x2 THEN '                                                                                   both x values same?
  1217.         IF y2 > y1 THEN '                                                                               yes, is second y lower than first y?
  1218.             SL_GET_ANGLE_POINT_TO_POINT = 180 '                                                         yes, the angle must be 180
  1219.         END IF
  1220.         EXIT FUNCTION '                                                                                 leave function, angle computed (angle is 0 if no calculation done)
  1221.     END IF
  1222.     angle = ATN((x2 - x1) / (y2 - y1)) * -57.2957795131 '                                               calculate initial angle
  1223.     IF y2 < y1 THEN '                                                                                   is second y higher than first y?
  1224.         IF x2 > x1 THEN '                                                                               yes, is second x to right of first x?
  1225.             SL_GET_ANGLE_POINT_TO_POINT = angle '                                                       yes, angle needs no adjustment
  1226.         ELSE '                                                                                          no, second x is to left of first x
  1227.             SL_GET_ANGLE_POINT_TO_POINT = angle + 360 '                                                 adjust angle accordingly
  1228.         END IF
  1229.     ELSE '                                                                                              no, second y is lower than first y
  1230.         SL_GET_ANGLE_POINT_TO_POINT = angle + 180 '                                                     adjust angle accordingly
  1231.     END IF
  1232.  
  1233.  
  1234. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1235. FUNCTION SL_GET_ANGLE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                       SL_GET_ANGLE_TO_SPRITE
  1236.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1237.  
  1238.     ' declare global variables
  1239.  
  1240.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1241.  
  1242.     'perform error checks
  1243.  
  1244.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  1245.         SL_ERROR "SL_GET_ANGLE_TO_SPRITE", 1, "" '                                                      no, report error to programmer
  1246.     END IF
  1247.  
  1248.     SL_GET_ANGLE_TO_SPRITE = SL_GET_ANGLE_POINT_TO_POINT(SL_sprite(handle1).x.int, SL_sprite(handle1).y.int, _
  1249.                                                          SL_sprite(handle2).x.int, SL_sprite(handle2).y.int) ' return angle to sprite 2
  1250.  
  1251.  
  1252. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1253. FUNCTION SL_GET_ANGLE_FROM_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER) '                                                                                                   SL_GET_ANGLE_FROM_SPRITE
  1254.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1255.  
  1256.     ' declare global variables
  1257.  
  1258.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1259.  
  1260.     'perform error checks
  1261.  
  1262.     IF (NOT SL_VALID_SPRITE(handle1)) OR (NOT SL_VALID_SPRITE(handle2)) THEN '                          are these valid sprites?
  1263.         SL_ERROR "SL_GET_ANGLE_FROM_SPRITE", 1, "" '                                                    no, report error to programmer
  1264.     END IF
  1265.  
  1266.     SL_GET_ANGLE_FROM_SPRITE = SL_GET_ANGLE_POINT_TO_POINT(SL_sprite(handle2).x.int, SL_sprite(handle2).y.int, _
  1267.                                                            SL_sprite(handle1).x.int, SL_sprite(handle1).y.int) '  return angle from sprite 2
  1268.  
  1269.  
  1270. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1271. FUNCTION SL_GET_ANGLE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                                                                  SL_GET_ANGLE_TO_POINT
  1272.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1273.  
  1274.     ' declare global variables
  1275.  
  1276.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1277.  
  1278.     'perform error checks
  1279.  
  1280.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1281.         SL_ERROR "SL_GET_ANGLE_TO_POINT", 1, "" '                                                       no, report error to programmer
  1282.     END IF
  1283.  
  1284.     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
  1285.  
  1286.  
  1287. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1288. FUNCTION SL_GET_ANGLE_FROM_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                                                              SL_GET_ANGLE_FROM_POINT
  1289.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1290.  
  1291.     ' declare global variables
  1292.  
  1293.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1294.  
  1295.     'perform error checks
  1296.  
  1297.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1298.         SL_ERROR "SL_GET_ANGLE_FROM_POINT", 1, "" '                                                     no, report error to programmer
  1299.     END IF
  1300.  
  1301.     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
  1302.  
  1303.  
  1304. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1305. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1306. '                                                                       ----------==========                 ==========----------
  1307. '                                                                       ----------========== SPRITE ROUTINES ==========----------
  1308. '                                                                       ----------==========                 ==========----------
  1309. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1310. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1311.  
  1312. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1313. FUNCTION SL_COPY_SPRITE (handle AS INTEGER) '                                                                                                                                            SL_COPY_SPRITE
  1314.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1315.  
  1316.     ' declare global variables
  1317.  
  1318.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1319.  
  1320.     ' declare local variables
  1321.  
  1322.     DIM newhandle AS INTEGER '          handle of copied sprite
  1323.  
  1324.     ' perform error checks
  1325.  
  1326.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1327.         SL_ERROR "SL_COPY_SPRITE", 1, "" '                                                              no, report error to programmer
  1328.     END IF
  1329.  
  1330.     newhandle = 0 '                                                                                     initialize new handle counter
  1331.  
  1332.     ' increase sprite array's size if needed
  1333.  
  1334.     DO '                                                                                                look for next available handle
  1335.         newhandle = newhandle + 1 '                                                                     increment to next handle value
  1336.     LOOP UNTIL (NOT SL_sprite(newhandle).inuse) OR newhandle = UBOUND(SL_sprite) '                      stop looking when valid handle found
  1337.     IF SL_sprite(newhandle).inuse THEN '                                                                is the last array element in use?
  1338.         newhandle = newhandle + 1 '                                                                     yes, increment to next handle value
  1339.         REDIM _PRESERVE SL_sprite(newhandle) AS SL_SPRITE '                                             increase the size of the sprite array
  1340.     END IF
  1341.  
  1342.     ' copy new sprite
  1343.  
  1344.     SL_sprite(newhandle) = SL_sprite(handle) '                                                          copy entire sprite contents
  1345.     SL_sprite(newhandle).gfx.sprite = _COPYIMAGE(SL_sprite(handle).gfx.sprite, 33) '                    create an actual copy of the hardware sprite
  1346.     SL_sprite(newhandle).gfx.image = _COPYIMAGE(SL_sprite(handle).gfx.image, 32) '                      create an actual copy of the software image
  1347.     IF SL_sprite(handle).gfx.mask THEN '                                                                does the original contain a mask image?
  1348.         SL_sprite(newhandle).gfx.mask = _COPYIMAGE(SL_sprite(handle).gfx.mask, 32) '                    yes, create an actual copy of the software mask image
  1349.     END IF
  1350.  
  1351.     SL_COPY_SPRITE = newhandle '                                                                        return new sprite's handle pointer
  1352.  
  1353.  
  1354. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1355. SUB SL_STAMP_SPRITE (x AS INTEGER, y AS INTEGER, sheet AS INTEGER, column AS INTEGER, row AS INTEGER, degrees AS INTEGER, flip AS INTEGER, zoom AS INTEGER) '                           SL_STAMP_SPRITE
  1356.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1357.  
  1358.     ' declare global variables
  1359.  
  1360.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  1361.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1362.  
  1363.     ' declare local variables
  1364.  
  1365.     DIM tempsprite AS LONG '            temporary sprite to stamp
  1366.     DIM degree AS INTEGER '             rotation degree passed in
  1367.  
  1368.     ' set local variables
  1369.  
  1370.     degree = SL_FIX_DEGREES(degrees) '                                                                  get rotation degree passed in
  1371.  
  1372.     ' perform error checks
  1373.  
  1374.     IF NOT SL_VALID_SHEET(sheet) THEN '                                                                 is this a valid sheet?
  1375.         SL_ERROR "SL_STAMP_SPRITE", 5, "" '                                                             no, report error to programmer
  1376.     END IF
  1377.     IF column > UBOUND(SL_sheet, 2) OR row > UBOUND(SL_sheet, 3) OR row < 1 OR column < 1 THEN '        valid row and column requested?
  1378.         SL_ERROR "SL_STAMP_SPRITE", 6, "" '                                                             no, report error to programmer
  1379.     END IF
  1380.     IF flip < 0 OR flip > 3 THEN '                                                                      valid flip behavior requested?
  1381.         SL_ERROR "SL_STAMP_SPRITE", 3, "" '                                                             no, report error to programmer
  1382.     END IF
  1383.     IF zoom < 1 THEN '                                                                                  valid zoom level requested?
  1384.         SL_ERROR "SL_STAMP_SPRITE", 4, "" '                                                             no, report error to programmer
  1385.     END IF
  1386.  
  1387.     tempsprite = SL_NEW_SPRITE(sheet, column, row, 0, 0) '                                              create new temporary sprite
  1388.     SL_sprite(tempsprite).rotation.speed = degree '                                                     set speed of rotation
  1389.     SL_sprite(tempsprite).flip = flip '                                                                 set flipping behavior
  1390.     SL_sprite(tempsprite).zoom = zoom '                                                                 set zoom level
  1391.     SL_PUT_SPRITE x, y, tempsprite '                                                                    place sprite on current destination
  1392.     SL_FREE_SPRITE tempsprite '                                                                         temporary sprite no longer needed
  1393.  
  1394.  
  1395. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1396. SUB SL_UPDATE_AUTO_SPRITES () '                                                                                                                                                  SL_UPDATE_AUTO_SPRITES
  1397.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1398.  
  1399.     ' declare global variables
  1400.  
  1401.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1402.     SHARED SL_framerate AS INTEGER '    global frame rate
  1403.  
  1404.     ' declare local variables
  1405.  
  1406.     DIM handle AS INTEGER '             handle of sprite
  1407.     DIM nextcell AS SINGLE '            draw or skip next animation cell
  1408.  
  1409.     ' local variable setup
  1410.  
  1411.     handle = 0 '                                                                                        initialize handle counter
  1412.  
  1413.     DO '                                                                                                cycle through all sprite indexes
  1414.         handle = handle + 1 '                                                                           increment to next sprite handle
  1415.         IF SL_sprite(handle).inuse AND (SL_sprite(handle).motion.auto OR _
  1416.                                         SL_sprite(handle).rotation.auto OR _
  1417.                                         SL_sprite(handle).anim.auto) THEN '                             is this sprite being used and automagically controlled?
  1418.  
  1419.             ' auto motion
  1420.  
  1421.             IF SL_sprite(handle).motion.auto THEN '                                                     yes, is auto motion enabled?
  1422.                 SL_sprite(handle).x.real = SL_sprite(handle).x.real + SL_sprite(handle).x.dir '         yes, update x location
  1423.                 SL_sprite(handle).y.real = SL_sprite(handle).y.real + SL_sprite(handle).y.dir '         update y location
  1424.             END IF
  1425.  
  1426.             ' auto rotation
  1427.  
  1428.             IF SL_sprite(handle).rotation.auto THEN '                                                   is auto rotation enabled?
  1429.                 SL_sprite(handle).rotation.angle = SL_FIX_DEGREES(SL_sprite(handle).rotation.angle_
  1430.                                                                 + SL_sprite(handle).rotation.speed) '   yes, rotate sprite to next degree angle
  1431.             END IF
  1432.  
  1433.             ' auto animation
  1434.  
  1435.             IF SL_sprite(handle).anim.auto THEN '                                                       is auto animation enabled?
  1436.                 IF SL_sprite(handle).anim.skip = 0 THEN '                                               yes, always go to next cell?
  1437.                     nextcell = -1 '                                                             (TRUE)  yes, draw next cell
  1438.                 ELSE '                                                                                  no
  1439.  
  1440.                     ' decide to draw or skip next cell
  1441.  
  1442.                     SL_sprite(handle).anim.frame = SL_sprite(handle).anim.frame + 1 '                   increment frame counter
  1443.                     IF SL_sprite(handle).anim.skip = SL_sprite(handle).anim.frame THEN '                time to skip or go to next cell?
  1444.                         SL_sprite(handle).anim.frame = 0 '                                              yes, reset the frame counter
  1445.                         IF SL_sprite(handle).anim.framerate >= SL_framerate \ 2 THEN '                  should this cell be skipped?
  1446.                             nextcell = 0 '                                                     (FALSE)  yes, skip next cell
  1447.                         ELSE '                                                                          no
  1448.                             nextcell = -1 '                                                     (TRUE)  go to next cell
  1449.                         END IF
  1450.                     ELSEIF SL_sprite(handle).anim.framerate >= SL_framerate \ 2 THEN '                  no, is sprite frame rate equal or greater than half global frame rate?
  1451.                         nextcell = -1 '                                                                 yes, go to next cell
  1452.                     END IF
  1453.                 END IF
  1454.  
  1455.                 ' draw next cell
  1456.  
  1457.                 IF nextcell THEN '                                                                      update animation cell?
  1458.                     SELECT CASE SL_sprite(handle).anim.mode '                                           which animation mode is this sprite using?
  1459.                         CASE 0 '                                                          (SL_FORWARD)  move forward through the cells
  1460.                             SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cell + 1 '             increment animation cell
  1461.                             IF SL_sprite(handle).anim.cell > SL_sprite(handle).anim.cellto THEN '       passed the last cell?
  1462.                                 SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cellfrom '         yes, go back to first cell
  1463.                             END IF
  1464.                         CASE 1 '                                                         (SL_BACKWARD)  move backward through the cells
  1465.                             SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cell - 1 '             decrement animation cell
  1466.                             IF SL_sprite(handle).anim.cell < SL_sprite(handle).anim.cellfrom THEN '     passed the first cell?
  1467.                                 SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cellto '           yes, go back to last cell
  1468.                             END IF
  1469.                         CASE 2 '                                                        (SL_BACKFORTH)  ping-pong back and forth through the cells
  1470.                             SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cell + SL_sprite(handle).anim.dir ' increment/decrement animation cell
  1471.                             IF SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cellto OR _
  1472.                                SL_sprite(handle).anim.cell = SL_sprite(handle).anim.cellfrom THEN '     is this the first or last cell?
  1473.                                 SL_sprite(handle).anim.dir = -SL_sprite(handle).anim.dir '              yes, reverse animation direction
  1474.                             END IF
  1475.                     END SELECT
  1476.                     SL_sprite(handle).column = SL_GET_COLUMN(SL_sprite(handle).sheet, SL_sprite(handle).anim.cell) ' get cell column on sheet
  1477.                     SL_sprite(handle).row = SL_GET_ROW(SL_sprite(handle).sheet, SL_sprite(handle).anim.cell) '       get cell row on sheet
  1478.                 END IF
  1479.             END IF
  1480.             SL_PUT_SPRITE SL_sprite(handle).x.real, SL_sprite(handle).y.real, handle '                  update sprite motion location, rotation, and animation
  1481.         END IF
  1482.     LOOP UNTIL handle = UBOUND(SL_sprite) '                                                             leave when all indexes checked
  1483.  
  1484.  
  1485. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1486. SUB SL_SET_SOFTWARE (handle AS INTEGER, restores AS INTEGER) '                                                                                                                          SL_SET_SOFTWARE
  1487.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1488.  
  1489.     ' declare global variables
  1490.  
  1491.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1492.  
  1493.     'perform error checks
  1494.  
  1495.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1496.         SL_ERROR "SL_SET_SOFTWARE", 1, "" '                                                             no, report error to programmer
  1497.     END IF
  1498.     IF restores < -1 OR restores > 0 THEN '                                                             valid background restoration behavior requested?
  1499.         SL_ERROR "SL_SET_SOFTWARE", 2, "" '                                                             no, report error to programmer
  1500.     END IF
  1501.  
  1502.     SL_sprite(handle).software = -1 '                                                    (SL_SOFTWARE)  set sprite to software mode
  1503.     SL_sprite(handle).restore = restores '                                       (SL_SAVE & SL_NOSAVE)  set background saving behavior
  1504.  
  1505.  
  1506. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1507. SUB SL_SET_HARDWARE (handle AS INTEGER) '                                                                                                                                               SL_SET_HARDWARE
  1508.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1509.  
  1510.     ' declare global variables
  1511.  
  1512.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1513.  
  1514.     'perform error checks
  1515.  
  1516.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1517.         SL_ERROR "SL_SET_HARDWARE", 1, "" '                                                             no, report error to programmer
  1518.     END IF
  1519.  
  1520.     SL_sprite(handle).software = 0 '                                                     (SL_HARDWARE)  set sprite to hardware mode
  1521.  
  1522.  
  1523. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1524. SUB SL_SET_ZOOM (handle AS INTEGER, zoom AS INTEGER) '                                                                                                                                      SL_SET_ZOOM
  1525.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1526.  
  1527.     ' declare global variables
  1528.  
  1529.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1530.  
  1531.     IF zoom = -32767 THEN '                                                                 (SL_RESET)  reset zoom level?
  1532.         SL_sprite(handle).zoom = 100 '                                                                  yes, reset level to normal
  1533.         EXIT SUB '                                                                                      leave subroutine
  1534.     END IF
  1535.  
  1536.     ' perform error checks
  1537.  
  1538.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1539.         SL_ERROR "SL_SET_ZOOM", 1, "" '                                                                 no, report error to programmer
  1540.     END IF
  1541.     IF zoom < 1 THEN '                                                                                  valid zoom level requested?
  1542.         SL_ERROR "SL_SET_ZOOM", 4, "" '                                                                 no, report error to programmer
  1543.     END IF
  1544.  
  1545.     SL_sprite(handle).zoom = zoom '                                                                     set zoom level
  1546.  
  1547.  
  1548.  
  1549. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1550. SUB SL_FLIP_SPRITE (handle AS INTEGER, flip AS INTEGER) '                                                                                                                                SL_FLIP_SPRITE
  1551.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1552.  
  1553.     ' declare global variables
  1554.  
  1555.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1556.  
  1557.     ' perform error checks
  1558.  
  1559.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1560.         SL_ERROR "SL_FLIP_SPRITE", 1, "" '                                                              no, report error to programmer
  1561.     END IF
  1562.     IF flip < 0 OR flip > 3 THEN '                                                                      valid flip behavior requested?
  1563.         SL_ERROR "SL_FLIP_SPRITE", 3, "" '                                                              no, report error to programmer
  1564.     END IF
  1565.  
  1566.     IF flip = -32767 THEN '                                                                 (SL_RESET)  reset flipping behavior?
  1567.         SL_sprite(handle).flip = 0 '                                                       (SL_NOFLIP)  yes, reset flip value
  1568.     ELSE
  1569.         SL_sprite(handle).flip = flip '           (SL_NOFLIP, SL_HORIZONTAL, SL_VERTICAL, SL_FLIPBOTH)  set flipping behavior
  1570.     END IF
  1571.  
  1572.  
  1573. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1574. SUB SL_PUT_SPRITE (x AS SINGLE, y AS SINGLE, handle AS INTEGER) '                                                                                                                         SL_PUT_SPRITE
  1575.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1576.  
  1577.     ' declare global variables
  1578.  
  1579.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  1580.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1581.     SHARED SL_rotate() AS SL_ROTATE '   precalculated rotation table
  1582.  
  1583.     ' declare local variables
  1584.  
  1585.     DIM xa AS INTEGER '                 actual x location of sprite on screen
  1586.     DIM ya AS INTEGER '                 actual y location of sprite on screen
  1587.     DIM sw AS INTEGER '                 width of sprite to be drawn
  1588.     DIM sh AS INTEGER '                 height of sprite to be drawn
  1589.     DIM rw AS INTEGER '                 precalculated rotated sprite width
  1590.     DIM rh AS INTEGER '                 precalculated rotated sprite height
  1591.     DIM px0 AS INTEGER '                precalculated triangular coordinates
  1592.     DIM px1 AS INTEGER
  1593.     DIM px2 AS INTEGER
  1594.     DIM px3 AS INTEGER
  1595.     DIM py0 AS INTEGER
  1596.     DIM py1 AS INTEGER
  1597.     DIM py2 AS INTEGER
  1598.     DIM py3 AS INTEGER
  1599.     DIM image AS LONG '                 software sprite image
  1600.     DIM mask AS LONG '                  software sprite image mask
  1601.     DIM sprite AS LONG '                hardware sprite image
  1602.  
  1603.     ' perform error checks
  1604.  
  1605.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1606.         SL_ERROR "SL_PUT_SPRITE", 1, "" '                                                               no, report error to programmer
  1607.     END IF
  1608.  
  1609.     'local variable setup
  1610.  
  1611.     SL_sprite(handle).x.real = x '                                                            (SINGLE)  save requested x center location
  1612.     SL_sprite(handle).y.real = y '                                                            (SINGLE)  save requested y center location
  1613.     SL_sprite(handle).x.int = INT(x) '                                                       (INTEGER)  save screen x center location
  1614.     SL_sprite(handle).y.int = INT(y) '                                                       (INTEGER)  save screen y center location
  1615.     image = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).image '  get image from sprite sheet
  1616.     mask = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).mask '    get mask from sprite sheet
  1617.     sw = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).swidth '    get default sprite width from sprite sheet
  1618.     sh = SL_sheet(SL_sprite(handle).sheet, SL_sprite(handle).column, SL_sprite(handle).row).sheight '   get default sprite height from sprite sheet
  1619.  
  1620.     'free existing images
  1621.  
  1622.     _FREEIMAGE SL_sprite(handle).gfx.sprite '                                                           free hardware sprite image
  1623.     _FREEIMAGE SL_sprite(handle).gfx.image '                                                            free software sprite image
  1624.     IF SL_sprite(handle).gfx.mask THEN _FREEIMAGE SL_sprite(handle).gfx.mask '                          free software mask image
  1625.     IF SL_sprite(handle).restore THEN '                                                                 is sprite holding a background image?
  1626.         IF SL_sprite(handle).gfx.back THEN '                                                            yes, has a background image been saved yet?
  1627.             _PUTIMAGE (SL_sprite(handle).x.back, SL_sprite(handle).y.back), SL_sprite(handle).gfx.back 'yes, replace background with image
  1628.             _FREEIMAGE SL_sprite(handle).gfx.back '                                                     free hardware background image
  1629.         END IF
  1630.         IF NOT SL_sprite(handle).software THEN '                                                        was the sprite type changed?
  1631.             SL_sprite(handle).restore = 0 '                                                (SL_NOSAVE)  yes, stop saving background
  1632.         END IF
  1633.     END IF
  1634.  
  1635.     'adjust sprite rotation if needed
  1636.  
  1637.     IF SL_sprite(handle).rotation.angle THEN '                                                          rotate sprite?
  1638.         px0 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).px0 '                yes, get precalculated triangular coordinates
  1639.         px1 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).px1
  1640.         px2 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).px2
  1641.         px3 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).px3
  1642.         py0 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).py0
  1643.         py1 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).py1
  1644.         py2 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).py2
  1645.         py3 = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).py3
  1646.         rw = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).rwidth '              get precalculated rotated sprite width
  1647.         rh = SL_rotate(SL_sprite(handle).sheet, SL_sprite(handle).rotation.angle).rheight '             get precalculated rotated sprite height
  1648.         SL_sprite(handle).gfx.image = _NEWIMAGE(rw, rh, 32) '                                           create image using precalculated width/height
  1649.         _MAPTRIANGLE (0, 0)-(0, sh - 1)-(sw - 1, sh - 1), image TO _
  1650.                      (px0, py0)-(px1, py1)-(px2, py2), SL_sprite(handle).gfx.image '                    map rotated sprite onto image
  1651.         _MAPTRIANGLE (0, 0)-(sw - 1, 0)-(sw - 1, sh - 1), image TO _
  1652.                      (px0, py0)-(px3, py3)-(px2, py2), SL_sprite(handle).gfx.image
  1653.         IF SL_sprite(handle).transparency THEN '                                                        does this sprite have a mask?
  1654.             SL_sprite(handle).gfx.mask = _NEWIMAGE(rw, rh, 32) '                                        yes, create mask image
  1655.             _MAPTRIANGLE (0, 0)-(0, sh - 1)-(sw - 1, sh - 1), mask TO _
  1656.                          (px0, py0)-(px1, py1)-(px2, py2), SL_sprite(handle).gfx.mask '                 map rotated mask onto image
  1657.             _MAPTRIANGLE (0, 0)-(sw - 1, 0)-(sw - 1, sh - 1), mask TO _
  1658.                          (px0, py0)-(px3, py3)-(px2, py2), SL_sprite(handle).gfx.mask
  1659.         END IF
  1660.         sw = rw '                                                                                       save new sprite width
  1661.         sh = rh '                                                                                       save new sprite height
  1662.     ELSE '                                                                                              no rotation needed
  1663.         SL_sprite(handle).gfx.image = _COPYIMAGE(image, 32) '                                           copy software image from sprite sheet
  1664.         IF SL_sprite(handle).transparency THEN '                                                        does this sprite have a mask?
  1665.             SL_sprite(handle).gfx.mask = _COPYIMAGE(mask, 32) '                                         yes, copy software mask from sprite sheet
  1666.         END IF
  1667.     END IF
  1668.  
  1669.     'create hardware sprite
  1670.  
  1671.     SL_sprite(handle).gfx.sprite = _COPYIMAGE(SL_sprite(handle).gfx.image, 33) '                        create hardware sprite of image
  1672.  
  1673.     'adjust zoom level if needed
  1674.  
  1675.     IF SL_sprite(handle).zoom <> 100 THEN '                                                             zoom sprite in/out?
  1676.         sw = sw * SL_sprite(handle).zoom \ 100 '                                                        yes, calculate new zoom width
  1677.         sh = sh * SL_sprite(handle).zoom \ 100 '                                                        calculate new zoom height
  1678.     END IF
  1679.  
  1680.     'calculate actual sprite screen coordinates
  1681.  
  1682.     xa = SL_sprite(handle).x.int - sw \ 2 '                                                             calculate actual screen x location from center
  1683.     ya = SL_sprite(handle).y.int - sh \ 2 '                                                             calculate actual screen y location from center
  1684.     SL_sprite(handle).x.actual = xa '                                                        (INTEGER)  save actual screen x location
  1685.     SL_sprite(handle).y.actual = ya '                                                        (INTEGER)  save actual screen y location
  1686.  
  1687.     'get background image before placing sprite if necessary
  1688.  
  1689.     IF SL_sprite(handle).restore THEN '                                                                 is this sprite storing background images?
  1690.         SL_sprite(handle).gfx.back = _NEWIMAGE(sw, sh, 32) '                                            yes, create background image
  1691.         _PUTIMAGE , _DEST, SL_sprite(handle).gfx.back, (xa, ya)-(xa + sw - 1, ya + sh - 1) '            get background area from current destination
  1692.         SL_sprite(handle).x.back = xa '                                                                 record background x location
  1693.         SL_sprite(handle).y.back = ya '                                                                 record background y location
  1694.     END IF
  1695.  
  1696.     'use hardware or software image
  1697.  
  1698.     IF SL_sprite(handle).software THEN '                                                                is this a software sprite?
  1699.         sprite = SL_sprite(handle).gfx.image '                                                          yes, use the software image
  1700.     ELSE '                                                                                              no
  1701.         sprite = SL_sprite(handle).gfx.sprite '                                                         use the hardware image
  1702.     END IF
  1703.  
  1704.     ' place sprite on the current destination with desired flip method
  1705.  
  1706.     SELECT CASE SL_sprite(handle).flip '                                                                which flipping style is selected?
  1707.         CASE 0 '                                                                           (SL_NOFLIP)  normal, no flipping
  1708.             _PUTIMAGE (xa, ya)-(xa + sw - 1, ya + sh - 1), sprite '                                     draw normal sprite
  1709.         CASE 1 '                                                                       (SL_HORIZONTAL)  flip horizontally
  1710.             _PUTIMAGE (xa + sw - 1, ya)-(xa, ya + sh - 1), sprite '                                     draw horizontally flipped sprite
  1711.         CASE 2 '                                                                         (SL_VERTICAL)  flip vertically
  1712.             _PUTIMAGE (xa, ya + sh - 1)-(xa + sw - 1, ya), sprite '                                     draw vertically flipped sprite
  1713.         CASE 3 '                                                                         (SL_FLIPBOTH)  flip vertically and horizontally
  1714.             _PUTIMAGE (xa + sw - 1, ya + sh - 1)-(xa, ya), sprite '                                     draw horizontally and vertically flipped sprite
  1715.     END SELECT
  1716.  
  1717.  
  1718. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1719. FUNCTION SL_NEW_SPRITE (sheet AS INTEGER, column AS INTEGER, row AS INTEGER, software AS INTEGER, restores AS INTEGER) '                                                                  SL_NEW_SPRITE
  1720.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1721.  
  1722.     ' declare global variables
  1723.  
  1724.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  1725.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1726.  
  1727.     ' declare local variables
  1728.  
  1729.     DIM handle AS INTEGER '             handle (pointer) number of new sprite
  1730.  
  1731.     ' perform error checks
  1732.  
  1733.     IF NOT SL_VALID_SHEET(sheet) THEN '                                                                 is this a valid sprite sheet?
  1734.         SL_ERROR "SL_NEW_SPRITE", 5, "" '                                                               no, report error to programmer
  1735.     END IF
  1736.     IF column > UBOUND(SL_sheet, 2) OR row > UBOUND(SL_sheet, 3) OR row < 1 OR column < 1 THEN '        valid row and column requested?
  1737.         SL_ERROR "SL_NEW_SPRITE", 6, "" '                                                               no, report error to programmer
  1738.     END IF
  1739.     IF restores < -1 OR restores > 0 THEN '                                                             valid background restoration behavior requested?
  1740.         SL_ERROR "SL_NEW_SPRITE", 2, "" '                                                               no, report error to programmer
  1741.     END IF
  1742.     IF software < -1 OR software > 0 THEN '                                                             valid hardware / software setting requested?
  1743.         SL_ERROR "SL_NEW_SPRITE", 112, "" '                                                             no, report error to programmer
  1744.     END IF
  1745.     IF (NOT software) AND restores THEN '                                                               hardware image that restores background?
  1746.         SL_ERROR "SL_NEW_SPRITE", 113, "" '                                                             yes, report error to programmer
  1747.     END IF
  1748.  
  1749.     ' local variable setup
  1750.  
  1751.     handle = 0 '                                                                                        initialize handle value
  1752.  
  1753.     ' increase sprite array's size if needed
  1754.  
  1755.     DO '                                                                                                look for next available handle
  1756.         handle = handle + 1 '                                                                           increment to next handle value
  1757.     LOOP UNTIL (NOT SL_sprite(handle).inuse) OR handle = UBOUND(SL_sprite) '                            stop looking when valid handle found
  1758.     IF SL_sprite(handle).inuse THEN '                                                                   is the last array element in use?
  1759.         handle = handle + 1 '                                                                           yes, increment to next handle value
  1760.         REDIM _PRESERVE SL_sprite(handle) AS SL_SPRITE '                                                increase the size of the sprite array
  1761.     END IF
  1762.  
  1763.     ' populate sprite array, general settings
  1764.  
  1765.     SL_sprite(handle).inuse = -1 '                                                              (TRUE)  mark array index as in use
  1766.     SL_sprite(handle).sheet = sheet '                                                                   point to sheet where sprite resides
  1767.     SL_sprite(handle).column = column '                                                                 point to column on sheet where sprite located
  1768.     SL_sprite(handle).row = row '                                                                       point to row on sheet where sprite located
  1769.     SL_sprite(handle).software = software '                                (SL_SOFTWARE & SL_HARDWARE)  sprite treated as software or hardware image
  1770.     SL_sprite(handle).restore = restores '                                       (SL_SAVE & SL_NOSAVE)  background restore behavior of sprite
  1771.     SL_sprite(handle).swidth = SL_sheet(sheet, column, row).swidth '                                    get width of sprite
  1772.     SL_sprite(handle).sheight = SL_sheet(sheet, column, row).sheight '                                  get height of sprite
  1773.     SL_sprite(handle).collx1 = SL_sheet(sheet, column, row).collx1 '                                    get sprite's collision box boundaries
  1774.     SL_sprite(handle).colly1 = SL_sheet(sheet, column, row).colly1
  1775.     SL_sprite(handle).collx2 = SL_sheet(sheet, column, row).collx2
  1776.     SL_sprite(handle).colly2 = SL_sheet(sheet, column, row).colly2
  1777.     SL_sprite(handle).flip = 0 '                                                                        no sprite flipping
  1778.     SL_sprite(handle).zoom = 100 '                                                                      zoom normal at 100%
  1779.     SL_sprite(handle).score = 0 '                                                                       no point score
  1780.  
  1781.     ' animation settings
  1782.  
  1783.     SL_sprite(handle).anim.cell = SL_sheet(sheet, column, row).cell '                                   the animation cell this sprite is in
  1784.     SL_sprite(handle).anim.cellfrom = 0 '                                                               reset sprite beginning animation cell
  1785.     SL_sprite(handle).anim.cellto = 0 '                                                                 reset sprite ending animation cell
  1786.     SL_sprite(handle).anim.dir = 0 '                           (SL_FORWARD, SL_BACKWARD & SLBACKFORTH)  reset sprite animation direction
  1787.     SL_sprite(handle).anim.mode = 0 '                                                                   reset sprite animation mode
  1788.     SL_sprite(handle).anim.frame = 0 '                                                                  reset sprite animation frame counter
  1789.     SL_sprite(handle).anim.skip = 0 '                                                                   reset sprite animation skip rate
  1790.     SL_sprite(handle).anim.auto = 0 '                                                          (FALSE)  sprite has no auto animation
  1791.  
  1792.     ' x,y location settings
  1793.  
  1794.     SL_sprite(handle).x.real = 0 '                                                                      reset x location of sprite (center x)
  1795.     SL_sprite(handle).y.real = 0 '                                                                      reset y location of sprite (center y)
  1796.     SL_sprite(handle).x.int = 0 '                                                                       reset x location of sprite on screen INT(xreal) (center x)
  1797.     SL_sprite(handle).y.int = 0 '                                                                       reset y location of sprite on screen INT(yreal) (center y)
  1798.     SL_sprite(handle).x.actual = 0 '                                                                    reset x location of sprite on screen (upper left x)
  1799.     SL_sprite(handle).y.actual = 0 '                                                                    reset y location of sprite on screen (upper left y)
  1800.     SL_sprite(handle).x.dir = 0 '                                                                       x direction during motion
  1801.     SL_sprite(handle).y.dir = 0 '                                                                       y direction during motion
  1802.  
  1803.     ' graphics image settings
  1804.  
  1805.     SL_sprite(handle).gfx.back = 0 '                                                                    no background image saved yet
  1806.     SL_sprite(handle).gfx.sprite = _COPYIMAGE(SL_sheet(sheet, column, row).image, 33) '                 create hardware sprite image
  1807.     SL_sprite(handle).gfx.image = _COPYIMAGE(SL_sheet(sheet, column, row).image, 32) '                  copy software sprite image from sheet
  1808.     IF SL_sheet(sheet, column, row).transparency THEN '                                                 does this sprite use transparency?
  1809.         SL_sprite(handle).gfx.mask = _COPYIMAGE(SL_sheet(sheet, column, row).mask, 32) '                yes, copy software sprite mask image from sheet
  1810.         SL_sprite(handle).transparency = -1 '                                                   (TRUE)  remember this sprite has a transparency layer
  1811.     ELSE '                                                                                              no transparency
  1812.         SL_sprite(handle).gfx.mask = 0 '                                                                no mask will be brought in
  1813.         SL_sprite(handle).transparency = 0 '                                                   (FALSE)  remember this sprite has no transparency layer
  1814.     END IF
  1815.  
  1816.     ' rotation settings
  1817.  
  1818.     SL_sprite(handle).rotation.angle = 0 '                                                              no sprite rotation angle
  1819.     SL_sprite(handle).rotation.speed = 0 '                                                              no spin rate
  1820.     SL_sprite(handle).rotation.auto = 0 '                                                      (FALSE)  auto rotation disabled
  1821.  
  1822.     ' motion settings
  1823.  
  1824.     SL_sprite(handle).motion.speed = 0 '                                                                speed during motion
  1825.     SL_sprite(handle).motion.angle = 0 '                                                                direction during motion (0 - 359)
  1826.     SL_sprite(handle).motion.auto = 0 '                                                        (FALSE)  auto motion disabled
  1827.  
  1828.     SL_NEW_SPRITE = handle '                                                                            return pointer value of new sprite
  1829.  
  1830.  
  1831. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1832. SUB SL_FREE_SPRITE (handle AS INTEGER) '                                                                                                                                                 SL_FREE_SPRITE
  1833.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1834.  
  1835.     ' declare global variables
  1836.  
  1837.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1838.  
  1839.     ' check for errors
  1840.  
  1841.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1842.         SL_ERROR "SL_FREE_SPRITE", 1, "" '                                                              no, report error to programmer
  1843.     END IF
  1844.  
  1845.     ' restore background if this sprite saving background
  1846.  
  1847.     IF SL_sprite(handle).restore THEN '                                                                 is there a background image to restore?
  1848.         _PUTIMAGE (SL_sprite(handle).x.back, SL_sprite(handle).y.back), SL_sprite(handle).gfx.back '    yes, restore the image
  1849.         _FREEIMAGE SL_sprite(handle).gfx.back '                                                         free background image
  1850.     END IF
  1851.  
  1852.     ' free all image data associated with sprite
  1853.  
  1854.     IF SL_sprite(handle).gfx.back THEN _FREEIMAGE SL_sprite(handle).gfx.back '                          free background image if present
  1855.     IF SL_sprite(handle).gfx.mask THEN _FREEIMAGE SL_sprite(handle).gfx.mask '                          free sprite mask image if present
  1856.     _FREEIMAGE SL_sprite(handle).gfx.sprite '                                                           free hardware sprite image
  1857.     _FREEIMAGE SL_sprite(handle).gfx.image '                                                            free software sprite image
  1858.  
  1859.     IF (handle = UBOUND(sl_sprite)) AND (handle <> 1) THEN '                                            is handle the last element in array?
  1860.         REDIM _PRESERVE SL_sprite(handle - 1) AS SL_SPRITE '                                            yes, remove index and resize array
  1861.     ELSE '                                                                                              no, index somewhere else
  1862.         SL_sprite(handle).inuse = 0 '                                                          (FALSE)  mark index as usable later
  1863.     END IF
  1864.  
  1865.  
  1866. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1867. FUNCTION SL_VALID_SPRITE (handle AS INTEGER) '                                                                                                                                         SL_VALID_SPRITE
  1868.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1869.  
  1870.     ' declare global variables
  1871.  
  1872.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1873.  
  1874.     IF (handle > UBOUND(SL_SPRITE)) OR (NOT SL_sprite(handle).inuse) OR (handle < 1) THEN '              is this a valid sprite handle?
  1875.         SL_VALID_SPRITE = 0 '                                                                   (FALSE)  no, return 0
  1876.     ELSE '                                                                                               yes, it is valid
  1877.         SL_VALID_SPRITE = -1 '                                                                   (TRUE)  return -1
  1878.     END IF
  1879.  
  1880.  
  1881. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1882. SUB SL_SET_SCORE (handle AS INTEGER, score AS INTEGER) '                                                                                                                                   SL_SET_SCORE
  1883.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1884.  
  1885.     ' declare global variables
  1886.  
  1887.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1888.  
  1889.     ' perform error checks
  1890.  
  1891.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1892.         SL_ERROR "SL_SET_SCORE", 1, "" '                                                                no, report error to programmer
  1893.     END IF
  1894.  
  1895.     SL_sprite(handle).score = score '                                                                   set sprite score
  1896.  
  1897.  
  1898. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1899. FUNCTION SL_GET_SCORE (handle AS INTEGER) '                                                                                                                                                SL_GET_SCORE
  1900.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1901.  
  1902.     ' declare global variables
  1903.  
  1904.     SHARED SL_sprite() AS SL_SPRITE '   master working sprite array
  1905.  
  1906.     ' perform error checks
  1907.  
  1908.     IF NOT SL_VALID_SPRITE(handle) THEN '                                                               is this a valid sprite?
  1909.         SL_ERROR "SL_GET_SCORE", 1, "" '                                                                no, report error to programmer
  1910.     END IF
  1911.  
  1912.     SL_GET_SCORE = SL_sprite(handle).score '                                                            return sprite score
  1913.  
  1914.  
  1915. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1916. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1917. '                                                                       ----------==========                ==========----------
  1918. '                                                                       ----------========== SHEET ROUTINES ==========----------
  1919. '                                                                       ----------==========                ==========----------
  1920. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1921. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1922.  
  1923. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1924. FUNCTION SL_NEW_SHEET (filename AS STRING, swidth AS INTEGER, sheight AS INTEGER, transparency AS INTEGER, transcolor AS _UNSIGNED LONG) '                                       SL_NEW_SHEET
  1925.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  1926.  
  1927.     ' declare global variables
  1928.  
  1929.     SHARED SL_sheet() AS SL_SHEET '    master sprite sheet array
  1930.     SHARED SL_rotate() AS SL_ROTATE '  precalculated rotation table
  1931.  
  1932.     ' declare local variables
  1933.  
  1934.     DIM handle AS INTEGER '             handle (pointer) number of new sprite sheet
  1935.     DIM x AS INTEGER '                  generic counter to cycle through sheet sprite columns
  1936.     DIM y AS INTEGER '                  generic counter to cycle through sheet sprite rows
  1937.     DIM x1 AS INTEGER '                 generic counter to cycle though sprite for collision boundaries and mask creation
  1938.     DIM y1 AS INTEGER '                 generic ocunter to cycle though sprite for collision boundaries and mask creation
  1939.     DIM osource AS LONG '               original source image before this function was called
  1940.     DIM odest AS LONG '                 original destination image before this function was called
  1941.     DIM pixel AS _UNSIGNED LONG '       pixel color at each coordinate in sprite sheet
  1942.     DIM alpha AS _UNSIGNED LONG '       alpha level of current pixel
  1943.     DIM top AS INTEGER '                upper boundary of sprite image
  1944.     DIM bottom AS INTEGER '             lower boundary of sprite image
  1945.     DIM left AS INTEGER '               left boundary of sprite image
  1946.     DIM right AS INTEGER '              right boundary of sprite image
  1947.     DIM sheetimage AS LONG '            sprite sheet image
  1948.     DIM sheetwidth AS INTEGER '         width of sprite sheet in pixels
  1949.     DIM sheetheight AS INTEGER '        height of sprite sheet in pixels
  1950.     DIM rows AS INTEGER '               number of sprite rows contained on sheet
  1951.     DIM columns AS INTEGER '            number of sprite columns contained on sheet
  1952.     DIM clearcolor AS _UNSIGNED LONG '  transcolor passed in will be modified
  1953.     DIM tempsprite AS LONG '            temporary sprite for _CLEARCOLOR detection
  1954.     DIM px(3) AS SINGLE '               polar x coordinates of maptriangle *
  1955.     DIM py(3) AS SINGLE '               polar y coordinates of maptriangle *
  1956.     DIM sinr AS SINGLE '                sin rotation calculation           *  could all of these DOUBLEs
  1957.     DIM cosr AS SINGLE '                cosine rotation claculation        *  be changed to SINGLEs and     <-------------------------------------- LOOK
  1958.     DIM bx1 AS SINGLE '                 max boundaries of rotated sprite   *  still be accurate enough for
  1959.     DIM bx2 AS SINGLE '                                                    *  _MAPTRIANGLE?
  1960.     DIM by1 AS SINGLE '                                                    *
  1961.     DIM by2 AS SINGLE '                                                    *
  1962.     DIM x2 AS SINGLE '                  new computed polar coordinates     *
  1963.     DIM y2 AS SINGLE '                                                     *
  1964.  
  1965.     ' perform error checks
  1966.  
  1967.     IF NOT _FILEEXISTS(filename) THEN '                                                                 does the sprite sheet exist?
  1968.         SL_ERROR "SL_NEW_SHEET", 100, filename '                                                        no, report error to programmer
  1969.     END IF
  1970.     IF ABS(transparency) > 1 THEN '                                                                     valid transparency setting?
  1971.         SL_ERROR "SL_NEW_SHEET", 101, "" '                                                              no, report error to programmer
  1972.     END IF
  1973.     IF swidth < 1 OR sheight < 1 THEN '                                                                 valid sprite width/height supplied?
  1974.         SL_ERROR "SL_NEW_SHEET", 102, "" '                                                              no, report error to programmer
  1975.     END IF
  1976.     IF transparency = -1 AND UCASE$(RIGHT$(filename, 4)) <> ".PNG" THEN '                               wrong file type for transparency?
  1977.         SL_ERROR "SL_NEW_SHEET", 103, UCASE$(RIGHT$(filename, 4)) '                                     yes, report error to programmer
  1978.     END IF
  1979.  
  1980.     ' local variable setup
  1981.  
  1982.     sheetimage = _LOADIMAGE(filename, 32) '                                                             load sprite sheet file
  1983.     sheetwidth = _WIDTH(sheetimage) '                                                                   get width of sheet
  1984.     sheetheight = _HEIGHT(sheetimage) '                                                                 get height of sheet
  1985.     columns = sheetwidth \ swidth '                                                                     get number of whole columns of sprites
  1986.     rows = sheetheight \ sheight '                                                                      get number of whole rows of sprites
  1987.     IF columns < 1 OR rows < 1 THEN '                                                                   at least one sprite column and row on sheet?
  1988.         SL_ERROR "SL_NEW_SHEET", 104, "" '                                                              no, report error to programmer
  1989.     END IF
  1990.     osource = _SOURCE '                                                                                 remember current source image
  1991.     odest = _DEST '                                                                                     remember current destination image
  1992.     handle = 0 '                                                                                        initialize handle value
  1993.     clearcolor = transcolor '                                                                           get background/transparent color passed in
  1994.  
  1995.     ' increase sheet array's 1st dimension if needed to create a new sprite sheet
  1996.  
  1997.     DO '                                                                                                look for the next available handle
  1998.         handle = handle + 1 '                                                                           increment the handle value
  1999.     LOOP UNTIL (NOT SL_sheet(handle, 0, 0).image) OR handle = UBOUND(SL_sheet) '                        stop looking when valid handle value found
  2000.     IF SL_sheet(handle, 0, 0).image = -1 THEN '                                                 (TRUE)  is the last array element in use?
  2001.         handle = handle + 1 '                                                                           yes, increment the handle value
  2002.         REDIM _PRESERVE SL_sheet(handle, UBOUND(SL_sheet, 2), UBOUND(SL_sheet, 3)) AS SL_SHEET '        create new sheet in sprite array
  2003.         REDIM _PRESERVE SL_rotate(handle, UBOUND(SL_rotate, 2)) AS SL_ROTATE
  2004.     END IF
  2005.  
  2006.     ' increase sheet array's 2nd and 3rd dimensions if needed to match number of rows and columns
  2007.  
  2008.     IF columns > UBOUND(SL_sheet, 2) THEN '                                                             more columns in this sheet than others?
  2009.         REDIM _PRESERVE SL_sheet(handle, columns, UBOUND(SL_sheet, 3)) AS SL_SHEET '                    yes, increase the array's 2nd dimension to match
  2010.     END IF
  2011.     IF rows > UBOUND(SL_sheet, 3) THEN '                                                                more rows in this sheet than others?
  2012.         REDIM _PRESERVE SL_sheet(handle, UBOUND(SL_sheet, 2), rows) AS SL_SHEET '                       yes, increase the array's 3rd dimension to match
  2013.     END IF
  2014.  
  2015.     ' the variables in SL_sheet(x, 0, 0) will serve a dual purpose
  2016.     ' SL_sheet(x, 0, 0).image will contain either -1 (true) or 0 (false) to indicate the first dimension of the array is in use.
  2017.     ' SL_sheet(x, 0, 0).swidth will contain the number of columns contained in the sheet (the array's 2nd dimension)
  2018.     ' SL_sheet(x, 0, 0).sheight will contain the number of rows contained in the sheet (the array's 3rd dimension)
  2019.  
  2020.     SL_sheet(handle, 0, 0).image = -1 '                                                         (TRUE)  mark as in use
  2021.     SL_sheet(handle, 0, 0).swidth = columns '                                                           remember number of columns in sheet
  2022.     SL_sheet(handle, 0, 0).sheight = rows '                                                             remember number of rows in sheet
  2023.  
  2024.     ' identify transparency of sprite sheet if requested
  2025.  
  2026.     IF transparency = -1 THEN '                                                          (SL_USESHEET)  sheet have alpha channel?
  2027.         x = 0 '                                                                                         yes, start at upper left x of sheet
  2028.         y = 0 '                                                                                         start at upper left y of sheet
  2029.         alpha = 255 '                                                                                   assume no alpha channel
  2030.         _SOURCE sheetimage '                                                                            set sprite sheet image as source image
  2031.         DO '                                                                                            start looping through the sheet's pixels
  2032.             pixel = POINT(x, y) '                                                                       get the pixel's color attributes
  2033.             alpha = _ALPHA32(pixel) '                                                                   get the alpha level (0 - 255)
  2034.             IF alpha = 0 THEN EXIT DO '                                                                 if it is transparent then leave the loop
  2035.             x = x + 1 '                                                                                 move right one pixel
  2036.             IF x > sheetwidth THEN '                                                                    have we gone off the sheet?
  2037.                 x = 0 '                                                                                 yes, reset back to the left beginning
  2038.                 y = y + 1 '                                                                             move down one pixel
  2039.             END IF
  2040.         LOOP UNTIL y > sheetheight '                                                                    don't stop until the entire sheet has been checked
  2041.         IF alpha = 0 THEN '                                                                             did we find a transparent pixel?
  2042.             tempsprite = _NEWIMAGE(1, 1, 32) '                                                          yes, create a temporary image         * why did I have to do
  2043.             _CLEARCOLOR pixel, tempsprite '                                                             set pixel found as transparent        * this hack to get
  2044.             clearcolor = _CLEARCOLOR(tempsprite) '                                                      get the transparent color from image  * clearcolor to come out
  2045.             _FREEIMAGE tempsprite '                                                                     temporary image no longer needed      * to the right value?
  2046.         ELSE '                                                                                          no transparency found within sheet
  2047.             transparency = 1 '                                                                          set sheet to having no alpha channel
  2048.         END IF
  2049.     ELSEIF transparency = 0 THEN '                                                            (SL_SET)  manually set alpha channel?
  2050.         _CLEARCOLOR clearcolor, sheetimage '                                                            yes, set color as transparent
  2051.         clearcolor = _CLEARCOLOR(sheetimage) '                                                          get the transparent color ************* again, why this hack?
  2052.     END IF
  2053.  
  2054.     ' load sprites from sheet and place into sprite array
  2055.  
  2056.     x = 0 '                                                                                             reset column counter
  2057.     DO '                                                                                                cycle through sheet's columns
  2058.         x = x + 1 '                                                                                     increment column counter
  2059.         y = 0 '                                                                                         reset row counter
  2060.         DO '                                                                                            cycle through sheet's rows
  2061.             y = y + 1 '                                                                                 increment row counter
  2062.             SL_sheet(handle, x, y).cell = (y - 1) * columns + x '                                       record animation cell this sprite is in
  2063.             SL_sheet(handle, x, y).image = _NEWIMAGE(swidth, sheight, 32) '                             create software sprite image
  2064.             IF transparency < 1 THEN '                                                                  should a mask be created?
  2065.                 SL_sheet(handle, x, y).mask = _NEWIMAGE(swidth, sheight, 32) '                          yes, create software sprite mask image
  2066.                 _DEST SL_sheet(handle, x, y).mask '                                                     write to the mask image
  2067.             ELSE
  2068.                 SL_sheet(handle, x, y).transparency = 0 '                                      (FALSE)  set sprite as having no transparency
  2069.             END IF
  2070.             _PUTIMAGE , sheetimage, SL_sheet(handle, x, y).image,_
  2071.                 ((x - 1) * swidth, (y - 1) * sheight)-_
  2072.                 ((x - 1) * swidth + swidth - 1, (y - 1) * sheight + sheight - 1) '                      copy sprite from sheet and place in sprite image
  2073.  
  2074.             ' precalculate collision boundaries and update sprite mask if needed
  2075.  
  2076.             _SOURCE SL_sheet(handle, x, y).image '                                                      work from the software sprite image
  2077.             top = sheight - 1 '                                                                         set initial collision boundary markers
  2078.             left = swidth - 1
  2079.             bottom = 0
  2080.             right = 0
  2081.             x1 = 0 '                                                                                    reset width counter
  2082.             DO '                                                                                        cycle through width of sprite
  2083.                 y1 = 0 '                                                                                reset height counter
  2084.                 DO '                                                                                    cycle through height of sprite
  2085.                     IF POINT(x1, y1) <> clearcolor THEN '                                               is this pixel a transparent/background color?
  2086.                         IF x1 < left THEN left = x1 '                                                   no, save position if left-most pixel
  2087.                         IF y1 < top THEN top = y1 '                                                     save position if top-most pixel
  2088.                         IF x1 > right THEN right = x1 '                                                 save position if right-most pixel
  2089.                         IF y1 > bottom THEN bottom = y1 '                                               save position if bbottom-most pixel
  2090.                     END IF
  2091.                     IF transparency < 1 THEN '                                                          update software sprite mask?
  2092.                         IF POINT(x1, y1) = clearcolor THEN '                                            yes, is this pixel a transparent/background color?
  2093.                             PSET (x1, y1), _RGB32(255, 255, 255) '                                      yes, set as white on the mask image
  2094.                         END IF
  2095.                     END IF
  2096.                     y1 = y1 + 1 '                                                                       increment height counter
  2097.                 LOOP UNTIL y1 = sheight '                                                               leave when height of sprite reached (-1)
  2098.                 x1 = x1 + 1 '                                                                           increment width counter
  2099.             LOOP UNTIL x1 = swidth '                                                                    leave when width of sprite reached (-1)
  2100.             SL_sheet(handle, x, y).collx1 = left '                                                      collision box top left x
  2101.             SL_sheet(handle, x, y).colly1 = top '                                                       collision box top left y
  2102.             SL_sheet(handle, x, y).collx2 = right '                                                     collision box bottom right x
  2103.             SL_sheet(handle, x, y).colly2 = bottom '                                                    collision box bottom right y
  2104.             SL_sheet(handle, x, y).swidth = swidth '                                                    remember sprite width
  2105.             SL_sheet(handle, x, y).sheight = sheight '                                                  remember sprite height
  2106.         LOOP UNTIL y = rows '                                                                           leave when all rows processed
  2107.     LOOP UNTIL x = columns '                                                                            leave when all columns processed
  2108.     _FREEIMAGE sheetimage '                                                                             sprite sheet image no longer needed
  2109.  
  2110.     ' create precalculated rotation table for the sprite sheet (1 to 359 degrees)
  2111.  
  2112.     x = 0 '                                                                                             reset counter
  2113.     DO '                                                                                                cycle from 1 to 359 degrees
  2114.         x = x + 1 '                                                                                     increment counter
  2115.         'px(0) = (-swidth + 1) / 2 '                                                                     upper left  x polar coordinate of sprite
  2116.         'py(0) = (-sheight + 1) / 2 '                                                                    upper left  y polar coordinate of sprite
  2117.         px(0) = -swidth / 2 '                                                                           upper left  x polar coordinate of sprite
  2118.         py(0) = -sheight / 2 '                                                                          upper left  y polar coordinate of sprite
  2119.         px(1) = px(0) '                                                                                 lower left  x polar coordinate of sprite
  2120.         'py(1) = (sheight -1) / 2 '                                                                      lower left  y polar coordinate of sprite
  2121.         'px(2) = (swidth - 1) / 2 '                                                                      lower right x polar coordinate of sprite
  2122.         py(1) = sheight / 2 '                                                                           lower left  y polar coordinate of sprite
  2123.         px(2) = swidth / 2 '                                                                            lower right x polar coordinate of sprite
  2124.         py(2) = py(1) '                                                                                 lower right y polar coordinate of sprite
  2125.         px(3) = px(2) '                                                                                 upper right x polar coordinate of sprite
  2126.         py(3) = py(0) '                                                                                 upper right y polar coordinate of sprite
  2127.         sinr = SIN(-x / 57.2957795131) '                                                                calculate the sin of rotation
  2128.         cosr = COS(-x / 57.2957795131) '                                                                calculate the cosine of rotation
  2129.         bx1 = 0 '                                                                                       upper left x boundary of sprite
  2130.         by1 = 0 '                                                                                       upper left y boundary of sprite
  2131.         bx2 = 0 '                                                                                       lower right x boundary of sprite
  2132.         by2 = 0 '                                                                                       lower right y boundary of sprite
  2133.         y = 0 '                                                                                         reset counter
  2134.         DO '                                                                                            cycle through all four polar coordinates (0 to 3)
  2135.             x2 = (px(y) * cosr + sinr * py(y)) '                                                        compute new polar coordinate location
  2136.             y2 = (py(y) * cosr - px(y) * sinr) '                                                        compute new polar coordinate location
  2137.             px(y) = x2 '                                                                                save the new polar coordinate
  2138.             py(y) = y2 '                                                                                save the new polar coordinate
  2139.             IF px(y) < bx1 THEN bx1 = px(y) '                                                           save lowest  x value seen \  NOTE: use for
  2140.             IF px(y) > bx2 THEN bx2 = px(y) '                                                           save highest x value seen  \ background image         <--------------------- LOOK
  2141.             IF py(y) < by1 THEN by1 = py(y) '                                                           save lowest  y value seen  / rectangle coordinates
  2142.             IF py(y) > by2 THEN by2 = py(y) '                                                           save highest y value seen /
  2143.             y = y + 1 '                                                                                 increment counter
  2144.         LOOP UNTIL y = 4 '                                                                              leave when all coordinates calculated
  2145.         SL_rotate(handle, x).rwidth = bx2 - bx1 + 1 '                                                   calculate width of rotated sprite
  2146.         SL_rotate(handle, x).rheight = by2 - by1 + 1 '                                                  calculate height of rotated sprite
  2147.         x2 = SL_rotate(handle, x).rwidth \ 2 '                                                          calculate x offset
  2148.         y2 = SL_rotate(handle, x).rheight \ 2 '                                                         calculate y offset
  2149.         SL_rotate(handle, x).px0 = px(0) + x2 '                                                         add offsets to coordinates
  2150.         SL_rotate(handle, x).px1 = px(1) + x2
  2151.         SL_rotate(handle, x).px2 = px(2) + x2
  2152.         SL_rotate(handle, x).px3 = px(3) + x2
  2153.         SL_rotate(handle, x).py0 = py(0) + y2
  2154.         SL_rotate(handle, x).py1 = py(1) + y2
  2155.         SL_rotate(handle, x).py2 = py(2) + y2
  2156.         SL_rotate(handle, x).py3 = py(3) + y2
  2157.     LOOP UNTIL x = 359 '                                                                                leave when all degree angles calculated
  2158.  
  2159.     _SOURCE osource '                                                                                   return source to current
  2160.     _DEST odest '                                                                                       return destination to current
  2161.     SL_NEW_SHEET = handle '                                                                             return the handle number pointing to this sheet
  2162.  
  2163.  
  2164. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2165. FUNCTION SL_VALID_SHEET (sheet AS INTEGER) '                                                                                                                                             SL_VALID_SHEET
  2166.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2167.  
  2168.     ' declare global variables
  2169.  
  2170.     SHARED SL_sheet() AS SL_SHEET '    master sprite sheet array
  2171.  
  2172.     IF (sheet > UBOUND(SL_sheet)) OR (sheet < 1) THEN '                                                 is this a valid sheet?
  2173.         SL_VALID_SHEET = 0 '                                                                   (FALSE)  no, return false
  2174.     ELSEIF NOT SL_sheet(sheet, 0, 0).image THEN '                                                       is sprite sheet in use?
  2175.         SL_VALID_SHEET = 0 '                                                                   (FALSE)  no, return false
  2176.     ELSE '                                                                                              everything checks out
  2177.         SL_VALID_SHEET = -1 '                                                                   (TRUE)  return true
  2178.     END IF
  2179.  
  2180.  
  2181. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2182. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2183. '                                                                        ----------==========               ==========----------
  2184. '                                                                        ----------========== ERROR ROUTINE ==========----------
  2185. '                                                                        ----------==========               ==========----------
  2186. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2187. 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2188.  
  2189. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2190. SUB SL_ERROR (routine AS STRING, errno AS INTEGER, info AS STRING) '                                                                                                                           SL_ERROR
  2191.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  2192.  
  2193.     SCREEN 0, 0, 0, 0 '                                                                                 go to a pure text screen
  2194.     _FONT 16 '                                                                                          set the standard screen 0 font
  2195.     IF _FULLSCREEN THEN _FULLSCREEN _OFF '                                                              turn off full screen if on
  2196.     _AUTODISPLAY '                                                                                      auto update the display
  2197.     CLS '                                                                                               clear the screen
  2198.     COLOR 10, 0
  2199.     PRINT "                   **************************************" '                                 print error header
  2200.     PRINT "                   ** Sprite Library Error Encountered **"
  2201.     PRINT "                   **************************************"
  2202.     PRINT
  2203.     COLOR 15, 0
  2204.     PRINT " "; routine;
  2205.     COLOR 7, 0
  2206.     PRINT " has reported error";
  2207.     COLOR 30, 0
  2208.     PRINT STR$(errno)
  2209.     COLOR 7, 0
  2210.     PRINT
  2211.     SELECT CASE errno '                                                                                 which error number is being reported?
  2212.  
  2213.         ' general purpose errors for all subs/functions
  2214.  
  2215.         CASE 1
  2216.             PRINT "- the requested sprite does not exist"
  2217.         CASE 2
  2218.             PRINT "- invalid background restore setting supplied - valid settings are"
  2219.             PRINT "- : -1 (constant SL_SAVE)"
  2220.             PRINT "- :  0 (constant SL_NOSAVE)"
  2221.         CASE 3
  2222.             PRINT "- invalid flip setting supplied - valid settings are"
  2223.             PRINT "- : 0 (constant SL_NOFLIP)"
  2224.             PRINT "- : 1 (constant SL_HORIZONTAL)"
  2225.             PRINT "- : 2 (constant SL_VERTICAL)"
  2226.             PRINT "- : 3 (constant SL_FLIPBOTH)"
  2227.         CASE 4
  2228.             PRINT "- invalid zoom level setting supplied"
  2229.             PRINT "- zoom level must be greater than zero (0)"
  2230.         CASE 5
  2231.             PRINT "- the specified sprite sheet is not in use or does not exist"
  2232.         CASE 6
  2233.             PRINT "- invalid row or column selected for specified sprite sheet"
  2234.         CASE 7
  2235.             PRINT "- invalid auto motion behavior requested - valid settings are"
  2236.             PRINT "- : -1 (constant SL_START)"
  2237.             PRINT "- :  0 (constant SL_STOP)"
  2238.         CASE 8
  2239.             PRINT "- invalid auto rotation behavior requested - valid settings are"
  2240.             PRINT "- : -1 (constant SL_START)"
  2241.             PRINT "- :  0 (constant SL_STOP)"
  2242.         CASE 9
  2243.             PRINT "- rotation speed must be between -359 and 359 degrees"
  2244.         CASE 10
  2245.             PRINT "- frame rate must be greater than zero (0)"
  2246.         CASE 11
  2247.             PRINT "- frame rate must be greater than zero (0) and less than or equal"
  2248.             PRINT "- to the global frame rate"
  2249.         CASE 12
  2250.             PRINT "- incorrect animation direction mode setting - valid settings are"
  2251.             PRINT "- : 0 (constant SL_FORWARD)"
  2252.             PRINT "- : 1 (constant SL_BACKWARD)"
  2253.             PRINT "- : 2 (constant CL_BACKFORTH"
  2254.         CASE 13
  2255.             PRINT "- invalid cell value given - it must be greater than 0 and less"
  2256.             PRINT "- than or equal to the total number of animation cells on a sheet"
  2257.         CASE 14
  2258.             PRINT "- invalid auto animation behavior requested - valid settings are"
  2259.             PRINT "- : -1 (constant SL_START)"
  2260.             PRINT "- :  0 (constant SL_STOP)"
  2261.         CASE 15
  2262.             PRINT "- animation has not been assigned to this sprite - use"
  2263.             PRINT "- SL_SET_ANIMATION to assign animation to this sprite"
  2264.         CASE 16
  2265.             PRINT "- this srpite is already under auto motion control"
  2266.             PRINT "- use SL_CHANGE_AUTOMOTION to disable auto motion control"
  2267.         CASE 17
  2268.             PRINT "- this sprite is already under auto rotation control"
  2269.             PRINT "- use SL_CHANGE_AUTOROTATION to disable auto rotation control"
  2270.         CASE 18
  2271.             PRINT "- this sprite is already under auto animation control"
  2272.             PRINT "- use SL_CHNAGE_AUTOANIMATION to disable auto animation control"
  2273.         CASE 19
  2274.             PRINT "- the destination cell must be greater than the starting cell"
  2275.  
  2276.             ' errors belonging to SL_NEW_SHEET (100 - 109)
  2277.  
  2278.         CASE 100
  2279.             PRINT "- "; CHR$(34); info; CHR$(34); " sprite sheet does not exist"
  2280.             PRINT "- check path or spelling"
  2281.         CASE 101
  2282.             PRINT "- invalid transparency setting supplied - valid settings are"
  2283.             PRINT "- : -1 (constant SL_USESHEET)"
  2284.             PRINT "- :  0 (constant SL_SET)"
  2285.             PRINT "- :  1 (constant SL_NONE)"
  2286.         CASE 102
  2287.             PRINT "- sprite width and/or height must be greater than zero"
  2288.         CASE 103
  2289.             PRINT "- selecting to use a sheet's transparency only works with .PNG files"
  2290.             PRINT "- the function was passed a "; info; " file."
  2291.         CASE 104
  2292.             PRINT "- there must be at least one column and one row of sprites on sheet"
  2293.             PRINT "- the sheet being loaded does not meet these minimums"
  2294.  
  2295.             'errors belonging to SL_NEW_SPRITE (110 - 119)
  2296.  
  2297.             'CASE 110
  2298.             '    PRINT "- the specified sprite sheet is not in use or does not exist"
  2299.             'CASE 111
  2300.             '    PRINT "- invalid row or column selected for specified sprite sheet"
  2301.         CASE 112
  2302.             PRINT "- invalid hardware / software setting supplied - valid settings are"
  2303.             PRINT "- : -1 (constant SL_SOFTWARE)"
  2304.             PRINT "- :  0 (constant SL_HARDWARE)"
  2305.         CASE 113
  2306.             PRINT "- there is no need to restore the background with hardware sprites"
  2307.             PRINT "- change background restore setting to zero (0) (constant SL_NOSAVE)"
  2308.  
  2309.     END SELECT
  2310.     COLOR 12, 0
  2311.     PRINT
  2312.     PRINT " See sprite library doumentation for further explanation."
  2313.     COLOR 7, 0
  2314.     DO: LOOP UNTIL INKEY$ = "" '                                                                        clear the keyboard buffer
  2315.     END '                                                                                               end the program
  2316.  
  2317.  
  2318.  
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 23, 2018, 01:55:36 pm
Ok, it looks like ellipse collision is out for two ellipses colliding. This is the formula for it .. NO JOKE LOL

x = c*b^2/(2*(b^2 - 1)) - 1/2*sqrt(c^2*b^4/(b^2 - 1)^2 + (c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)/(3*(b^4 - 2*b^2 + 1)) - (c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)/(b^2 - 1)^2 + (- 108*c^2*(b^4*c - b^2*c)^2*b^4 + 72*(b^4 - 2*b^2 + 1)*c^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)*b^4 + 2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^3 + 108*(b^4 - 2*b^2 + 1)*(b^4*c - b^2*c)^2 + 36*(b^4*c - b^2*c)^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1) + sqrt((- 108*c^2*(b^4*c - b^2*c)^2*b^4 + 72*(b^4 - 2*b^2 + 1)*c^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)*b^4 + 2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^3 + 108*(b^4 - 2*b^2 + 1)*(b^4*c - b^2*c)^2 + 36*(b^4*c - b^2*c)^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1))^2 - 4*(- 12*(b^4 - 2*b^2 + 1)*c^2*b^4 + 12*(b^4*c - b^2*c)^2 + (c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^2)^3))^(1/3)/(3*2^(1/3)*(b^2 - 1)^2) + 2^(1/3)*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^2/(3*(b^2 - 1)^2*(- 108*c^2*(b^4*c - b^2*c)^2*b^4 + 72*(b^4 - 2*b^2 + 1)*c^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)*b^4 + 2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^3 + 108*(b^4 - 2*b^2 + 1)*(b^4*c - b^2*c)^2 + 36*(b^4*c - b^2*c)^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1) + sqrt((- 108*c^2*(b^4*c - b^2*c)^2*b^4 + 72*(b^4 - 2*b^2 + 1)*c^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)*b^4 + 2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^3 + 108*(b^4 - 2*b^2 + 1)*(b^4*c - b^2*c)^2 + 36*(b^4*c - b^2*c)^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1))^2 - 4*(- 12*(b^4 - 2*b^2 + 1)*c^2*b^4 + 12*(b^4*c - b^2*c)^2 + (c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^2)^3))^(1/3))) + 1/2*sqrt(2*c^2*b^4/(b^2 - 1)^2 - (c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)/(3*(b^4 - 2*b^2 + 1)) - (c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)/(b^2 - 1)^2 - (- 108*c^2*(b^4*c - b^2*c)^2*b^4 + 72*(b^4 - 2*b^2 + 1)*c^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)*b^4 + 2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^3 + 108*(b^4 - 2*b^2 + 1)*(b^4*c - b^2*c)^2 + 36*(b^4*c - b^2*c)^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1) + sqrt((- 108*c^2*(b^4*c - b^2*c)^2*b^4 + 72*(b^4 - 2*b^2 + 1)*c^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)*b^4 + 2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^3 + 108*(b^4 - 2*b^2 + 1)*(b^4*c - b^2*c)^2 + 36*(b^4*c - b^2*c)^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1))^2 - 4*(- 12*(b^4 - 2*b^2 + 1)*c^2*b^4 + 12*(b^4*c - b^2*c)^2 + (c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^2)^3))^(1/3)/(3*2^(1/3)*(b^2 - 1)^2) - 2^(1/3)*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^2/(3*(b^2 - 1)^2*(- 108*c^2*(b^4*c - b^2*c)^2*b^4 + 72*(b^4 - 2*b^2 + 1)*c^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)*b^4 + 2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^3 + 108*(b^4 - 2*b^2 + 1)*(b^4*c - b^2*c)^2 + 36*(b^4*c - b^2*c)^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1) + sqrt((- 108*c^2*(b^4*c - b^2*c)^2*b^4 + 72*(b^4 - 2*b^2 + 1)*c^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)*b^4 + 2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^3 + 108*(b^4 - 2*b^2 + 1)*(b^4*c - b^2*c)^2 + 36*(b^4*c - b^2*c)^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1))^2 - 4*(- 12*(b^4 - 2*b^2 + 1)*c^2*b^4 + 12*(b^4*c - b^2*c)^2 + (c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^2)^3))^(1/3)) - (8*c^3*b^6/(b^2 - 1)^3 - 16*c*b^2/(b^2 - 1) - 8*c*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)*b^2/(b^2 - 1)^3)/(4*sqrt(c^2*b^4/(b^2 - 1)^2 + (c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)/(3*(b^4 - 2*b^2 + 1)) - (c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)/(b^2 - 1)^2 + (- 108*c^2*(b^4*c - b^2*c)^2*b^4 + 72*(b^4 - 2*b^2 + 1)*c^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)*b^4 + 2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^3 + 108*(b^4 - 2*b^2 + 1)*(b^4*c - b^2*c)^2 + 36*(b^4*c - b^2*c)^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1) + sqrt((- 108*c^2*(b^4*c - b^2*c)^2*b^4 + 72*(b^4 - 2*b^2 + 1)*c^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)*b^4 + 2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^3 + 108*(b^4 - 2*b^2 + 1)*(b^4*c - b^2*c)^2 + 36*(b^4*c - b^2*c)^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1))^2 - 4*(- 12*(b^4 - 2*b^2 + 1)*c^2*b^4 + 12*(b^4*c - b^2*c)^2 + (c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^2)^3))^(1/3)/(3*2^(1/3)*(b^2 - 1)^2) + 2^(1/3)*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^2/(3*(b^2 - 1)^2*(- 108*c^2*(b^4*c - b^2*c)^2*b^4 + 72*(b^4 - 2*b^2 + 1)*c^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)*b^4 + 2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^3 + 108*(b^4 - 2*b^2 + 1)*(b^4*c - b^2*c)^2 + 36*(b^4*c - b^2*c)^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1) + sqrt((- 108*c^2*(b^4*c - b^2*c)^2*b^4 + 72*(b^4 - 2*b^2 + 1)*c^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)*b^4 + 2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^3 + 108*(b^4 - 2*b^2 + 1)*(b^4*c - b^2*c)^2 + 36*(b^4*c - b^2*c)^2*(c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1))^2 - 4*(- 12*(b^4 - 2*b^2 + 1)*c^2*b^4 + 12*(b^4*c - b^2*c)^2 + (c^2*b^4 - b^4 + d^2*b^2 + 2*b^2 - 1)^2)^3))^(1/3)))))

y = sqrt(1 - x^2)/b
Title: Re: Sprite Library Revisited
Post by: jack on September 23, 2018, 03:15:03 pm
that's a huge formula, how did generate it?
anyway, I tried to simplify the expression with Maple but no luck, however, Maple has a nice code conversion tool, so I had it convert the monster formula to Visual Basic
Code: QB64: [Select]
  1. t1 = CInt(b * b)
  2. t2 = CInt(CDbl(c) * CDbl(t1))
  3. t3 = t1 - 1
  4. t6 = CInt(CDbl(c) * CDbl(c))
  5. t7 = t1 * t1
  6. t8 = t6 * t7
  7. t9 = t3 * t3
  8. t10 = 1 / t9
  9. t11 = t8 * t10
  10. t12 = CInt(d * d)
  11. t14 = 2 * t1
  12. t15 = t12 * t1 + t14 - t7 + t8 - 1
  13. t20 = t15 / (3 * t7 - 6 * t1 + 3)
  14. t21 = t15 * t10
  15. t24 = CInt( Pow(CDbl(t7 * c - t2), CDbl(2)) )
  16. t27 = 108 * t6 * t24 * t7
  17. t28 = t7 - t14 + 1
  18. t29 = t28 * t6
  19. t32 = 72 * t29 * t15 * t7
  20. t33 = t15 * t15
  21. t35 = 2 * t33 * t15
  22. t37 = 108 * t28 * t24
  23. t39 = 36 * t24 * t15
  24. t41 = CInt( Pow(CDbl(-t27 + t32 + t35 + t37 + t39), CDbl(2)) )
  25. t45 = -12 * t29 * t7 + 12 * t24 + t33
  26. t46 = t45 * t45
  27. t50 = Sqrt(CDbl(-4 * t46 * t45 + t41))
  28. t52 = Pow(-CDbl(t27) + CDbl(t32) + CDbl(t35) + CDbl(t37) + CDbl(t39) + t50, 0.1E1 / 0.3E1)
  29. t53 = Pow(0.2E1, 0.1E1 / 0.3E1)
  30. t54 = t53 * t53
  31. t57 = t52 * t54 * CDbl(t10) / 0.6E1
  32. t62 = t53 * CDbl(t33) * CDbl(t10) / t52 / 0.3E1
  33. t64 = Sqrt(CDbl(t11) + CDbl(t20) - CDbl(t21) + t57 + t62)
  34. t71 = 1 / t9 / t3
  35. t86 = Sqrt(CDbl(2 * t11) - CDbl(t20) - CDbl(t21) - t57 - t62 - CDbl(8 * t6 * c * t7 * t1 * t71 - 16 * t2 / t3 - 8 * c * t15 * t1 * t71) / t64 / 0.4E1)
  36. t88 = CDbl(t2 / t3) / 0.2E1 - t64 / 0.2E1 + t86 / 0.2E1
  37.  
Title: Re: Sprite Library Revisited
Post by: bplus on September 23, 2018, 03:48:51 pm
Wow Jack, nice taming of a monster.

I wonder if these ellipse are only horizontal or vertical?

If so, there might be easier way given the x and y radius and the (x, y) origins.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 23, 2018, 03:57:38 pm
that's a huge formula, how did generate it?

I got the formula from here: http://yehar.com/blog/?p=2926
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 23, 2018, 04:00:10 pm
Wow Jack, nice taming of a monster.

I wonder if these ellipse are only horizontal or vertical?

If so, there might be easier way given the x and y radius and the (x, y) origins.

I was wondering that too. At one of the sites I was reading up about this they did mention there is a difference between vertical and horizontal axis verses non. However, that site did not offer up any workable formula I could use.
Title: Re: Sprite Library Revisited
Post by: bplus on September 23, 2018, 04:07:41 pm
I think I could work up a formula for ellipse of type A in link you just posted, what I call only vertical and horizontal (referring to the major and minor axis or the ellipse laying parallel to x and y axis).

If they are type B in that diagram, it gets a bit more complicated.

The million dollar question is where these ellipse are coming from in your sprite code. Are they coming with sprite frame or rectangle the sprite fits into or they coming from some other method.

The sprite frame gives a natural x and y radius = just half the height and half the width.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 23, 2018, 04:28:14 pm
In my code I calculated the ellipse vertical radius height by taking the farthest points in distance from each other vertically then took half of that for the radius.

Same thing for horizontal radius, farthest points from each other horizontally then half for the radius.

These two radii would then be the basis for the ellipse with a center point in the middle of the sprite.

If the radii are within one pixel of each other then the collision detection would default to circle instead.
Title: Re: Sprite Library Revisited
Post by: bplus on September 23, 2018, 04:46:58 pm
That's the complicated case, dang. That one would have to cook on the back burner for awhile.

Terry, did you know how to get the a, b, c... values for the monster? (I didn't read the article, one look at it had me running away as fast as I could. :-))

Hey, I wonder if there could be like an average between a circle and a rectangle,... the cooking has begun.
Title: Re: Sprite Library Revisited
Post by: bplus on September 23, 2018, 05:50:16 pm
One thing has boiled out already, you need both the x, y for each point farthest east, west, north and south, otherwise the object will be indeterminate between 2 likely shapes that would fit in the frame formed.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 24, 2018, 02:00:39 am
Another crazy day of programming. The collision routines are finished (but not yet completely debugged, so they may be a little wonky right now). Sprites can be collision detected using rectangle, circle, and pixel perfect at the moment.

The first mouse routine has been finished as well. You can now detect when the mouse in hovering, left click, right click, and middle click on a sprite.

I also sorted the source code routines by their type (Mouse Routines, Animation Routines, Motion Routines, Rotation Routines, etc..) separated by headers for easier reading and finding routines. Had to do that for my sanity.

Plus a slew of other routines added here and there. There are now 72 of them (3 of which are internal use only). 2700+ lines of code and counting. My fingers hurt. O.o

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

At first I tried to calculate the collision box and radius in real-time when a sprite was grabbed from the sheet. This proved too costly when rotation came into play. So for now what I have done is create an array that holds every possible collision box size and radius for every sprite given at every possible rotation angle. With this array, no matter how the sprite is presented, the pre-calculated data can be called and used with no impact on performance.

The only noticeable impact is during sprite sheet loading. In the example below, the sprite sheet has 72 cells at 64x64 pixels each. It takes my computer about 3 seconds to process all this data before the images appear. The more sprite sheets that get loaded, the more time preloading and calculating will take. I'm going to work on a method that allows the programmer to choose which sprites to pre-calculate for. For instance, a sprite that never rotates will have no need for 360 pre-calculated rotation angles, collision boxes, and radii.

If you run the code below you'll see the library does a perfect job of encapsulating a collision box around the sprite. It does a really good job of approximating the size of the collision circle needed as well.

I have not incorporated zoom into this yet, changing the size of the collision box and radii accordingly, but that should be fairly easy by simply multiplying by the zoom percentage.

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

Maybe you could save all the calculations made when loading a sprite sheet to another file, so you only have to do all those calculations once per sheet forever.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 26, 2018, 12:08:28 am
That's a good idea. Thank you for suggesting it.

A final project would then use that file if present. Yes, that would work.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 26, 2018, 05:07:50 pm
Here is a run-down of commands completed so far. I had to create this text file to keep track of everything, especially the options available for each command. It's getting too big to keep track in my head.

edit: oops forgot one

FUNCTION SL_GET_ROTATION_ANGLE (handle AS INTEGER)

- returns the current rotation angle of a sprite in degrees

Code: QB64: [Select]
  1. ----------==========                ==========----------
  2. ----------========== MOUSE ROUTINES ==========----------
  3. ----------==========                ==========----------
  4.  
  5.  
  6. FUNCTION SL_GET_MOUSE (handle AS INTEGER)
  7.  
  8. - get mouse interaction status with a single sprite or all sprites
  9. - use -1 (SL_ALL) to check all sprites
  10. - returns the event number of mouse interaction if checking just one sprite
  11. - returns -1 or 0 if a mouse event happened with any sprite when checking all sprites
  12.  
  13. FUNCTION SL_GET_MOUSE_EVENT (handle AS INTEGER)
  14.  
  15. - gets the last mouse event associated with sprite
  16. - useful for when all mouse interactions were checked with SL_GET_MOUSE
  17. - returns the event number of mouse interaction
  18. - resets the event number after checking
  19.  
  20. FUNCTION SL_GET_MOUSE_SPRITEX (handle AS INTEGER)
  21. FUNCTION SL_GET_MOUSE_SPRITEY (handle AS INTEGER)
  22.  
  23. - gets the x or y location of the mouse pointer on a sprite
  24. - returns a value from 0 to width or height of sprite
  25. - resets the location after checking
  26.  
  27. FUNCTION SL_GET_MOUSE_ACTUALX (handle AS INTEGER)
  28. FUNCTION SL_GET_MOUSE_ACTUALY (handle AS INTEGER)
  29.  
  30. - gets the x or y location of the mouse pointer on the screen in relation to the sprite
  31. - returns a value from 0 to width or height of screen
  32. - resets the location after checking
  33.  
  34.  
  35. ----------==========                    ==========----------
  36. ----------========== COLLISION ROUTINES ==========----------
  37. ----------==========                    ==========----------
  38.  
  39.  
  40. FUNCTION SL_GET_COLLISION (handle1 AS INTEGER, handle2 AS INTEGER)
  41.  
  42. - get the collision status of two sprites or one sprite with all sprites
  43. - use -1 (SL_ALL) to check for collision with all sprites
  44. - returns the handle of the sprite that was collided with
  45. - when checking all sprites the first sprite handle collided with is returned
  46.  
  47. FUNCTION SL_ROUND_COLLISION (x1 AS INTEGER, y1 AS INTEGER, r1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER, r2 AS INTEGER)
  48.  
  49. - checks for a circular collision between two points given their radius
  50. - returns -1 or 0 as collision status
  51.  
  52. 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)
  53.  
  54. - checks for a rectangular collision between rectangles with the coordinates, width, and height supplied
  55. - returns -1 or 0 as collision status
  56.  
  57. FUNCTION SL_PIXEL_COLLISION (handle1 AS INTEGER, handle2 AS INTEGER)
  58.  
  59. - checks for a pixel perfect collision between two sprites
  60. - returns handle2 or 0 as collision status
  61.  
  62. SUB SL_SET_COLLISION (handle AS INTEGER, mode AS INTEGER)
  63.  
  64. - sets a sprite's collision detection method
  65. - methods are 0 (SL_NODETECT or SL_RESET), 1 (SL_BOXDETECT), 2 (SL_ROUNDDETECT), 3 (SL_PIXELDETECT)
  66.  
  67.  
  68. ----------==========                    ==========----------
  69. ----------========== ANIMATION ROUTINES ==========----------
  70. ----------==========                    ==========----------
  71.  
  72.  
  73. SUB SL_SET_ANIMATION (handle AS INTEGER, cellfrom AS INTEGER, cellto AS INTEGER, mode AS INTEGER, framerate AS INTEGER, auto AS INTEGER)
  74.  
  75. - sets the animation characteristics of a sprite
  76. - sets start and ending animation cells
  77. - sets the animation mode to 0 (SL_FORWARD), 1 (SL_BACKWARD), or 2 (SL_BACKFORTH)
  78. - sets the auto animation mode to 0 (SL_STOP) or -1 (SL_START)
  79. - sets the sprite's local framerate from 1 to global frame rate
  80.  
  81. SUB SL_SET_FRAMERATE (framerate AS INTEGER)
  82.  
  83. - sets the global frame rate
  84. - updates all sprite frame rates of sprites with local frame rates set
  85. - if a sprite's local frame rate is greate than the new global frame rate the local frame rate will be set to the global frame rate
  86.  
  87. FUNCTION SL_GET_FRAMERATE ()
  88.  
  89. - returns the global frame rate value
  90.  
  91. SUB SL_NEXT_ANIMATION_CELL (handle AS INTEGER)
  92.  
  93. - updates the animation cell of a sprite to the next cell in line
  94. - will only work with sprites that have animation settings applied and are not being animated automatically
  95.  
  96. SUB SL_CHANGE_ANIMATION_CELLS (handle AS INTEGER, cellfrom AS INTEGER, cellto AS INTEGER)
  97.  
  98. - changes the starting and ending animation cell values of a sprite
  99. - will only work with sprites that have animation settings applied
  100.  
  101. SUB SL_CHANGE_ANIMATION_FRAMERATE (handle AS INTEGER, framerate AS INTEGER)
  102.  
  103. - changes the local frame rate of a sprite
  104.  
  105. SUB SL_CHANGE_AUTOANIMATION (handle AS INTEGER, auto AS INTEGER)
  106.  
  107. - enables or disables auto animation for a sprite
  108. - 0 (SL_STOP) to disable or -1 (SL_START) to enable
  109.  
  110. FUNCTION SL_GET_CELL (handle AS INTEGER)
  111.  
  112. - gets the sprites current image cell
  113. - the cell also corresponds to the location on the sprite sheet
  114. - this is also the current animation cell for animated sprites
  115.  
  116. FUNCTION SL_VALID_CELL (sheet AS INTEGER, cell AS INTEGER)
  117.  
  118. - reports if a cell exists on a given sprite sheet
  119. - returns 0 or -1
  120.  
  121.  
  122. ----------==========                 ==========----------
  123. ----------========== MOTION ROUTINES ==========----------
  124. ----------==========                 ==========----------
  125.  
  126.  
  127. SUB SL_SET_MOTION (handle AS INTEGER, degrees AS INTEGER, speed AS SINGLE, auto AS INTEGER)
  128.  
  129. - sets a sprite's motion characteristics
  130. - sets the sprite's x and y motion vectors based on degrees
  131. - sets the sprite's motion vector speeds based on speed
  132. - enables or disables automatic motion -1 (SL_START) to enable and 0 (SL_STOP) to disable
  133.  
  134. SUB SL_REVERSE_MOTIONX (handle AS INTEGER)
  135. SUB SL_REVERSE_MOTIONY (handle AS INTEGER)
  136.  
  137. - reverses the x or y motion vectors of a sprite
  138.  
  139. FUNCTION SL_GET_MOTIONX (handle AS INTEGER)
  140. FUNCTION SL_GET_MOTIONY (handle AS INTEGER)
  141.  
  142. - returns the x or y motion vectors of a sprite
  143.  
  144. SUB SL_SET_MOTIONX (handle AS INTEGER, xdir AS SINGLE)
  145. SUB SL_SET_MOTIONY (handle AS INTEGER, ydir AS SINGLE)
  146.  
  147. - sets the x or y motion vectors of a given sprite
  148.  
  149. SUB SL_UPDATE_MOTION (handle AS INTEGER)
  150.  
  151. - updates the x and y location of a sprite using the motion vectors of the sprite
  152. - will only work on sprites not under automatic motion control
  153.  
  154. SUB SL_CHANGE_MOTION_DIRECTION (handle AS INTEGER, degrees AS INTEGER)
  155.  
  156. - sets the x and y motion vectors of a sprite based on degrees
  157.  
  158. FUNCTION SL_GET_MOTION_DIRECTION (handle AS INTEGER)
  159.  
  160. - returns the x and y motion vector of a sprite in degrees
  161.  
  162. SUB SL_CHANGE_MOTION_SPEED (handle AS INTEGER, speed AS SINGLE)
  163.  
  164. - sets a sprite's x and y motion vector speeds
  165.  
  166. FUNCTION SL_GET_MOTION_SPEED (handle AS INTEGER)
  167.  
  168. - gets a sprite's x and y motion vector speed
  169.  
  170. SUB SL_CHANGE_AUTOMOTION (handle AS INTEGER, auto AS INTEGER)
  171.  
  172. - enables or disables a sprite's automatic motion
  173. - use -1 (SL_START) to enable or 0 (SL_STOP or SL_RESET) to disable
  174.  
  175. FUNCTION SL_GET_AUTOMOTION (handle AS INTEGER)
  176.  
  177. - returns the status of a sprite's automatic motion
  178. - returns -1 or 0
  179.  
  180.  
  181. ----------==========                   ==========----------
  182. ----------========== ROTATION ROUTINES ==========----------
  183. ----------==========                   ==========----------
  184.  
  185.  
  186. SUB SL_SET_ROTATION (handle AS INTEGER, degrees AS INTEGER, speed AS INTEGER, auto AS INTEGER)
  187.  
  188. - sets a sprite's automatic rotation characteristics
  189. - sets the degree angle of the sprite using degrees
  190. - sets the speed of rotation in degrees per frame using speed
  191. - enables -1 (SL_START) or disables 0 (SL_STOP) automatic rotation
  192.  
  193. SUB SL_UPDATE_ROTATION (handle AS INTEGER)
  194.  
  195. - updates the rotation angle of a sprite using the sprite's rotation settings
  196. - will only work on sprites not under automatic rotation control
  197.  
  198. SUB SL_CHANGE_AUTOROTATION (handle AS INTEGER, auto AS INTEGER)
  199.  
  200. - enables -1 (SL_START) or disables 0 (SL_STOP) sprite automatic rotation control
  201.  
  202. FUNCTION SL_GET_AUTOROTATION (handle AS INTEGER)
  203.  
  204. - get the status of a sprite's automatic rotation control
  205. - returns -1 or 0
  206.  
  207. SUB SL_CHANGE_ROTATION_SPEED (handle AS INTEGER, degrees AS INTEGER)
  208.  
  209. - sets a sprite's speed of rotation in degrees per frame
  210.  
  211. FUNCTION SL_GET_ROTATION_SPEED (handle AS INTEGER)
  212.  
  213. - gets the current speed of rotation of a given sprite
  214.  
  215. SUB SL_ROTATE_SPRITE (handle AS INTEGER, degrees AS INTEGER)
  216.  
  217. - rotates a sprite to the degree angle provided
  218. - 0 (SL_RESET) can be used to reset a sprite's angle
  219.  
  220. FUNCTION SL_FIX_DEGREES (degrees AS INTEGER)
  221.  
  222. - corrects any value given to fall within 0 to 359 degrees
  223.  
  224.  
  225. ----------==========                   ==========----------
  226. ----------========== LOCATION ROUTINES ==========----------
  227. ----------==========                   ==========----------
  228.  
  229.  
  230. FUNCTION SL_GET_REALX (handle AS INTEGER)
  231. FUNCTION SL_GET_REALY (handle AS INTEGER)
  232.  
  233. - returns the SINGLE value of the sprite's x and y center locations on the screen
  234.  
  235. FUNCTION SL_GET_INTX (handle AS INTEGER)
  236. FUNCTION SL_GET_INTY (handle AS INTEGER)
  237.  
  238. - returns the INTEGER value of the sprite's x and y center locations on the screen
  239.  
  240. FUNCTION SL_GET_ACTUALX (handle AS INTEGER)
  241. FUNCTION SL_GET_ACTUALY (handle AS INTEGER)
  242.  
  243. - returns the sprite's x and y coordinates of its upper left corner
  244.  
  245. FUNCTION SL_GET_DISTANCE_POINT_TO_POINT (x1 AS INTEGER, y1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER)
  246.  
  247. - returns the distance in pixels between two x and y coordinate pairs on the screen
  248.  
  249. FUNCTION SL_GET_DISTANCE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER)
  250.  
  251. - returns the distance in pixels between the center points of two sprites
  252.  
  253. FUNCTION SL_GET_DISTANCE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER)
  254.  
  255. - returns the distance in pixels between the center point of a sprite and an x and y coordinate pair
  256.  
  257. FUNCTION SL_GET_ANGLE_POINT_TO_POINT (x1 AS INTEGER, y1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER)
  258.  
  259. - returns the angle in degrees between two x and y coordinate pairs
  260.  
  261. FUNCTION SL_GET_ANGLE_TO_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER)
  262.  
  263. - returns the angle in degrees between the center points of sprite 1 TO sprite 2
  264.  
  265. FUNCTION SL_GET_ANGLE_FROM_SPRITE (handle1 AS INTEGER, handle2 AS INTEGER)
  266.  
  267. - returns the angle in degrees between the center points of sprite 1 FROM sprite 2
  268.  
  269. FUNCTION SL_GET_ANGLE_TO_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER)
  270.  
  271. - returns the angle in degrees from the center point of a sprite TO an x and y coordinate pair
  272.  
  273. FUNCTION SL_GET_ANGLE_FROM_POINT (handle AS INTEGER, x AS INTEGER, y AS INTEGER)
  274.  
  275. - returns the angle in degrees to the center point of a sprite FROM an x and y coordinate pair
  276.  
  277.  
  278. ----------==========                 ==========----------
  279. ----------========== SPRITE ROUTINES ==========----------
  280. ----------==========                 ==========----------
  281.  
  282.  
  283. SUB SL_SET_VISIBLE (handle AS INTEGER, visible AS INTEGER)
  284.  
  285. - enables or disables sprite visibility
  286. - while the sprite is invisible any automatic control will still be updated in the background
  287. - use -1 (SL_SHOW) or 0 (SL_HIDE) to set visibility
  288.  
  289. FUNCTION SL_COPY_SPRITE (handle AS INTEGER)
  290.  
  291. - copies a sprite to create a new one
  292. - all sprite characteristics are copied, to include any automatic control features
  293.  
  294. SUB SL_STAMP_SPRITE (x AS INTEGER, y AS INTEGER, sheet AS INTEGER, cell AS INTEGER, degrees AS INTEGER, flip AS INTEGER, zoom AS INTEGER)
  295.  
  296. - places a software image of a sprite onto a software surface
  297. - this subroutine does not actuallly create a new sprite in the process
  298. - the sprite image used is determined by the sheet and cell selected
  299. - the image can be rotated, flipped, and/or zoomed before placing as well
  300. - useful for creating background maps from sprite images
  301.  
  302. SUB SL_UPDATE_AUTO_SPRITES ()
  303.  
  304. - updates all sprites under any kind of automatic control
  305. - should be the last sprite command used before a _DISPLAY update
  306.  
  307. SUB SL_SET_SOFTWARE (handle AS INTEGER, restores AS INTEGER)
  308.  
  309. - set a sprite into software mode
  310. - sets the background saving method of the sprite -1 (SL_SAVE) or 0 (SL_NOSAVE)
  311.  
  312. SUB SL_SET_HARDWARE (handle AS INTEGER)
  313.  
  314. - set a sprite into hardware mode
  315. - turns off background saving since hardware sprites do not require this
  316. - if a background was saved before the mode change it will be restored one last time
  317.  
  318. SUB SL_SET_ZOOM (handle AS INTEGER, zoom AS INTEGER)
  319.  
  320. - sets the zoom level of a sprite in percent
  321. - zoom levels must be greater than 0
  322. - a zoom level of 100 (SL_RESET) will display a sprite at a normal zoom level
  323.  
  324. SUB SL_FLIP_SPRITE (handle AS INTEGER, flip AS INTEGER)
  325.  
  326. - sets the flipping characteristic of a sprite
  327. - 0 (SL_NOFLIP or SL_RESET) for no sprite flipping
  328. - 1 (SL_HORIZONTAL) for horizontal sprite flipping
  329. - 2 (SL_VERTICAL) for vertical sprite flipping
  330. - 3 (SL_FLIPBOTH) for vertical and horizontal sprite flipping
  331.  
  332. SUB SL_PUT_SPRITE (x AS SINGLE, y AS SINGLE, handle AS INTEGER)
  333.  
  334. - places a sprite on screen at the x and y coordinate pair
  335. - all characterisitcs of the sprite (zoom, flip, rotation, etc..) will be taken into account
  336.  
  337. FUNCTION SL_NEW_SPRITE (sheet AS INTEGER, cell AS INTEGER, software AS INTEGER, restores AS INTEGER)
  338.  
  339. - creates a new sprite from the sprite sheet and cell provided
  340. - a software 0 (SL_SOFTWARE) or 1 (SL_HARDWARE) sprite can be created
  341. - if a software sprite then background saving 0 (SL_NOSAVE) -1 (SL_SAVE) can be set as well
  342.  
  343. SUB SL_FREE_SPRITE (handle AS INTEGER)
  344.  
  345. - removes a sprite from memory and all of its associated image data
  346.  
  347. FUNCTION SL_VALID_SPRITE (handle AS INTEGER)
  348.  
  349. - tests a sprite pointer value to see if it points to a valid sprite in memory
  350. - returns -1 or 0
  351.  
  352. SUB SL_SET_SCORE (handle AS INTEGER, score AS INTEGER)
  353. FUNCTION SL_GET_SCORE (handle AS INTEGER)
  354.  
  355. - sets or gets the score associated with a sprite
  356. - used to keep track of scores in games
  357.  
  358.  
  359. ----------==========                ==========----------
  360. ----------========== SHEET ROUTINES ==========----------
  361. ----------==========                ==========----------
  362.  
  363.  
  364. FUNCTION SL_NEW_SHEET (filename AS STRING, swidth AS INTEGER, sheight AS INTEGER, transparency AS INTEGER, transcolor AS _UNSIGNED LONG)
  365.  
  366. - creates a new sprite sheet database in memory
  367. - grabs all images from the sprite sheet file provided ate their given width and height
  368. - transparency can be set in one of three ways:
  369. - -1 (SL_USESHEET) uses the file's built in slpha channel setting (.PNG files only)
  370. -  0 (SL_SET) use the value provided in transcolor as the sheet's transparency color
  371. -  1 (SL_NONE) the sheet uses no transparency
  372. - transcolor will be ignored unless a value of 0 (SL_SET) is used for the transparency setting
  373. - there must be at least one sprite on the sheet with the width and height provided
  374.  
  375. FUNCTION SL_VALID_SHEET (sheet AS INTEGER)
  376.  
  377. - tests a sheet pointer value to see if it points to a vlaid sprite sheet in memory
  378. - returns -1 or 0
  379.  
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 28, 2018, 03:49:51 pm
Hi Terry,

Maybe you could save all the calculations made when loading a sprite sheet to another file, so you only have to do all those calculations once per sheet forever.

I implemented your idea and wow did that make a difference.

The first time SL_NEW_SHEET is called a .ROT rotation file is created for the given sprite sheet. After that, if the file exists it uses that instead. What took 3 to 5 seconds before with the Mario sprite sheet  now happens in the blink of an eye.

I let SL_NEW_SHEET chew on that TR3B sprite sheet containing 228 sprites at 266x266 each. It took 4 minutes to calculate all of the rotational variables. But the second time around the file was loaded in 3 seconds. Safe to say no matter how many/big the sprite sheets get they will not be an issue now.

I'm going to create a stand-alone sprite sheet designer to go along with the library (my first major inform program). The stand-alone program will also create the .ROT file so the first time around SL_NEW_SHEET will have the file available right away.
Title: Re: Sprite Library Revisited
Post by: SMcNeill on September 28, 2018, 04:26:02 pm
3 seconds just to load a file?  That seems a little excessive.  Can you share the file saving/loading routines here?  (Or point to which they are in the library?)
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 28, 2018, 04:56:57 pm
I have a 3 dimension array that needs saved/loaded:

TYPE SL_ANGLE
    x1 AS INTEGER '                     collision box upper left x
    x2 AS INTEGER '                     collision box lower right x
    y1 AS INTEGER '                     collision box upper left y
    y2 AS INTEGER '                     collision box lower right y
    cwidth AS INTEGER '                 collision box width
    cheight AS INTEGER '                collision box height
    radius AS INTEGER '                 collision circle radius
    rwidth AS INTEGER '                 rotated sprite width
    rheight AS INTEGER '                rotated sprite height
    px0 AS INTEGER '                    rectangular rotation coordinates
    px1 AS INTEGER
    px2 AS INTEGER
    px3 AS INTEGER
    py0 AS INTEGER
    py1 AS INTEGER
    py2 AS INTEGER
    py3 AS INTEGER
END TYPE

SL_angle(x, y, 359) AS SL_ANGLE  (x = sheet#, y = cell#, rotational angle from 0 to 359

I tried saving the entire array with a single PUT command, but when I bring it back with a single GET for some reason all the data contained in the even numbered entries is set to zero.

Here is what I'm using to save the file:

Code: QB64: [Select]
  1.     IF NOT _FILEEXISTS(rotfile) THEN '                                                                  does it exist?
  2.         OPEN rotfile FOR BINARY AS #1 '                                                                 no, open it for writing
  3.         FOR x = 1 TO cells '                                                                            cycle through all sprite cells
  4.             FOR y = 0 TO 359 '                                                                          and their rotational angles
  5.                 PUT #1, , SL_angle(handle, x, y) '                                                      put the data
  6.             NEXT y
  7.         NEXT x
  8.         CLOSE #1 '                                                                                      close the file
  9.     END IF
  10.  

and here is what I am using to load the file:

Code: QB64: [Select]
  1.     rotfile = LEFT$(filename, INSTR(filename, ".") - 1) + ".rot" '                                      the name of the rotational data file
  2.     IF _FILEEXISTS(rotfile) THEN '                                                                      does it exist?
  3.         preloaded = -1 '                                                                                yes, remember that data has been preloaded
  4.         OPEN rotfile FOR BINARY AS #1 '                                                                 open it for reading
  5.         FOR x = 1 TO cells '                                                                            cycle through all animation cells
  6.             FOR y = 0 TO 359 '                                                                          and their associated rotational data
  7.                 GET #1, , SL_angle(handle, x, y) '                                                      get the data
  8.             NEXT y
  9.         NEXT x
  10.         CLOSE #1 '                                                                                      close the file
  11.     END IF
  12.  

Title: Re: Sprite Library Revisited
Post by: SMcNeill on September 28, 2018, 06:03:38 pm
Dim a memblock, point it to your array:


DIM m AS _MEM
M = _MEM(SL_Angle())

Set a temp variable to hold it all, and put that to the file in one go.

t$ = SPACE(M.SIZE)
_MEMGET M, M.OFFSET, t$
PUT #1, , t$
......

Reverse the process to restore it in one go.

t$ = SPACE$(M.SIZE)
GET #1, , t$
_MEMPUT M, M.OFFSET, t$

****************************

I'm thinking the end result should save you some disk access time.  (And if M can be static/shared, you won't need to _MEMFREE or assign it more than once, saving some initialization time there as well.)


*****************
*****************

EDIT:   And, I see potential issues with the shared code:  Change #1 to a FREEFILE handle.  You can't be certain that a library user isn't going to already have file #1 opened for some other purpose (such as a save game file).
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 28, 2018, 07:23:16 pm
Thank you for helping me make this better/faster.

Yes! You are correct, FREEFILE should always be used in library. I'm glad you caught that.
Title: Re: Sprite Library Revisited
Post by: TempodiBasic on September 29, 2018, 02:14:36 pm
Hi Terry
you have started to go on the moon and now your astroship is acrossing the rings of Saturn. Wonderful!!! Hard but great work!

about your issue about PUT#FileNumberFree, , array() and GET#FileNumberFree, , array()
using your model of code I have tried and it seems to work well saving and loading in one shot the array from/to the file.
Here my lazy mod:
Code: QB64: [Select]
  1. TYPE SL_ANGLE
  2.     x1 AS INTEGER '                     collision box upper left x
  3.     x2 AS INTEGER '                     collision box lower right x
  4.     y1 AS INTEGER '                     collision box upper left y
  5.     y2 AS INTEGER '                     collision box lower right y
  6.     cwidth AS INTEGER '                 collision box width
  7.     cheight AS INTEGER '                collision box height
  8.     radius AS INTEGER '                 collision circle radius
  9.     rwidth AS INTEGER '                 rotated sprite width
  10.     rheight AS INTEGER '                rotated sprite height
  11.     px0 AS INTEGER '                    rectangular rotation coordinates
  12.     px1 AS INTEGER
  13.     px2 AS INTEGER
  14.     px3 AS INTEGER
  15.     py0 AS INTEGER
  16.     py1 AS INTEGER
  17.     py2 AS INTEGER
  18.     py3 AS INTEGER
  19.  
  20. REDIM SL_angle(1 TO 2, 1 TO 5, 0 TO 359) AS SL_ANGLE '(x = sheet#, y = cell#, rotational angle from 0 to 359
  21.  
  22. 'IF NOT _FILEEXISTS("rotfile") THEN '                                                                  does it exist?
  23. handle = 1: cells = 5: numfile = FREEFILE
  24. OPEN "rotfile" FOR BINARY AS #numfile '                                                                 no, open it for writing
  25. FOR x = 1 TO cells '                                                                            cycle through all sprite cells
  26.     FOR y = 0 TO 359 '                                                                          and their rotational angles
  27.         SL_angle(handle, x, y).x1 = x
  28.         SL_angle(handle, x, y).y1 = y
  29.         SL_angle(handle, x, y).radius = y
  30.         PRINT SL_angle(handle, x, y).x1; " "; SL_angle(handle, x, y).y1; " "; SL_angle(handle, x, y).radius
  31.  
  32.     NEXT y
  33. PUT #numfile, , SL_angle() '                                                      put the data
  34. CLOSE #numfile '                                                                                      close the file
  35. 'END IF
  36.  
  37. '   rotfile = LEFT$(filename, INSTR(filename, ".") - 1) + ".rot" '                                      the name of the rotational data file
  38. VIEW PRINT 14 TO 24
  39. IF _FILEEXISTS("rotfile") THEN '                                                                      does it exist?
  40.     preloaded = -1 '                                                                                yes, remember that data has been preloaded
  41.     OPEN "rotfile" FOR BINARY AS #numfile '                                                                 open it for reading
  42.     GET #numfile, , SL_angle() '                                                      get the data
  43.     FOR x = 1 TO cells '                                                                            cycle through all animation cells
  44.         FOR y = 0 TO 359 '                                                                          and their associated rotational data
  45.             PRINT SL_angle(handle, x, y).x1; " "; SL_angle(handle, x, y).y1; " "; SL_angle(handle, x, y).radius
  46.         NEXT y
  47.     NEXT x
  48.     CLOSE #numfile '                                                                                      close the file
  49.  
  50.  

I hope this can be useful for your coding.
PS here I add Steve's suggestion to use FREEFILE to be safe from conflict about number of file used to open a file.
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on September 29, 2018, 04:30:02 pm
Thanks for code Tempo, I'll investigate it in a little bit.

Right now I'm tracking down some layer issues I have. I needed to have a working program to track the issues down so I created this quick Roman numeral clock using some cheesy clock graphics I found on the net. It's a good example showing how powerful this little library is already becoming. You'll need the two graphic files below if you wish to run the demo.

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

Update: I smoothed the second hand out as well. It now uses all 360 degrees when spinning.

Code: QB64: [Select]
  1.  
  2. DIM handsheet AS INTEGER '      clock hand sprite sheet
  3. DIM hour AS INTEGER '           hour hand sprite
  4. DIM minute AS INTEGER '         minute hand sprite
  5. DIM second AS INTEGER '         second hand sprite
  6. DIM h AS INTEGER '              current hour value
  7. DIM m AS INTEGER '              current minute value
  8. DIM s AS INTEGER '              current second value
  9. DIM currentscreen AS LONG '     current SL_SCREEN
  10. DIM tempscreen AS LONG '        a temporary screen needed for resizing
  11. DIM swidth AS INTEGER '         original width of screen
  12. DIM sheight AS INTEGER '        original height of screen
  13. DIM center AS INTEGER '         x and y center point of screen
  14. DIM frame AS INTEGER '          frame counter
  15. DIM olds AS INTEGER '           the previous second
  16.  
  17. swidth = 551 '                                                                                          set screen variables
  18. sheight = 551
  19. center = 276
  20. SL_SCREEN swidth, sheight, 1 '                                                                          set window size and layers
  21. _DELAY .1 '                                                                                             need to wait for _RESIZE below
  22. tempscreen = _RESIZE '                                                                                  clear resize flag
  23.  
  24. _TITLE "Clock Demo" '                                                                                   give window a title
  25. handsheet = SL_NEW_SHEET("hands73x533.png", 73, 533, SL_SET, _RGB32(255, 0, 255)) '                     load the clock hands
  26. hour = SL_NEW_SPRITE(1, handsheet, 2, SL_HARDWARE, SL_NOSAVE) '                                         get the hour hand
  27. minute = SL_NEW_SPRITE(1, handsheet, 1, SL_HARDWARE, SL_NOSAVE) '                                       get the minute hand
  28. second = SL_NEW_SPRITE(1, handsheet, 3, SL_HARDWARE, SL_NOSAVE) '                                       get the second hand
  29. _PUTIMAGE , _LOADIMAGE("face.png", 32) '                                                                display the clock face
  30. SL_SET_FRAMERATE 6 '                                                                                    set the global frame rate
  31.     _LIMIT SL_GET_FRAMERATE '                                                                           maintain global frame rate
  32.     h = VAL(TIME$) '                                                                                    get current hour value
  33.     IF h > 11 THEN h = h - 12 '                                                                         keep a 12 hour clock
  34.     m = VAL(MID$(TIME$, 4, 2)) '                                                                        get current minute value
  35.     s = VAL(MID$(TIME$, 7, 2)) '                                                                        get current second value
  36.     frame = frame + 1 '                                                                                 increment frame counter
  37.     IF s <> olds THEN '                                                                                 new second?
  38.         frame = 0 '                                                                                     yes, reset frame counter
  39.         olds = s '                                                                                      remember this second value
  40.     END IF
  41.     SL_ROTATE_SPRITE hour, 30 * h + m \ 2 '                                                             rotate hour hand into position
  42.     SL_ROTATE_SPRITE minute, 6 * m + s \ 10 '                                                           rotate minute hand into position
  43.     SL_ROTATE_SPRITE second, 6 * s + frame '                                                                    rotate second hand into position
  44.     SL_PUT_SPRITE center, center, hour '                                                                display the hour hand
  45.     SL_PUT_SPRITE center, center, minute '                                                              display the minute hand
  46.     SL_PUT_SPRITE center, center, second '                                                              display the second hand
  47.     IF _RESIZE THEN '                                                                                   did user resize screen?
  48.         currentscreen = _SOURCE '                                                                       yes, get the current screen pointer
  49.         tempscreen = _COPYIMAGE(_SOURCE, 32) '                                                          make a copy of the current screen
  50.         SCREEN tempscreen '                                                                             make the copy active
  51.         _FREEIMAGE currentscreen '                                                                      free the old current screen
  52.         SL_SCREEN _RESIZEWIDTH, _RESIZEWIDTH, 1 '                                                       create the new current screen (square _RESIZEWIDTH)
  53.         _PUTIMAGE (0, 0)-(_WIDTH(_SOURCE) - 1, _HEIGHT(_SOURCE) - 1), _LOADIMAGE("face.png", 32) '      stretch the clock face onto it
  54.         _FREEIMAGE tempscreen '                                                                         no longer need copy of old current screen
  55.         SL_SET_ZOOM hour, _WIDTH(_SOURCE) / swidth * 100 '                                              zoom the sprites to match new dimensions
  56.         SL_SET_ZOOM minute, _WIDTH(_SOURCE) / swidth * 100
  57.         SL_SET_ZOOM second, _WIDTH(_SOURCE) / swidth * 100
  58.         center = _WIDTH(_SOURCE) \ 2 '                                                                  new center point for clock hands
  59.     END IF
  60.     SL_DISPLAY '                                                                                        merge layers and display
  61. LOOP UNTIL _KEYHIT '                                                                                    leave when key hit
  62. SL_FREE_SPRITE hour '                                                                                   free sprites from memory
  63. SL_FREE_SPRITE minute
  64. SL_FREE_SPRITE second
Title: Re: Sprite Library Revisited
Post by: TempodiBasic on September 30, 2018, 09:39:44 am
Hi Terry
your clock demo is very fine
like you can see from the attachment file image...

it remember me the old fashion clock of the ancient time :-)

Waiting the evolution of your creature Sprite Library I'll take open eyes
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on October 18, 2018, 03:28:49 am
It's been a while since I posted an update. I am still working on the new library. I have most of the pieces I want in place, it's now time to go through those pieces and optimize the code. I purchased a wide carriage dot matrix printer because the code is getting LONG. At last count I was over 4000 lines. To this end during the optimization I am keeping code to 132 characters per line to match the printer.

Some additions I made since the last update:
- SIN and COSINE tables are now precalculated and used to speed up math routines.
- Sprite rotation table saving/loading is now done with one GET and PUT statement speeding it up drastically.
- Took a page from Python and designed data types to use RECT (rectangular) structures for easier manipulation (TOP, LEFT, RIGHT, BOTTOM).
- The programmer now has the option to have the sprite rotation file built during a sprite sheet load or have sprites done individually as needed.
- Saving of _SOURCE and _DEST throughout the code is now performed using a FILO stack structure.

Here is the newly designed code I have completed so far. Much leaner and cleaner. Much, much more to come.

Code: QB64: [Select]
  1.  
  2. CONST SL_NOTRANSPARENCY = _RGB32(2, 4, 6) ' the chance of a sheet using this as a transparent color are 16 million to 1
  3. CONST SL_WHITE = _RGB32(255, 255, 255)
  4.  
  5. CONST SL_FALSE = 0 '                    boolean truth test
  6. CONST SL_TRUE = -1 '                    boolean truth test
  7. CONST SL_PUSH = -1 '                    push _DEST and _SOURCE into stack
  8. CONST SL_POP = 0 '                      pop _DEST and _SOURCE out of stack
  9.  
  10.  
  11. TYPE SL_RECTANGLE '---------------- A RECTANGULAR STRUCTURE -----------------------------------------------------------------------
  12.     left AS INTEGER '               the left x coordinate       *  This structure should ALWAYS be used to describe any           *
  13.     right AS INTEGER '              the right x coordinate      *  rectangular object contained within the library. The screen,   *
  14.     top AS INTEGER '                the top y coordinate        *  layers, sprites, and objects are examples of rectangular       *
  15.     bottom AS INTEGER '             the bottom y coordinate     *  structures.                                                    *
  16.     centerx AS INTEGER '            the center x coordinate     *                                                                 *
  17.     centery AS INTEGER '            the center y coordinate     *                                                                 *
  18.     width AS INTEGER '              the width of rectangle      *                                                                 *
  19.     height AS INTEGER '             the height of rectangle     *                                                                 *
  20. END TYPE '-------------------------------------------------------------------------------------------------------------------------
  21.  
  22. TYPE SL_COLLISION '---------------- COLLISION BOX STRUCTURE -----------------------------------------------------------------------
  23.     collision AS SL_RECTANGLE '     collision box offsets
  24. END TYPE '-------------------------------------------------------------------------------------------------------------------------
  25.  
  26. TYPE SL_RECT '--------------------- RECTANGULAR STRUCTURES ------------------------------------------------------------------------
  27.     '                                                           *  -------------------------------------------------------------  *
  28.     offset AS SL_RECTANGLE '        rectangular offset values   *  These should be considered STATIC values. Once they have been  *
  29.     '                                                           *  set they should not be changed. These are used as offsets to   *
  30.     '                                                           *  rectangular objects placed on the screen. TOP and LEFT will    *
  31.     '                                                           *  ALWAYS be zero (0). RIGHT and BOTTOM will ALWAYS equal         *
  32.     '                                                           *  WIDTH - 1 and HEIGHT - 1 respectively.                         *
  33.     '                                                           *  WIDTH and HEIGHT respectively.                                 *
  34.     '                                                           *  -------------------------------------------------------------  *
  35.     '                                                           *  -------------------------------------------------------------  *
  36.     screen AS SL_RECTANGLE '        rectangular screen values   *  These should be considered as DYNAMIC values. The values       *
  37.     '                                                           *  contained here will be computed from the offsets above to      *
  38.     '                                                           *  obtain screen coordinates. These will change every time an     *
  39.     '                                                           *  object is moved based on the CENTERX and CENTERY values        *
  40.     '                                                           *  passed in.                                                     *
  41.     '                                                           *  -------------------------------------------------------------  *
  42.     '                                                           *  -------------------------------------------------------------  *
  43.     collision AS SL_RECTANGLE '     collision box offsets       *  These should be considered STATIC values. Once they have been  *
  44.     '                                                           *  set they should not be changed. These are used as offsets to   *
  45.     '                                                           *  rectangular object collision boxes within the sprite itself.   *
  46.     '                                                           *  Add these offsets to 'screen' above to identify the collision  *
  47.     '                                                           *  rectangular area within the sprite.                            *
  48.     '                                                           *  -------------------------------------------------------------  *
  49. END TYPE '-------------------------------------------------------------------------------------------------------------------------
  50.  
  51. TYPE SL_ANGLE '-------------------- PRECALCULATED SPRITE ROTATION ANGLE DATABASE --------------------------------------------------
  52.     inuse AS _BYTE '                -1 if array index in use
  53.     rect AS SL_COLLISION '          collision box offsets
  54.     px0 AS INTEGER '                rotation coordinates
  55.     px1 AS INTEGER '                (used by _MAPTRIANGLE)
  56.     px2 AS INTEGER
  57.     px3 AS INTEGER
  58.     py0 AS INTEGER
  59.     py1 AS INTEGER
  60.     py2 AS INTEGER
  61.     py3 AS INTEGER
  62. END TYPE '-------------------------------------------------------------------------------------------------------------------------
  63.  
  64. TYPE SL_DEGREE '------------------- PRECALCULATED ROTATION DEGREE TABLE -----------------------------------------------------------
  65.     sin AS SINGLE '                 rotating sprites
  66.     cos AS SINGLE '                 rotating sprites
  67.     sinmap AS SINGLE '              maptriangle rotation
  68.     cosmap AS SINGLE '              maptriangle rotation
  69. END TYPE '-------------------------------------------------------------------------------------------------------------------------
  70.  
  71. TYPE SL_SHEET '-------------------- SPRITE SHEET DATABASE -------------------------------------------------------------------------
  72.     rect AS SL_COLLISION '          collision box offsets
  73.     image AS LONG '                 default sprite image
  74.     mask AS LONG '                  default sprite mask
  75.     anglekey AS INTEGER '           pointer to SL_angle
  76. END TYPE '-------------------------------------------------------------------------------------------------------------------------
  77.  
  78. TYPE SL_SPRITE
  79.     rect AS SL_RECT '               rectangular structures
  80.     zoom AS INTEGER
  81.  
  82. ' define arrays
  83.  
  84. REDIM SL_sheet(0, 0) AS SL_SHEET '      sprite sheet sprite database
  85. REDIM SL_angle(1, 359) AS SL_ANGLE '    precalculated rotation table
  86. DIM SL_degree(359) AS SL_DEGREE '       precalculated SIN/COS table
  87.  
  88.  
  89. ' main code (for testing)
  90.  
  91. DIM sprite AS SL_SPRITE
  92. DIM rect AS SL_RECTANGLE
  93. DIM dkong AS INTEGER
  94.  
  95. SL_START '                                                                  initialize library
  96. dkong = SL_LOAD_SHEET("dkong.png", 64, 64, _RGB32(255, 0, 255), SL_TRUE) '  load a sprite sheet
  97. SCREEN _NEWIMAGE(640, 480, 32) '                                            set up a screen
  98. _PUTIMAGE (100, 100), SL_sheet(dkong, 1).image '                            make sure SL_SHEET is getting images
  99. LINE (SL_sheet(dkong, 1).rect.collision.left + 100, SL_sheet(dkong, 1).rect.collision.top + 100)-_
  100.      (SL_sheet(dkong, 1).rect.collision.right + 100, SL_sheet(dkong, 1).rect.collision.bottom + 100),_
  101.      _RGB32(255, 255, 255), B '                                             draw the collision box
  102.  
  103.  
  104. '----------------------------------------------------------------------------------------------------------------------------------
  105. SUB SL_START ()
  106.     '------------------------------------------------------------------------------------------------------------------------------
  107.  
  108.     SHARED SL_degree() AS SL_DEGREE '   precalculated SIN/COS table
  109.     DIM degree AS INTEGER '             degree counter
  110.  
  111.     ' precalculate SIN/COS values and place in table
  112.  
  113.     DO '                                                                                    cycle 0 to 359 degrees
  114.         SL_degree(degree).sin = SIN(degree * .017453292) '                                  SIN of angle
  115.         SL_degree(degree).cos = -COS(degree * .017453292) '                                 COS of angle
  116.         'SL_degree(degree).sinmap = SIN(-degree / 57.2957795131) '                           MAPTRIANGLE SIN of angle
  117.         'SL_degree(degree).cosmap = COS(-degree / 57.2957795131) '                           MAPTRIANGLE COS of angle
  118.         SL_degree(degree).sinmap = SIN(-degree * .017453292) '                              MAPTRIANGLE SIN of angle
  119.         SL_degree(degree).cosmap = COS(-degree * .017453292) '                              MAPTRIANGLE COS of angle
  120.         degree = degree + 1 '                                                               increment degree counter
  121.     LOOP UNTIL degree = 360 '                                                               leave when all degrees calculated
  122.  
  123.  
  124. '----------------------------------------------------------------------------------------------------------------------------------
  125. FUNCTION SL_LOAD_SHEET (filename AS STRING, swidth AS INTEGER, sheight AS INTEGER, colour AS _UNSIGNED LONG, rotate AS INTEGER)
  126.     '------------------------------------------------------------------------------------------------------------------------------
  127.  
  128.     SHARED SL_sheet() AS SL_SHEET '     master sheet array
  129.     SHARED SL_angle() AS SL_ANGLE '     precalculated rotation angle array
  130.     REDIM SL_temp(0, 0) AS SL_ANGLE '   temporary rotation angle array
  131.     DIM clearcolor AS _UNSIGNED LONG '  transparency color of sprite sheet
  132.     DIM bounds AS SL_RECTANGLE '        rectangle boundaries
  133.     DIM transparent AS INTEGER '        -1 (TRUE) if sprite sheet contains transparency
  134.     DIM celltotal AS INTEGER '          total number of cells on sheet
  135.     DIM colcount AS INTEGER '           column counter
  136.     DIM rowcount AS INTEGER '           row counter
  137.     DIM anglekey AS INTEGER '           key index pointer to angle array
  138.     DIM filenum AS INTEGER '            the next free file handle
  139.     DIM preload AS INTEGER '            -1 (SL_TRUE) if rotation data file was loaded
  140.     DIM columns AS INTEGER '            number of columns on sheet
  141.     DIM rows AS INTEGER '               number of rows on sheet
  142.     DIM handle AS INTEGER '             next available sheet handle pointer
  143.     DIM rotfile AS STRING '             rotation data file name
  144.     DIM degree AS INTEGER '             degree counter
  145.     DIM cell AS INTEGER '               number of cells currently assigned in SL_sheet, and a cell counter
  146.     DIM sheet AS LONG '                 sheet image
  147.  
  148.     ' load sheet, determine rows / columns / cells, create an index in sheet array
  149.  
  150.     sheet = _LOADIMAGE(filename, 32) '                                                      load sprite sheet
  151.     columns = _WIDTH(sheet) \ swidth: rows = _HEIGHT(sheet) \ sheight '                     calculate number of columns and rows
  152.     celltotal = rows * columns '                                                            calculate number of cells
  153.     cell = UBOUND(SL_sheet, 2) '                                                            current number of cells in sheet array
  154.     IF celltotal > cell THEN cell = celltotal '                                             increase cells in sheet array
  155.     handle = UBOUND(SL_sheet) + 1 '                                                         get new sheet's handle pointer value
  156.     REDIM _PRESERVE SL_sheet(handle, cell) AS SL_SHEET '                                    create a new sheet entry in array
  157.  
  158.     ' load rotation data file if it exists
  159.  
  160.     IF rotate THEN '                                                                        precalculate rotations?
  161.         rotfile = LEFT$(filename, INSTR(filename, ".")) + "rot" '                           yes, create name of rotation file
  162.         filenum = FREEFILE '                                                                get next free file handle
  163.         REDIM SL_temp(celltotal, 359) AS SL_ANGLE '                                         increase array size to match sheet size
  164.         IF _FILEEXISTS(rotfile) THEN '                                                      does the rotation file exist?
  165.             OPEN rotfile FOR BINARY AS #filenum '                                           open the rotation file
  166.             GET #filenum, , SL_temp() '                                                     get the rotation data
  167.             CLOSE #filenum '                                                                close the file
  168.             anglekey = UBOUND(SL_angle) + 1 '                                               beginning index in array
  169.             REDIM _PRESERVE SL_angle(UBOUND(SL_angle) + UBOUND(sl_temp), 359) AS SL_ANGLE ' increase angle array to hold ne data
  170.             preload = SL_TRUE '                                                             remember that is has been loaded
  171.         END IF
  172.     END IF
  173.  
  174.     ' get or apply transparency to the sprite sheet
  175.  
  176.     IF colour <> SL_NOTRANSPARENCY THEN '                                                   use transparency?
  177.         transparent = SL_GetTransparentColor(sheet, clearcolor) '                           yes, get transparent layer of image
  178.         IF NOT transparent THEN '                                                           was a transparent color found?
  179.             _CLEARCOLOR colour, sheet '                                                     no, apply the supplied color
  180.             clearcolor = _CLEARCOLOR(sheet) '                                               get the transparent value from sheet
  181.             transparent = SL_TRUE '                                                         sheet now contains transparency
  182.         END IF
  183.     END IF
  184.  
  185.     ' cycle through the sheet and create related data
  186.  
  187.     DO '                                                                                    cycle through sheet's columns
  188.         colcount = colcount + 1 '                                                           increment column counter
  189.         rowcount = 0 '                                                                      reset row counter
  190.         DO '                                                                                cycle through sheet's rows
  191.  
  192.             ' get image from sheet and place in array
  193.  
  194.             rowcount = rowcount + 1 '                                                       increment row counter
  195.             cell = (rowcount - 1) * columns + colcount '                                    calculate current sprite's cell number
  196.             SL_sheet(handle, cell).image = _NEWIMAGE(swidth, sheight, 32) '                 create sprite image holder
  197.             bounds.left = (colcount - 1) * swidth '                                         calculate left x sprite location
  198.             bounds.top = (rowcount - 1) * sheight '                                         calculate top y sprite location
  199.             bounds.right = bounds.left + swidth - 1 '                                       calculate right x sprite location
  200.             bounds.bottom = bounds.top + sheight - 1 '                                      calculate bottom y sprite location
  201.             _PUTIMAGE , sheet, SL_sheet(handle, cell).image, (bounds.left, bounds.top)-_
  202.                                                              (bounds.right, bounds.bottom) 'get image from sheet
  203.  
  204.             ' create image mask and determine collision boundaries if necessary
  205.  
  206.             IF transparent THEN '                                                           sprite contain transparent color?
  207.                 SL_sheet(handle, cell).mask = _NEWIMAGE(swidth, sheight, 32) '              yes, create sprite mask image
  208.                 bounds.left = swidth - 1
  209.                 bounds.top = sheight - 1
  210.                 bounds.right = 0
  211.                 bounds.left = 0
  212.                 bounds.width = swidth
  213.                 bounds.height = sheight
  214.                 SL_GetBounds SL_sheet(handle, cell).image, SL_sheet(handle, cell).mask, clearcolor, bounds ' get collision bounds
  215.                 '                                                                           collide with boundaries only
  216.                 SL_sheet(handle, cell).rect.collision.left = bounds.left '                  * ----------------------------
  217.                 SL_sheet(handle, cell).rect.collision.top = bounds.top '                    *
  218.                 SL_sheet(handle, cell).rect.collision.right = bounds.right '                *
  219.                 SL_sheet(handle, cell).rect.collision.bottom = bounds.bottom '              * NOTE: These are OFFSETS
  220.                 SL_sheet(handle, cell).rect.collision.width = bounds.right - bounds.left '  *       NOT actual coordinates
  221.                 SL_sheet(handle, cell).rect.collision.height = bounds.bottom - bounds.top ' *
  222.                 SL_sheet(handle, cell).rect.collision.centerx = bounds.left + (bounds.right - bounds.left) / 2 '*
  223.                 SL_sheet(handle, cell).rect.collision.centery = bounds.top + (bounds.bottom - bounds.top) / 2 ' * --------
  224.             ELSE '                                                                          collide with entire sprite
  225.                 SL_sheet(handle, cell).rect.collision.left = 0 '                            * ----------------------------
  226.                 SL_sheet(handle, cell).rect.collision.top = 0 '                             *
  227.                 SL_sheet(handle, cell).rect.collision.right = swidth - 1 '                  *
  228.                 SL_sheet(handle, cell).rect.collision.bottom = sheight - 1 '                * NOTE: These are OFFSETS
  229.                 SL_sheet(handle, cell).rect.collision.width = swidth '                      *       NOT actual coordinates
  230.                 SL_sheet(handle, cell).rect.collision.height = sheight '                    *
  231.                 SL_sheet(handle, cell).rect.collision.centerx = bounds.left + swidth / 2 '  *
  232.                 SL_sheet(handle, cell).rect.collision.centery = bounds.top + sheight / 2 '  * ----------------------------
  233.             END IF
  234.  
  235.             ' create / insert precalculated rotation data
  236.  
  237.             IF rotate THEN '                                                                precalculate rotation data?
  238.                 IF preload THEN '                                                           yes, has it already been loaded?
  239.                     degree = 0 '                                                            reset degree counter
  240.                     DO '                                                                    cycle through 360 degrees
  241.                         SL_angle(anglekey, degree) = SL_temp(cell, degree) '                insert loaded information into array
  242.                         degree = degree + 1 '                                               increment degree counter
  243.                     LOOP UNTIL degree = 360 '                                               leave when all degrees processed
  244.                     SL_sheet(handle, cell).anglekey = anglekey '                            record the array index key
  245.                     anglekey = anglekey + 1 '                                               increment array index key
  246.                 ELSE '                                                                      no file was preloaded
  247.                     SL_sheet(handle, cell).anglekey = SL_RotationPrecalc(handle, cell, clearcolor) 'calculate rotation information
  248.                     degree = 0 '                                                            reset degree counter
  249.                     DO '                                                                    cycle through 360 degrees
  250.                         SL_temp(cell, degree) = SL_angle(anglekey, degree) '                save the rotation data to temp array
  251.                         degree = degree + 1 '                                               increment degree counter
  252.                     LOOP UNTIL degree = 360 '                                               leave when all degrees processed
  253.                 END IF
  254.             END IF
  255.         LOOP UNTIL rowcount = rows '                                                        leave when all rows checked
  256.     LOOP UNTIL colcount = columns '                                                         leave when all columns checked
  257.  
  258.     ' save precalculated rotation data to a file
  259.  
  260.     IF rotate AND (NOT preload) THEN '                                                      rotation data need saved?
  261.         OPEN rotfile FOR BINARY AS #filenum '                                               yes, open the file
  262.         PUT #filenum, , SL_temp() '                                                         write the rotation data
  263.         CLOSE #filenum '                                                                    close the file
  264.         REDIM SL_temp(0, 0) AS SL_ANGLE '                                                   clear temporary array
  265.     END IF
  266.     _FREEIMAGE sheet '                                                                      remove sprite sheet image from memory
  267.     SL_LOAD_SHEET = handle '                                                                return handle pointing to this sheet
  268.  
  269.  
  270. '----------------------------------------------------------------------------------------------------------------------------------
  271. FUNCTION SL_RotationPrecalc (sheet AS INTEGER, cell AS INTEGER, clearcolor AS _UNSIGNED LONG)
  272.     '------------------------------------------------------------------------------------------------------------------------------
  273.  
  274.     SHARED SL_sheet() AS SL_SHEET '     master sprite sheet array
  275.     SHARED SL_angle() AS SL_ANGLE '     master sprite angle array
  276.     SHARED SL_degree() AS SL_DEGREE '   precalculated SIN/COS table
  277.     DIM bounds AS SL_RECTANGLE '        rectangle boundries
  278.     DIM rotatedsprite AS LONG '         rotated sprite image
  279.     DIM anglekey AS INTEGER '           angle array index pointer
  280.     DIM swidth AS INTEGER '             width of sprite
  281.     DIM sheight AS INTEGER '            height of sprite
  282.     DIM xoffset AS INTEGER '            used to center sprite on rotated image
  283.     DIM yoffset AS INTEGER
  284.     DIM degree AS INTEGER '             degree counter
  285.     DIM polar AS INTEGER '              polar coordinate counter
  286.     DIM px(3) AS SINGLE '               _MAPTRIANGLE coordinates
  287.     DIM py(3) AS SINGLE
  288.     DIM sinr AS SINGLE, cosr AS SINGLE 'coordinate rotation calculations
  289.     DIM x2 AS SINGLE, y2 AS SINGLE '    rotated polar coordinate positions
  290.     DIM px0 AS SINGLE, px1 AS SINGLE '  polar coordinates
  291.     DIM px2 AS SINGLE, px3 AS SINGLE
  292.     DIM py0 AS SINGLE, py1 AS SINGLE
  293.     DIM py2 AS SINGLE, py3 AS SINGLE
  294.  
  295.     DO '                                                                                    cycle through angle array
  296.         anglekey = anglekey + 1 '                                                           increment index key pointer
  297.     LOOP UNTIL (SL_angle(anglekey, 0).inuse = SL_FALSE) OR (anglekey = UBOUND(SL_angle)) '  leave when available index found
  298.     IF SL_angle(anglekey, 0).inuse = SL_TRUE THEN '                                         is there no available index?
  299.         anglekey = anglekey + 1 '                                                           yes, increment index key pointer
  300.         REDIM _PRESERVE SL_angle(anglekey, 359) AS SL_ANGLE '                               increase size of angle array by one
  301.     END IF
  302.     SL_angle(anglekey, 0).inuse = SL_TRUE '                                                 mark this array index as in use
  303.     swidth = _WIDTH(SL_sheet(sheet, cell).image) '                                          get width of sprite image
  304.     sheight = _HEIGHT(SL_sheet(sheet, cell).image) '                                        get height of sprite image
  305.  
  306.     ' calculate _MAPTRIANGLE rotated coordinates
  307.  
  308.     DO
  309.         px(0) = -swidth / 2: py(0) = -sheight / 2: px(1) = px(0): py(1) = sheight / 2 '     specifiy _MAPTRIANGLE coordinates
  310.         px(2) = swidth / 2: py(2) = py(1): px(3) = px(2): py(3) = py(0)
  311.         sinr = SL_degree(degree).sinmap '                                                   get coordinate rotation angles
  312.         cosr = SL_degree(degree).cosmap '                                                   from precalculated COS/SIN table
  313.         bounds.left = 0: bounds.top = 0: bounds.right = 0: bounds.bottom = 0: polar = 0 '   set initial boundary markers
  314.         DO '                                                                                cycle through polar coordinates
  315.             x2 = (px(polar) * cosr + sinr * py(polar)) '                                    compute new polar coordinate location
  316.             y2 = (py(polar) * cosr - px(polar) * sinr) '                                    compute new polar coordinate location
  317.             px(polar) = x2 '                                                                save the new polar coordinate
  318.             py(polar) = y2 '                                                                save the new polar coordinate
  319.             IF px(polar) < bounds.left THEN bounds.left = px(polar) '                       get left x value
  320.             IF px(polar) > bounds.right THEN bounds.right = px(polar) '                     get right x value
  321.             IF py(polar) < bounds.top THEN bounds.top = py(polar) '                         get top y value
  322.             IF py(polar) > bounds.bottom THEN bounds.bottom = py(polar) '                   get bottom y value
  323.             polar = polar + 1 '                                                             increment counter
  324.         LOOP UNTIL polar = 4 '                                                              leave when all coordinates calculated
  325.         bounds.width = bounds.right - bounds.left + 1 '                                     calculate rotated width
  326.         bounds.height = bounds.bottom - bounds.top + 1 '                                    calculate rotated height
  327.         xoffset = bounds.width \ 2 '                                                        calculate x offset
  328.         yoffset = bounds.height \ 2 '                                                       calculate y offset
  329.         px0 = px(0) + xoffset: px1 = px(1) + xoffset '                                      add offsets to rotated sprite
  330.         px2 = px(2) + xoffset: px3 = px(3) + xoffset '                                      to center sprite onto the rotated
  331.         py0 = py(0) + yoffset: py1 = py(1) + yoffset '                                      image
  332.         py2 = py(2) + yoffset: py3 = py(3) + yoffset
  333.         rotatedsprite = _NEWIMAGE(bounds.width, bounds.height, 32) '                        create rotated sprite image holder
  334.  
  335.         ' map image onto rotated sprite
  336.  
  337.         _MAPTRIANGLE (0, 0)-(0, sheight - 1)-(swidth - 1, sheight - 1), SL_sheet(sheet, cell).image_
  338.                      TO(px0, py0)-(px1, py1)-(px2, py2), rotatedsprite
  339.         _MAPTRIANGLE (0, 0)-(swidth - 1, 0)-(swidth - 1, sheight - 1), SL_sheet(sheet, cell).image_
  340.                      TO(px0, py0)-(px3, py3)-(px2, py2), rotatedsprite
  341.  
  342.         ' get rotated collision boundaries
  343.  
  344.         bounds.left = bounds.width - 1: bounds.top = bounds.height - 1 '                    set intitial boundary markers
  345.         bounds.right = 0: bounds.bottom = 0
  346.         SL_GetBounds rotatedsprite, 0, clearcolor, bounds '                                 get collision boundaries
  347.         SL_angle(anglekey, degree).rect.collision.left = bounds.left '                      * ----------------------------
  348.         SL_angle(anglekey, degree).rect.collision.top = bounds.top '                        *
  349.         SL_angle(anglekey, degree).rect.collision.right = bounds.right '                    *
  350.         SL_angle(anglekey, degree).rect.collision.bottom = bounds.bottom '                  * NOTE: These are OFFSETS
  351.         SL_angle(anglekey, degree).rect.collision.width = bounds.right - bounds.left '      *       NOT actual coordinates
  352.         SL_angle(anglekey, degree).rect.collision.height = bounds.bottom - bounds.top '     *
  353.         SL_angle(anglekey, degree).rect.collision.centerx = bounds.left + (bounds.right - bounds.left) / 2 '*
  354.         SL_angle(anglekey, degree).rect.collision.centery = bounds.top + (bounds.bottom - bounds.top) / 2 ' * -------------
  355.         SL_angle(anglekey, degree).px0 = px0 '                                              save _MAPTRIANGLE coordinates
  356.         SL_angle(anglekey, degree).px1 = px1
  357.         SL_angle(anglekey, degree).px2 = px2
  358.         SL_angle(anglekey, degree).px3 = px3
  359.         SL_angle(anglekey, degree).py0 = py0
  360.         SL_angle(anglekey, degree).py1 = py1
  361.         SL_angle(anglekey, degree).py2 = py2
  362.         SL_angle(anglekey, degree).py3 = py3
  363.         degree = degree + 1 '                                                               increment degree counter
  364.     LOOP UNTIL degree = 360 '                                                               leave when all degrees processed
  365.     SL_RotationPrecalc = anglekey '                                                         return array index pointer
  366.  
  367.  
  368. '----------------------------------------------------------------------------------------------------------------------------------
  369. FUNCTION SL_GetTransparentColor (image AS LONG, clearcolor AS _UNSIGNED LONG)
  370.     '------------------------------------------------------------------------------------------------------------------------------
  371.  
  372.     ' usage  : exists = SL_GetTransparentColor(image, clearcolor)
  373.     '
  374.     ' returns: exists     =  0 (SL_FALSE) if no transparent color found, -1 (SL_TRUE) if a transparent color found
  375.     '          clearcolor =  unchanged if no transparent color found or the transparent color if one is found
  376.  
  377.     DIM pixel AS _UNSIGNED LONG '       color of pixel
  378.     DIM x AS INTEGER, y AS INTEGER '    column and row counters
  379.     DIM tempimage AS LONG '             temporary image used to identify transparent color
  380.  
  381.     SL_DestSource SL_PUSH '                                                                 save current _DEST and _SOURCE
  382.     _SOURCE image '                                                                         read from image
  383.     DO '                                                                                    cycle through image
  384.         pixel = POINT(x, y) '                                                               get the next pixel
  385.         IF _ALPHA32(pixel) = 0 THEN '                                                       is it transparent?
  386.             tempimage = _NEWIMAGE(1, 1, 32) '                                               yes, create a temp image
  387.             _CLEARCOLOR pixel, tempimage '                                                  apply the transparent value to it
  388.             clearcolor = _CLEARCOLOR(tempimage) '                                           get transparent value from temp image
  389.             _FREEIMAGE tempimage '                                                          remove temp image from memory
  390.             EXIT DO '                                                                       leave the loop, no reason to continue
  391.         END IF
  392.         x = x + 1 '                                                                         move to the next column
  393.         IF x > _WIDTH(image) THEN x = 0: y = y + 1 '                                        move to the next row if necessary
  394.     LOOP UNTIL y > _HEIGHT(image) '                                                         leave when entire sheet checked
  395.     IF _ALPHA32(pixel) = 0 THEN SL_GetTransparentColor = SL_TRUE '                          return -1 if transparent color found
  396.     SL_DestSource SL_POP '                                                                  restore previous _DEST and _SOURCE
  397.  
  398.  
  399. '----------------------------------------------------------------------------------------------------------------------------------
  400. SUB SL_GetBounds (image AS LONG, mask AS LONG, clearcolor AS _UNSIGNED LONG, bounds AS SL_RECTANGLE)
  401.     '------------------------------------------------------------------------------------------------------------------------------
  402.  
  403.     ' NOTE: bounds will be modified with new boundary coordinates
  404.  
  405.     DIM x AS INTEGER, y AS INTEGER '    column and row counters
  406.  
  407.     SL_DestSource SL_PUSH '                                                                 save current _DEST and _SOURCE
  408.     _SOURCE image '                                                                         read from image
  409.     IF mask THEN _DEST mask '                                                               write to mask if present
  410.     DO '                                                                                    cycle through columns
  411.         y = 0 '                                                                             reset row counter
  412.         DO '                                                                                cycle through rows
  413.             IF POINT(x, y) <> clearcolor THEN '                                             is this pixel transparent?
  414.                 IF x < bounds.left THEN bounds.left = x '                                   no, set left-most image pixel seen
  415.                 IF y < bounds.top THEN bounds.top = y '                                     set top-most image pixel seen
  416.                 IF x > bounds.right THEN bounds.right = x '                                 set right-most image pixel seen
  417.                 IF y > bounds.bottom THEN bounds.bottom = y '                               set bottom-most image pixel seen
  418.             ELSE '                                                                          yes, this is a transparent pixel
  419.                 IF mask THEN PSET (x, y), SL_WHITE '                                        draw as white on the image mask
  420.             END IF
  421.             y = y + 1 '                                                                     increment row counter
  422.         LOOP UNTIL y = bounds.height '                                                      leave when all rows scanned
  423.         x = x + 1 '                                                                         increment column counter
  424.     LOOP UNTIL x = bounds.width '                                                           leave when all columns scanned
  425.     SL_DestSource SL_POP '                                                                  restore previous _DEST and _SOURCE
  426.  
  427.  
  428. '----------------------------------------------------------------------------------------------------------------------------------
  429. SUB SL_DestSource (action AS INTEGER)
  430.     '------------------------------------------------------------------------------------------------------------------------------
  431.  
  432.     ' creates a FILO (First In Last Out) stack for storing source and destination values
  433.  
  434.     STATIC stack(0) AS LONG '           FILO stack (values retained between calls)
  435.  
  436.     SELECT CASE action '                                                                    push or pop stack?
  437.         CASE SL_PUSH '                                                                      pushing
  438.             REDIM _PRESERVE stack(UBOUND(stack) + 2) AS LONG '                              increase stack size
  439.             stack(UBOUND(stack) - 1) = _SOURCE '                                            save current source
  440.             stack(UBOUND(stack)) = _DEST '                                                  save current destination
  441.         CASE SL_POP '                                                                       popping in reverse order
  442.             _DEST stack(UBOUND(stack)) '                                                    restore destination
  443.             _SOURCE stack(UBOUND(stack) - 1) '                                              restore source
  444.             REDIM _PRESERVE stack(UBOUND(stack) - 2) AS LONG '                              decrease stack size
  445.     END SELECT
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455. ' subs and functions below ideas for now
  456.  
  457.  
  458. SUB SL_ComputeRectScreen (rect AS SL_RECT, centerx AS INTEGER, centery AS INTEGER)
  459.  
  460.     ' Calculates a RECT structures onscreen values using offset values
  461.     ' CENTERX and CENTERY always assumed to be the only values used
  462.     ' Any RECT structure supplied will be MODIFIED and sent back
  463.  
  464.     rect.screen.left = centerx - rect.offset.centerx
  465.     rect.screen.right = rect.screen.left + rect.offset.width
  466.     rect.screen.top = centery - rect.offset.centery
  467.     rect.screen.bottom = rect.screen.top + rect.offset.height
  468.     rect.screen.width = rect.screen.right - rect.screen.left
  469.     rect.screen.height = rect.screen.bottom - rect.screen.top
  470.     rect.screen.centerx = centerx
  471.     rect.screen.centery = centery
  472.  
  473.  
  474.  
  475. SUB SL_ComputeRectOffset (rect AS SL_RECTANGLE)
  476.  
  477.     ' Calculates a RECT structure's offset values
  478.     ' LEFT and TOP always assumed to be zero (0)
  479.     ' Any RECT structure supplied will be MODIFIED and sent back
  480.  
  481.     IF rect.left + rect.top THEN BEEP: END '                        left and top must be zero
  482.  
  483.     IF rect.width THEN '                                            if width is supplied
  484.         rect.right = rect.width '                                   then calculate right
  485.         rect.centerx = rect.width / 2 '                             and center x
  486.     ELSEIF rect.centerx THEN '                                      if center x is supplied
  487.         rect.right = rect.centerx * 2 '                             then calculate right
  488.         rect.width = rect.right '                                   and width
  489.     ELSE '                                                          if right and left supplied
  490.         rect.width = rect.right '                                   then calculate width
  491.         rect.centerx = rect.width / 2 '                             and center x
  492.     END IF
  493.  
  494.     IF rect.height THEN '                                           if height is supplied
  495.         rect.bottom = rect.height '                                 then calculate bottom
  496.         rect.centery = rect.height / 2 '                            and center y
  497.     ELSEIF rect.centery THEN '                                      if center y is suplied
  498.         rect.bottom = rect.centery * 2 '                            then calculate bottom
  499.         rect.height = rect.bottom '                                 and height
  500.     ELSE '                                                          if top and bottom supplied
  501.         rect.height = rect.bottom '                                 then calculate height
  502.         rect.centery = rect.height / 2 '                            and center y
  503.     END IF
  504.  
  505.  
Title: Re: Sprite Library Revisited
Post by: TerryRitchie on November 03, 2018, 02:07:04 pm
Just an update to state I'm still working on the library. Here is the current state of the code:

Code: QB64: [Select]
  1. '
  2. ' Sprite Library v2.0
  3. ' Terry Ritchie
  4. ' QuickBASIC64@gmail.com
  5. '
  6.  
  7. OPTION _EXPLICIT '                  NOTE: Remove before publishing library
  8.  
  9. '                                                                                            _____________________________________
  10. CONST SLFALSE = 0 '                 logical false (0)                                       | Constants are used throughout the   |
  11. CONST SLTRUE = NOT SLFALSE '        logical true (-1)                                       | library code. Changing, deleting,   |
  12. CONST SLNONE = 0 '                  used to null a setting                                  | or altering CONSTant values will    |
  13. CONST SLFORWARD = 1 '               used for animation cell direction                       | result in errors.                   |
  14. CONST SLBACKWARD = 2 '              used for animation cell direction                       |                                     |
  15. CONST SLBACKFORTH = 3 '             used for animation cell direction                       |                                     |
  16. CONST SLRECTANGLE = 1 '             used for collision detection method                     |                                     |
  17. CONST SLCIRCLE = 2 '                used for collision detection method                     |                                     |
  18. CONST SLPIXEL = 3 '                 used for collision detection method                     |                                     |
  19. CONST SLHORIZONTAL = 1 '            used for object flipping                                |                                     |
  20. CONST SLVERTICAL = 2 '              used for object flipping                                |                                     |
  21. CONST SLBOTH = 3 '                  used for object flipping                                |                                     |
  22. CONST SLNOTRANSPARENCY = 1 '        used to disable sheet/sprite transparency               |                                     |
  23. CONST SLLEFTCLICK = 1
  24. CONST SLRIGHTCLICK = 2
  25. CONST SLMIDDLECLICK = 3
  26. CONST SLHOVER = 4
  27. CONST SLWHEELUP = 5
  28. CONST SLWHEELDOWN = 6
  29. CONST SLZOOM = -32767
  30. CONST SLFLIP = -32766
  31. CONST SLVISIBLE = -32765
  32. CONST SLLAYER = -32764
  33. CONST SLSCORE = -32763
  34. CONST SLAUTOANIMATE = -32762
  35. CONST SLFROMCELL = -32761
  36. CONST SLTOCELL = -32760
  37. CONST SLANIMATEDIR = -32759
  38. CONST SLFRAMERATE = -32758
  39. CONST SLAUTOMOTION = -32757
  40. CONST SLMOTIONANGLE = -32756
  41. CONST SLXDIR = -32755
  42. CONST SLYDIR = -32754
  43. CONST SLAUTOROTATE = -32753
  44. CONST SLROTATEANGLE = -32752
  45. CONST SLROTATESPEED = -32751
  46. CONST SLDETECTION = -32750
  47. CONST SLLEFT = -32749
  48. CONST SLTOP = -32748
  49. CONST SLRIGHT = -32747
  50. CONST SLBOTTOM = -32746
  51. CONST SLWIDTH = -32745
  52. CONST SLHEIGHT = -32744
  53. CONST SLCENTERX = -32743
  54. CONST SLCENTERY = -32742
  55. CONST SLCOLLISION = -32741
  56. CONST SLCOLLIDEWITH = -32740
  57. CONST SLCOLLIDEX = -32739
  58. CONST SLCOLLIDEY = -32738
  59. CONST SLMOUSE = -32737
  60. CONST SLMOUSEX = -32736
  61. CONST SLMOUSEY = -32735
  62. CONST SLSPRITEMOUSEX = -32734
  63. CONST SLSPRITEMOUSEY = -32733
  64. '                                                                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  65.  
  66. TYPE SLRECT '---------------------- RECTANGULAR STRUCTURE ---------------------------------  _____________________________________
  67.     Width AS INTEGER '              width  of rectangular object                            | This structure should ALWAYS be     |
  68.     Height AS INTEGER '             height of rectangular object                            | used to describe any rectangular    |
  69.     Left AS INTEGER '               left x coordinate   (or offset) of rectangular object   | object used within the library.     |
  70.     Top AS INTEGER '                top y coordinate    (or offset) of rectangular object   | Items such as layers, main screen,  |
  71.     Right AS INTEGER '              right x coordinate  (or offset) of rectangular object   | sprites, and collision areas are    |
  72.     Bottom AS INTEGER '             bottom y coordinate (or offset) of rectangular object   | examples of rectangular structures. |
  73. END TYPE '---------------------------------------------------------------------------------  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74.  
  75. TYPE SLANIMATION '----------------- OBJECT ANIMATION SETTINGS -----------------------------  _____________________________________
  76.     Auto AS _BYTE '                 auto animation (SLTRUE / SLFALSE)                       | Notes                               |
  77.     Cell AS INTEGER '               current animation cell                                  |                                     |
  78.     FromCell AS INTEGER '           animation start cell number                             |                                     |
  79.     ToCell AS INTEGER '             animation end cell number                               |                                     |
  80.     FrameRate AS INTEGER '          animation independent frame rate                        |                                     |
  81.     Direction AS _BYTE '            animation direction (1 to 3)                            |                                     |
  82. END TYPE '---------------------------------------------------------------------------------  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  83.  
  84. TYPE SLMOTION '-------------------- OBJECT MOTION SETTINGS --------------------------------  _____________________________________
  85.     Auto AS _BYTE '                 auto motion (SLTRUE / SLFALSE)                          | Notes                               |
  86.     Degree AS INTEGER '             angle direction of motion (-359 to 359)                 |                                     |
  87.     Xdir AS INTEGER '               x motion vector                                         |                                     |
  88.     Ydir AS INTEGER '               y motion vector                                         |                                     |
  89. END TYPE '---------------------------------------------------------------------------------  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  90.  
  91. TYPE SLROTATION '------------------ OBJECT ROTATION SETTINGS ------------------------------  _____________________________________
  92.     Auto AS _BYTE '                 auto rotation (SLTRUE / SLFALSE)                        | Notes                               |
  93.     Rotates AS _BYTE '              rotation enabled/disabled for sprite (SLTRUE / SLFALSE) |                                     |
  94.     Degree AS INTEGER '             angle of rotation (0 to 359)                            |                                     |
  95.     Rate AS INTEGER '               rotation spin rate (speed)                              |                                     |
  96.     key AS INTEGER '                index key to map and rotation arrays                    |                                     |
  97. END TYPE '---------------------------------------------------------------------------------  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  98.  
  99. TYPE SLCOLLISIONS '---------------- OBJECT COLLISION SETTINGS -----------------------------  _____________________________________
  100.     Detect AS _BYTE '               collision detection method (0 to 3)                     | Notes                               |
  101.     Event AS _BYTE '                collision occurance (SLTRUE / SLFALSE)                  |                                     |
  102.     With AS INTEGER '               the object collision happend with                       |                                     |
  103.     Xloc AS INTEGER '               x location of collision (pixel)                         |                                     |
  104.     Yloc AS INTEGER '               y location of collision (pixel)                         |                                     |
  105.     Mask AS LONG '                  sprite mask image for pixel detection                   |                                     |
  106. END TYPE '---------------------------------------------------------------------------------  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  107.  
  108. TYPE SLMOUSES '-------------------- MOUSE INTERACTION SETTINGS ----------------------------  _____________________________________
  109.     Event AS _BYTE '                most recent mouse event                                 | Notes                               |
  110.     Xloc AS INTEGER '               x coordinate location of mouse on object                |                                     |
  111.     Yloc AS INTEGER '               y coordinate location of mouse on object                |                                     |
  112.     SXloc AS INTEGER '              x coordinate of mouse on screen in relation to object   |                                     |
  113.     SYloc AS INTEGER '              y coordinate of mouse on screen in relation to object   |                                     |
  114. END TYPE '---------------------------------------------------------------------------------  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  115.  
  116. TYPE SLSHEET '--------------------- SPRITE SHEET SETTINGS ---------------------------------  _____________________________________
  117.     InUse AS _BYTE '                array index in use (SLTRUE / SLFASLE)                   | Notes                               |
  118.     Image AS LONG '                 sprite sheet image                                      |                                     |
  119.     ClearColor AS _UNSIGNED LONG '  transparent color of sheet                              |                                     |
  120.     CellWidth AS INTEGER '          width of each sprite cell                               |                                     |
  121.     CellHeight AS INTEGER '         height of each sprite cell                              |                                     |
  122.     Columns AS INTEGER '            number of cell columns                                  |                                     |
  123.     Rows AS INTEGER '               number of cell rows                                     |                                     |
  124.     TotalCells AS INTEGER '         total number of cells on sheet                          |                                     |
  125. END TYPE '---------------------------------------------------------------------------------  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  126.  
  127. TYPE SLSPRITE '-------------------- SPRITE SETTINGS ---------------------------------------
  128.     '                                                                                        _____________________________________
  129.     OrigSheet AS INTEGER '          original sprite sheet location                          | These values are to be considered   |
  130.     OrigCell AS INTEGER '           original sprite sheet cell location                     | STATIC in nature. Once they are set |
  131.     OrigImage AS LONG '             original sprite image                                   | they should never be changed.       |
  132.     OrigMask AS LONG '              original sprite mask image                              |                                     |
  133.     OrigWidth AS INTEGER '          original sprite width                                   |                                     |
  134.     OrigHeight AS INTEGER '         original sprite height                                  |                                     |
  135.     '                                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  136.     OrigColl AS SLRECT '            original NON_ROTATED sprite collision area coordinates
  137.     '  _________________________________________________________________________________     _____________________________________
  138.     ' | .Width  - original collision area width                                         |   | These values are to be considered   |
  139.     ' | .Height - original collision area height                                        |   | STATIC in nature. Once they are set |
  140.     ' | .Left   - original collision area left   x offset (from screen left x)          |   | they should never be changed. These |
  141.     ' | .Top    - original collision area top    y offset (from screen top  y)          |   | values are used to calculate the    |
  142.     ' | .Right  - original collision area right  x offset (from screen left x)          |   | on-screen sprite collision area     |
  143.     ' | .Bottom - original collision area bottom y offset (from screen top  y)          |   | coordinates.                        |
  144.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  145.     ScrnImage AS LONG '             on-screen sprite software image
  146.     ScrnHardware AS LONG '          on-screen sprite hardware image
  147.     ScrnMask AS LONG '              on-screen sprite mask image
  148.  
  149.     Scrn AS SLRECT '                on-screen sprite location coordinates
  150.     '  _________________________________________________________________________________     _____________________________________
  151.     ' | .Width  - on-screen sprite width                                                |   | These values are to be considered   |
  152.     ' | .Height - on-screen sprite height                                               |   | DYNAMIC in nature. These values     |
  153.     ' | .Left   - on-screen sprite left   x location                                    |   | will be calculated every time a     |
  154.     ' | .Top    - on-screen sprite top    y location                                    |   | sprite is to be drawn on-screen     |
  155.     ' | .Right  - on-screen sprite right  x location                                    |   | taking into account rotation,       |
  156.     ' | .Bottom - on-screen sprite bottom y location                                    |   | animation, motion, etc..            |
  157.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  158.  
  159.     ScrnColl AS SLRECT '            on-screen sprite collision area coordinates
  160.     '  _________________________________________________________________________________     _____________________________________
  161.     ' | .Width  - on-screen sprite collision area width                                 |   | These values are to be considered   |
  162.     ' | .Height - on-screen sprite collision area height                                |   | DYNAMIC in nature. These values     |
  163.     ' | .Left   - on-screen sprite collision area left   x location                     |   | will be calculated by adding the    |
  164.     ' | .Top    - on-screen sprite collision area top    y location                     |   | original collision offsets to the   |
  165.     ' | .Right  - on-screen sprite collision area right  x location                     |   | on-screen sprite location           |
  166.     ' | .Bottom - on-screen sprite collision area bottom y location                     |   | coordinates.                        |
  167.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  168.  
  169.     Anim AS SLANIMATION '           sprite animation settings
  170.     '  _________________________________________________________________________________     _____________________________________
  171.     ' | .Auto      - enable or disable sprite auto-animation (SLTRUE / SLFALSE)         |   | Notes                               |
  172.     ' | .Cell      - the current cell in the animation sequence                         |   |                                     |
  173.     ' | .FromCell  - the beginning cell number of the animation sequence                |   |                                     |
  174.     ' | .ToCell    - the ending cell number of the animation sequence                   |   |                                     |
  175.     ' | .FrameRate - the independent animation frame rate                               |   |                                     |
  176.     ' | .Direction - the animation cell direction (1 forward, 2 backward, 3 back/forth) |   |                                     |
  177.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  178.  
  179.     Move AS SLMOTION '              sprite motion settings
  180.     '  _________________________________________________________________________________     _____________________________________
  181.     ' | .Auto   - enable or disable sprite auto-motion (SLTRUE / SLFALSE)               |   | Notes                               |
  182.     ' | .Degree - direction of motion movement in degrees (0 to 359)                    |   |                                     |
  183.     ' | .Xdir   - x direction vector of sprite motion                                   |   |                                     |
  184.     ' | .Ydir   - y direction vector of sprite motion                                   |   |                                     |
  185.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  186.  
  187.     Spin AS SLROTATION '            sprite rotation settings
  188.     '  _________________________________________________________________________________     _____________________________________
  189.     ' | .Auto    - enable or disable sprite auto-rotation (SLTRUE / SLFALSE)            |   | Notes                               |
  190.     ' | .Rotates - sprite has been configured for rotation (SLTRUE / SLFALSE)           |   |                                     |
  191.     ' | .Degree  - sprite degree of rotation (0 to 359)                                 |   |                                     |
  192.     ' | .Rate    - spin rate (speed) of rotation (-359 to 359)                          |   |                                     |
  193.     ' | .Key     - index pointer to map and rotation arrays                             |   |                                     |
  194.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  195.  
  196.     Mouse AS SLMOUSES '             sprite/mouse interaction settings
  197.     '  _________________________________________________________________________________     _____________________________________
  198.     ' | .Event - the most recent mouse/sprite interaction event that occurred           |   | Notes                               |
  199.     ' | .Xloc  - the x coordinate location of the mouse pointer on the sprite           |   |                                     |
  200.     ' | .Yloc  - the y coordinate location of the mouse pointer on the sprite           |   |                                     |
  201.     ' | .SXloc - the x coordinate of the mouse pointer on the screen                    |   |                                     |
  202.     ' | .SYloc - the y coordinate of the mouse pointer on the screen                    |   |                                     |
  203.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  204.  
  205.     Coll AS SLCOLLISIONS '          sprite collision settings
  206.     '  _________________________________________________________________________________     _____________________________________
  207.     ' | .Detect - collision detection method (0 none, 1 rectangle, 2 circle, 3 pixel)   |   | These collision settings have       |
  208.     ' | .Event  - set when a collision event occurs (SLTRUE / SLFALSE)                  |   | nothing to do with collision area   |
  209.     ' | .With   - the object handle the sprite has collided with                        |   | structures used for collision       |
  210.     ' | .Xloc   - x coordinate location of where the collision occurred (pixel)         |   | detection itself. Theese values are |
  211.     ' | .Yloc   - y coordinate location of where the collision occurred (pixel)         |   | created in direct result of a       |
  212.     ' | .Mask   - sprite mask image for use in pixel detection                          |   | collision happening between objects.|
  213.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  214.  
  215.     InUse AS _BYTE '                array index in use (SLTRUE / SLFALSE)
  216.     Flipped AS _BYTE '              sprite flipping method (0 None, 1 Horiz, 2 Vert, 3 Both)
  217.     Zoom AS INTEGER '               sprite zoom level (100 = 100%)
  218.     Visible AS _BYTE '              sprite is currently visible (SLTRUE / SLFALSE)
  219.     Layer AS INTEGER '              the layer a sprite belongs to
  220.     Score AS SINGLE '               the score value associated with a sprite
  221.     ClearColor AS _UNSIGNED LONG '  transparent color of sprite
  222.     Centerx AS INTEGER
  223.     Centery AS INTEGER
  224. END TYPE '---------------------------------------------------------------------------------
  225.  
  226. TYPE SLLAYERS '-------------------- LAYER DATABASE ----------------------------------------  _____________________________________
  227.     image AS LONG '                 the layer surface software image                        | Notes                               |
  228.     Hardware AS LONG '              the layer surface hardware image                        |                                     |
  229.     visible AS _BYTE '              layer visibility (SLTRUE / SLFALSE)                     |                                     |
  230. END TYPE '---------------------------------------------------------------------------------  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  231.  
  232. TYPE SLMAP '----------------------- _MAPTRIANGLE COORDINATES ------------------------------  _____________________________________
  233.     width AS INTEGER '              width of  _MAPTRIANGLE rotated sprite                   | Notes                               |
  234.     height AS INTEGER '             height of _MAPTRIANGLE rotated sprite                   |                                     |
  235.     px0 AS INTEGER '                upper left  x _MAPTRIANGLE coordinate                   |                                     |
  236.     py0 AS INTEGER '                upper left  y _MAPTRIANGLE coordinate                   |                                     |
  237.     px1 AS INTEGER '                lower left  x _MAPTRIANGLE coordinate                   |                                     |
  238.     py1 AS INTEGER '                lower left  y _MAPTRIANGLE coordinate                   |                                     |
  239.     px2 AS INTEGER '                lower right x _MAPTRIANGLE coordinate                   |                                     |
  240.     py2 AS INTEGER '                lower right y _MAPTRIANGLE coordinate                   |                                     |
  241.     px3 AS INTEGER '                upper right x _MAPTRIANGLE coordinate                   |                                     |
  242.     py3 AS INTEGER '                upper right y _MAPTRIANGLE coordinate                   |                                     |
  243. END TYPE '---------------------------------------------------------------------------------  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  244.  
  245. TYPE SLROT '----------------------- ROTATED COLLISION AREA COORDINATES --------------------
  246.     InUse AS _BYTE '                array index in use (SLTRUE / SLFALSE)
  247.     Coll AS SLRECT '                ROTATED collision area coordinates
  248.     '  _________________________________________________________________________________     _____________________________________
  249.     ' | .Width  - rotated collision area width                                          |   | These values are to be considered   |
  250.     ' | .Height - rotated collision area height                                         |   | STATIC in nature. Once they are set |
  251.     ' | .Left   - rotated collision area left   x offset (from screen left x)           |   | they should never be changed. These |
  252.     ' | .Top    - rotated collision area top    y offset (from screen top  y)           |   | values are used to calculate the    |
  253.     ' | .Right  - rotated collision area right  x offset (from screen left x)           |   | on-screen ROTATED sprite collision  |
  254.     ' | .Bottom - rotated collision area bottom y offset (from screen top  y)           |   | area coordinates.                   |
  255.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  256. END TYPE '---------------------------------------------------------------------------------
  257.  
  258. TYPE SLDEGREE '-------------------- PRECALCULATED SIN/COS TABLE ---------------------------  _____________________________________
  259.     SIN AS SINGLE '                 SIN of rotation                                         | The file degrees.deg will be        |
  260.     COS AS SINGLE '                 COS of rotation                                         | created to hold this table.         |
  261. END TYPE '---------------------------------------------------------------------------------  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  262.  
  263. TYPE SLGLOBAL '-------------------- GLOBAL SETTINGS ---------------------------------------  _____________________________________
  264.     Scrn AS SLRECT '                main screen coordinate values                           | Any single variables that need to   |
  265.     Start AS _BYTE '                SLStart initialization trigger (SLTRUE / SLFALSE)       | be shared globally throughout the   |
  266.     FrameRate AS INTEGER '          global library frame rate                               | library should be placed in this    |
  267.     Layers AS INTEGER '             number of layers requested by programmer                | data type.                          |
  268.     Subroutine AS STRING * 15 '     current subroutine for error processing                 |                                     |
  269. END TYPE '---------------------------------------------------------------------------------  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  270.  
  271.  
  272. REDIM SLSheet(0) AS SLSHEET '       master sprite sheet array
  273. REDIM SLSprite(0) AS SLSPRITE '     master sprite array
  274. REDIM SLMap(0, 359) AS SLMAP '      master sprite sheet _MAPTRIANGLE coordinate array
  275. REDIM SLRot(0, 359) AS SLROT '      master sprite rotated collision area array
  276. REDIM SLLayers(0) AS SLLAYERS '      master layer array
  277. DIM SLDegree(359) AS SLDEGREE '     precalculated SIN/COS table
  278. DIM SLGlobal AS SLGLOBAL '          global variables
  279.  
  280.  
  281. DIM dkong AS INTEGER
  282. DIM rect AS SLRECT
  283. DIM mario AS INTEGER
  284.  
  285. SL_Start
  286. SL_Window 640, 480, 5
  287. dkong = SL_LoadSheet("dkong.png", 64, 64, _RGB32(255, 0, 255))
  288. mario = SL_MakeSprite(0, dkong, 6, SLTRUE)
  289. 'SL_SpriteSet mario, SLZOOM, 500
  290. SL_PutSprite mario, 200, 200
  291. _PUTIMAGE (SLSprite(mario).Scrn.Left, SLSprite(mario).Scrn.Top)-(SLSprite(mario).Scrn.Right, SLSprite(mario).Scrn.Bottom), SLSprite(mario).OrigImage
  292. CIRCLE (100, 100), 50, _RGB32(255, 255, 255)
  293. LINE (SLSprite(mario).ScrnColl.Left, SLSprite(mario).ScrnColl.Top)-(SLSprite(mario).ScrnColl.Right, SLSprite(mario).ScrnColl.Bottom), _RGB32(255, 255, 255), B
  294. SL_FreeSprite mario
  295.  
  296.  
  297. ' Verified SLRot() is being created correctly
  298. '--------------------------------------------
  299. 'SCREEN _NEWIMAGE(640, 480, 32)
  300. 'dkong = SL_LoadSheet("dkong.png", 64, 64, _RGB32(255, 0, 255))
  301. 'mario = SL_MakeSprite(0, dkong, 1, SLTRUE)
  302. 'FOR i = 0 TO 359
  303. '    PRINT SLRot(0, i).Coll.Width; SLRot(0, i).Coll.Height
  304. '    PRINT SLRot(0, i).Coll.Left; SLRot(0, i).Coll.Top; SLRot(0, i).Coll.Right; SLRot(0, i).Coll.Bottom
  305. 'NEXT i
  306.  
  307.  
  308. ' Verified SL_MakeSprite is working properly
  309. '-------------------------------------------
  310. 'SCREEN _NEWIMAGE(640, 480, 32)
  311. 'dkong = SL_LoadSheet("dkong.png", 64, 64, _RGB32(255, 0, 255))
  312. 'mario = SL_MakeSprite(0, dkong, 1, SLTRUE)
  313. '_PUTIMAGE (0, 0), SLSprite(dkong).OrigImage
  314. 'LINE (SLSprite(mario).OrigColl.Left, SLSprite(mario).OrigColl.Top)-(SLSprite(mario).OrigColl.Right, SLSprite(mario).OrigColl.Bottom), _RGB32(255, 255, 255), B
  315.  
  316.  
  317. ' Verified SL_GetCellCoordinates is working properly
  318. '---------------------------------------------------
  319. 'SCREEN _NEWIMAGE(640, 480, 32)
  320. 'dkong = SL_LoadSheet("dkong.png", 64, 64, _RGB32(255, 0, 255))
  321. 'SL_GetCellCoordinates dkong, 1, rect
  322. 'PRINT rect.left, rect.top
  323. 'PRINT rect.right, rect.bottom
  324. 'PRINT rect.width, rect.height
  325.  
  326.  
  327. ' Verified sheet is loading and clearcolor being applied
  328. '-------------------------------------------------------
  329. 'SCREEN _NEWIMAGE(640, 480, 32)
  330. 'dkong = SL_LoadSheet("dkong.png", 64, 64, _RGB32(255, 0, 255))
  331. '_PUTIMAGE (100, 100), SLSheet(dkong).Image
  332.  
  333.  
  334. ' Verified SLMAP() is being created and reloaded properly
  335. '--------------------------------------------------------
  336. 'SCREEN _NEWIMAGE(640, 480, 32)
  337. 'dkong = SL_LoadSheet("dkong.png", 64, 64, _RGB32(255, 0, 255))
  338. 'FOR i = 0 TO 359
  339. '    PRINT i; SLMap(dkong, i).width; SLMap(dkong, i).height
  340. '    DO: LOOP UNTIL _KEYHIT
  341. 'NEXT i
  342.  
  343.  
  344.  
  345. '----------------------------------------------------------------------------------------------------------------------------------
  346. SUB SL_Start () '                                                                                                          SL_Start
  347.     '  ___________________________________________________________________________________________________________________________
  348.     ' | Initializes the sprite library                                                                                            |
  349.     ' |---------------------------------------------------------------------------------------------------------------------------|
  350.     ' | Usage : SL_Start                                                                                                          |
  351.     ' |                                                                                                                           |
  352.     ' | Output: A file named 'degrees.deg' will be created after executing this subroutine.                                       |
  353.     ' | Note  : This MUST be the first command issued before using the sprite library. Any setup procedures that need to be       |
  354.     ' |         performed in support of functions and subroutines should be placed in this subroutine.                            |
  355.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  356.     SHARED SLDegree() AS SLDEGREE ' precalculated SIN/COS table
  357.     SHARED SLGlobal AS SLGLOBAL '   global variables
  358.     DIM Degree AS INTEGER '         degree counter
  359.     DIM FileNumber AS INTEGER '     next available file handle
  360.     '  ________________________________________________________________________________
  361.     ' | Load or create precalculated degree rotation array                             |
  362.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  363.     FileNumber = FREEFILE '                                                                 get the next free file handle
  364.     IF _FILEEXISTS("degrees.deg") THEN '                                                    does the degree file exist?
  365.         '  ____________________________________________________________________________
  366.         ' | Load the array since the file already exists                               |
  367.         '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  368.         OPEN "degrees.deg" FOR BINARY AS #FileNumber '                                      yes, open the file for reading
  369.         GET #FileNumber, , SLDegree() '                                                     get the rotational degree data
  370.         CLOSE #FileNumber '                                                                 close the file
  371.     ELSE '                                                                                  no, the file does not exist
  372.         '  ____________________________________________________________________________
  373.         ' | Create the precalculated degree rotation array                             |
  374.         '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  375.         DO '                                                                                cycle through 360 degrees
  376.             SLDegree(Degree).SIN = SIN(Degree * .017453292) '                               calculate the SIN of angle
  377.             SLDegree(Degree).COS = -COS(Degree * .017453292) '                              calculate the COSINE of angle
  378.             Degree = Degree + 1 '                                                           increment degree counter
  379.         LOOP UNTIL Degree = 360 '                                                           leave when all degrees cycled
  380.         '  ____________________________________________________________________________
  381.         ' | The file must be created since it did not exist                            |
  382.         '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  383.         OPEN "degrees.deg" FOR BINARY AS #FileNumber '                                      open the file for writing
  384.         PUT #FileNumber, , SLDegree() '                                                     write the rotational degree data
  385.         CLOSE #FileNumber '                                                                 close the file
  386.     END IF
  387.     SLGlobal.Start = SLTRUE '                                                               record that library was initialized
  388.  
  389.  
  390. '----------------------------------------------------------------------------------------------------------------------------------
  391. SUB SL_Window (ScreenWidth AS INTEGER, ScreenHeight AS INTEGER, Layers AS INTEGER) '                                      SL_Window
  392.     '  ___________________________________________________________________________________________________________________________
  393.     ' | Creates the main working screen and number of requested layers.                                                           |
  394.     ' |---------------------------------------------------------------------------------------------------------------------------|
  395.     ' | Usage : SL_Window 640, 480, 4                                                                                             |
  396.     ' |                                                                                                                           |
  397.     ' | Input : ScreenWidth  = the width of the main working screen and requested layers                                          |
  398.     ' |         ScreenHeight = the height of the main working screen and requested layers                                         |
  399.     ' |         Layers       = the requested number fo layers to create (zero (0) for no layers)                                  |
  400.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  401.     SHARED SLLayers() AS SLLAYERS ' master layer array
  402.     SHARED SLGlobal AS SLGLOBAL '   global variables
  403.     DIM layer AS INTEGER
  404.  
  405.     SLGlobal.Scrn.Width = ScreenWidth '                                                     set screen/layer rectangular values
  406.     SLGlobal.Scrn.Height = ScreenHeight
  407.     SLGlobal.Scrn.Left = 0
  408.     SLGlobal.Scrn.Top = 0
  409.     SLGlobal.Scrn.Right = ScreenWidth - 1
  410.     SLGlobal.Scrn.Bottom = ScreenHeight - 1
  411.     '  _________________________________________________________________________________
  412.     ' | Create the number of requested layers                                           |
  413.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  414.     IF Layers > SLNONE THEN '                                                               have layers been requested?
  415.         SLGlobal.Layers = Layers '                                                          yes, record number of layers requested
  416.         REDIM SLLayers(Layers) AS SLLAYERS '                                                increase size of layer array
  417.         DO '                                                                                cycle through requested layers
  418.             layer = layer + 1 '                                                             increment layer counter
  419.             SLLayers(layer).image = _NEWIMAGE(ScreenWidth, ScreenHeight, 32) '              create software layer image
  420.             SLLayers(Layers).visible = SLTRUE '                                             layers are visible by default
  421.         LOOP UNTIL layer = UBOUND(SLLayers) '                                               leave when all layers created
  422.     END IF
  423.     '  _________________________________________________________________________________
  424.     ' | Create the main working screen (_DEST 0)                                        |
  425.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  426.     SCREEN _NEWIMAGE(ScreenWidth, ScreenHeight, 32) '                                       initialize main screen
  427.  
  428.  
  429. '----------------------------------------------------------------------------------------------------------------------------------
  430. SUB SL_PutSprite (Handle AS INTEGER, Centerx AS INTEGER, Centery AS INTEGER) '                                         SL_PutSprite
  431.     '  ___________________________________________________________________________________________________________________________
  432.     ' | Calculates the actual screen and collision area coordinates for sprite screen placement.                                  |
  433.     ' |---------------------------------------------------------------------------------------------------------------------------|
  434.     ' | Usage : SL_PutSprite Mysprite, 100, 100                                                                                   |
  435.     ' |                                                                                                                           |
  436.     ' | Input : Handle  = the handle pointer name of the sprite to have screen placement calculated                               |
  437.     ' |         Centerx = the x coordinate location to horizontally center the sprite                                             |
  438.     ' |         Centery = the y coordinate location to vertically center the sprite                                               |
  439.     ' | Note  : The sprite will be centered on the supplied Centerx and Centery coordinate pair.                                  |
  440.     ' |         The sprite zoom level will be taken into account to adjust the screen and collision coordinates accordingly.      |
  441.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  442.     SHARED SLSprite() AS SLSPRITE ' master sprite array
  443.     SHARED SLMap() AS SLMAP '       master sprite sheet _MAPTRIANGLE coordinate array
  444.     SHARED SLRot() AS SLROT '       master sprite rotated collision area array
  445.     DIM Zoom AS INTEGER '           zoom level of sprite
  446.     DIM Sheet AS INTEGER '          the sprite sheet the sprite belongs to
  447.     DIM Degree AS INTEGER '         the sprite's dgree of rotation
  448.     DIM RotKey AS INTEGER '         the sprite's key index pointer to the SLRot array
  449.  
  450.     Zoom = SLSprite(Handle).Zoom \ 100 '                                                    get and calculate the zoom level
  451.     Sheet = SLSprite(Handle).OrigSheet '                                                    get the sheet that owns this sprite
  452.     Degree = SLSprite(Handle).Spin.Degree '                                                 get the sprite's degree of rotation
  453.     RotKey = SLSprite(Handle).Spin.key '                                                    get the sprite's SLRot index pointer
  454.     SLSprite(Handle).Centerx = Centerx '                                                    record current x coordinate of sprite
  455.     SLSprite(Handle).Centery = Centery '                                                    record current y coordinate of sprite
  456.     '  _________________________________________________________________________________
  457.     ' |                                                                                 |
  458.     ' | Calculate the sprite's on-screen rectangular structure coordinate values        |
  459.     ' |                                                                                 |
  460.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  461.     IF SLSprite(Handle).Spin.Rotates THEN '                                                 has sprite been configured to rotate?
  462.         '  _____________________________________________________________________________
  463.         ' | Use SLMap width and height values since the sprite uses ROTATION            |
  464.         '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  465.         SLSprite(Handle).Scrn.Width = SLMap(Sheet, Degree).width '                          yes, get the rotated width of sprite
  466.         SLSprite(Handle).Scrn.Height = SLMap(Sheet, Degree).height '                        get the rotated height of sprite
  467.     ELSE '                                                                                  no, this sprite does not rotate
  468.         '  _____________________________________________________________________________
  469.         ' | Use original width and height values since the sprite uses NO ROTATION      |
  470.         '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  471.         SLSprite(Handle).Scrn.Width = SLSprite(Handle).OrigWidth '                          get the original width of sprite
  472.         SLSprite(Handle).Scrn.Height = SLSprite(Handle).OrigHeight '                        get the original height of sprite
  473.     END IF
  474.     '  _________________________________________________________________________________
  475.     ' | Complete the calculations for the on-screen sprite rectangular structure        |
  476.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  477.     SLSprite(Handle).Scrn.Left = Centerx - (SLSprite(Handle).Scrn.Width \ 2) * Zoom '       calculate sprite's left x coordinate
  478.     SLSprite(Handle).Scrn.Top = Centery - (SLSprite(Handle).Scrn.Height \ 2) * Zoom '       calculate sprite's top y coordinate
  479.     SLSprite(Handle).Scrn.Right = SLSprite(Handle).Scrn.Left +_
  480.                                   (SLSprite(Handle).Scrn.Width - 1) * Zoom '                calculate sprite's right x coordinate
  481.     SLSprite(Handle).Scrn.Bottom = SLSprite(Handle).Scrn.Top +_
  482.                                   (SLSprite(Handle).Scrn.Height - 1) * Zoom '               calculate sprite's bottom y coordinate
  483.     '  _________________________________________________________________________________
  484.     ' |                                                                                 |
  485.     ' | Calculate the sprite's on-screen collision area rectangular coordinate values   |
  486.     ' |                                                                                 |
  487.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  488.     IF SLSprite(Handle).ClearColor = SLNOTRANSPARENCY THEN '                                does sprite have transparent color?
  489.         '  _____________________________________________________________________________
  490.         ' | Since sprite is not transparent the collision area will be the entire sprite|
  491.         '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  492.         SLSprite(Handle).ScrnColl = SLSprite(Handle).Scrn '                                 no, use entire sprite as collision
  493.     ELSE '                                                                                  yes, this sprite uses transparency
  494.         IF SLSprite(Handle).Spin.Rotates THEN '                                             has sprite been configured to rotate?
  495.             '  _________________________________________________________________________
  496.             ' | Since the sprite is transparent and it rotates the collision area       |
  497.             ' | coordinates must come from the SLRot array.                             |
  498.             ' |-------------------------------------------------------------------------|
  499.             ' |                                Sprite Top Y                             |
  500.             ' |          +--------------------------------------------------------+     |
  501.             ' |          |TRANSPARENT          SLRot        ^   ^        SLRot    |     |
  502.             ' |          |   SPRITE          Collision      |   |      Collision  |     |
  503.             ' |          |                   Area Top Y --->|   |<--- Area Bottom |     |
  504.             ' |          |                    (offset)      |   |     Y (offset)  |     |
  505.             ' |          |                                  |   |                 |     |
  506.             ' |          |  SLRot ~~~~~~~~~~\               V   |                 |     |
  507.             ' |  Sprite  |  Collision Area   |    +-------------+--------+        |     |
  508.             ' |  Left X  |  Lext X (offset)  V    |COLLISION    |        |        |     |
  509.             ' |          |<---------------------->|   AREA      |        |        |     |
  510.             ' |          |                        |             |        |        |     |
  511.             ' |          |<-----------------------+-------------+------->|        |     |
  512.             ' |          |   Collision Area  ^    |             |        |        |     |
  513.             ' |          |  Right X (offset) |    |             V        |        |     |
  514.             ' |          |  SLRot __________/     +----------------------+        |     |
  515.             ' |          |                                                        |     |
  516.             ' |          +--------------------------------------------------------+     |
  517.             ' | The collsion area for a transparent sprite comes from taking the left x |
  518.             ' | and top y offset values from SLRot and adding them to the left x and    |
  519.             ' | top y sprite coordinate values as shown above. The collision area can   |
  520.             ' | wildy vary in size depending on the actual non-transparent image        |
  521.             ' | contained within the sprite. Note as well that the collision does not   |
  522.             ' | necessarily need to be centered within the sprite, again depending on   |
  523.             ' | the actual non-transparent image contained within the sprite.           |
  524.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  525.             SLSprite(Handle).ScrnColl.Width = SLRot(RotKey, Degree).Coll.Width '            get the sprite's rotated width
  526.             SLSprite(Handle).ScrnColl.Height = SLRot(RotKey, Degree).Coll.Height '          get the sprite's rotated height
  527.             SLSprite(Handle).ScrnColl.Left = SLSprite(Handle).Scrn.Left +_
  528.                                              SLRot(RotKey, Degree).Coll.Left * Zoom '       calculate sprite's left x coordinate
  529.             SLSprite(Handle).ScrnColl.Top = SLSprite(Handle).Scrn.Top +_
  530.                                             SLRot(RotKey, Degree).Coll.Top * Zoom '         calculate sprite's top y coordinate
  531.             SLSprite(Handle).ScrnColl.Right = SLSprite(Handle).Scrn.Left +_
  532.                                               SLRot(RotKey, Degree).Coll.Right * Zoom '     calculate sprite's right x coordinate
  533.             SLSprite(Handle).ScrnColl.Bottom = SLSprite(Handle).Scrn.Top +_
  534.                                                SLRot(RotKey, Degree).Coll.Bottom * Zoom '   calculate sprite's bottom y coordinate
  535.         ELSE '                                                                              no, this sprite does not rotate
  536.             '  _________________________________________________________________________
  537.             ' | The sprite does not rotate so use the original collision area instead   |
  538.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  539.             SLSprite(Handle).ScrnColl.Width = SLSprite(Handle).OrigColl.Width '             get sprite's original collision width
  540.             SLSprite(Handle).ScrnColl.Height = SLSprite(Handle).OrigColl.Height '           get sprite's original collision height
  541.             SLSprite(Handle).ScrnColl.Left = SLSprite(Handle).Scrn.Left +_
  542.                                              SLSprite(Handle).OrigColl.Left * Zoom '        calculate sprite's left x coordinate
  543.             SLSprite(Handle).ScrnColl.Top = SLSprite(Handle).Scrn.Top +_
  544.                                             SLSprite(Handle).OrigColl.Top * Zoom '          calculate sprite's top y coordinate
  545.             SLSprite(Handle).ScrnColl.Right = SLSprite(Handle).Scrn.Left +_
  546.                                               SLSprite(Handle).OrigColl.Right * Zoom '      calculate sprite's right x coordinate
  547.             SLSprite(Handle).ScrnColl.Bottom = SLSprite(Handle).Scrn.Top +_
  548.                                                SLSprite(Handle).OrigColl.Bottom * Zoom '    calculate sprite's bottom y coordinate
  549.         END IF
  550.     END IF
  551.  
  552.  
  553. '----------------------------------------------------------------------------------------------------------------------------------
  554. FUNCTION SL_MakeSprite (Layer AS INTEGER, Sheet AS INTEGER, Cell AS INTEGER, Rotates AS INTEGER) '                    SL_MakeSprite
  555.     '  ___________________________________________________________________________________________________________________________
  556.     ' | Create a new sprite from a previously loaded sprite sheet.                                                                |
  557.     ' |---------------------------------------------------------------------------------------------------------------------------|
  558.     ' | Usage : Sprite = SL_MakeSprite(LayerNumber, MySheet, CellNumber, SLTRUE)                                                  |
  559.     ' |                                                                                                                           |
  560.     ' | Input : Layer   = the layer this sprite resides on (use zero (0) for a pure hardware sprite)                              |
  561.     ' |         Sheet   = the previously loaded sheet where the sprite is located                                                 |
  562.     ' |         Cell    = the cell number on the previously loaded sheet where the sprite resides                                 |
  563.     ' |         Rotates = sprite rotation characteristics (SLTRUE = the sprite will rotate, SLFALSE = the sprite will not rotate) |
  564.     ' | Output: An array index that acts as a handle pointer to the newly created sprite                                          |
  565.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  566.     SHARED SLSprite() AS SLSPRITE ' master sprite array
  567.     SHARED SLSheet() AS SLSHEET '   master sprite sheet array
  568.     SHARED SLMap() AS SLMAP '       master sprite sheet _MAPTRIANGLE coordinate array
  569.     SHARED SLRot() AS SLROT '       master sprite rotated collision area array
  570.     DIM Handle AS INTEGER '         sprite array index pointer
  571.     DIM Rect AS SLRECT '            general use rectangular structure
  572.     DIM odest AS LONG '             current _DEST
  573.     DIM osource AS LONG '           current _SOURCE
  574.     DIM x AS INTEGER '              x axis (width) counter
  575.     DIM y AS INTEGER '              y axis (height) counter
  576.     DIM RotKey AS INTEGER '         rotated collsion array index key used by sprite
  577.     DIM rotatedsprite AS LONG '     each sprite rotated 360 degrees
  578.     DIM degree AS INTEGER '         degree counter
  579.     '  _________________________________________________________________________________
  580.     ' | Create a new or use existing unused index in sprite array to hold sprite.       |
  581.     ' |---------------------------------------------------------------------------------|
  582.     ' | When a sprite is removed (SL_RemoveSprite) the array index is marked as unused  |
  583.     ' | and can be later reused by another sprite being created. If no unused array     |
  584.     ' | positions exist then a new array index will be created to hold the new sprite's |
  585.     ' | information.                                                                    |
  586.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  587.     Handle = -1 '                                                                           reset handle array index pointer
  588.     DO '                                                                                    cycle through sprite array
  589.         Handle = Handle + 1 '                                                               increment handle array index pointer
  590.     LOOP UNTIL SLSprite(Handle).InUse = SLFALSE OR Handle = UBOUND(SLSprite) '              leave when suitable array index found
  591.     IF SLSprite(Handle).InUse THEN '                                                        is this array index currently in use?
  592.         Handle = Handle + 1 '                                                               yes, increase the array index size
  593.         REDIM _PRESERVE SLSprite(Handle) AS SLSPRITE '                                      create new index in sprite array
  594.     END IF
  595.     '  _________________________________________________________________________________
  596.     ' | Record basic information about the sprite                                       |
  597.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  598.     SLSprite(Handle).InUse = SLTRUE '                                                       mark this array index as in use
  599.     SLSprite(Handle).OrigSheet = Sheet '                                                    get the sheet sprite belongs to
  600.     SLSprite(Handle).OrigCell = Cell '                                                      get the cell sprite resides in on sheet
  601.     SLSprite(Handle).OrigWidth = SLSheet(Sheet).CellWidth '                                 get original width of sprite
  602.     SLSprite(Handle).OrigHeight = SLSheet(Sheet).CellHeight '                               get original height of sprite
  603.     SLSprite(Handle).OrigImage = _NEWIMAGE(SLSprite(Handle).OrigWidth,_
  604.                                            SLSprite(Handle).OrigHeight, 32) '               create original image surface
  605.     SLSprite(Handle).OrigMask = _COPYIMAGE(SLSprite(Handle).OrigImage, 32) '                create original image mask surface
  606.     SL_GetCellCoordinates Sheet, Cell, Rect '                                               get original image sheet coordinates
  607.     _PUTIMAGE , SLSheet(Sheet).Image, SLSprite(Handle).OrigImage,_
  608.                 (Rect.Left, Rect.Top)-(Rect.Right, Rect.Bottom) '                           get original copy of image from sheet
  609.     SLSprite(Handle).Flipped = SLNONE '                                                     reset sprite flipping behavior
  610.     SLSprite(Handle).Zoom = 100 '                                                           reset zoom to normal (100%)
  611.     SLSprite(Handle).Visible = SLTRUE '                                                     all new sprites visible by default
  612.     SLSprite(Handle).Layer = Layer '                                                        the layer that sprite belongs to
  613.     SLSprite(Handle).Score = 0 '                                                            reset sprite's score
  614.     SLSprite(Handle).ClearColor = SLSheet(Sheet).ClearColor '                               get sprite's transparenct color
  615.     '  _________________________________________________________________________________
  616.     ' | Create original collision area information and original sprite mask image       |
  617.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  618.     odest = _DEST '                                                                         save current destination surface
  619.     osource = _SOURCE '                                                                     save current source surface
  620.     _SOURCE SLSprite(Handle).OrigImage '                                                    set original image as source surface
  621.     _DEST SLSprite(Handle).OrigMask '                                                       set original image mask as destination
  622.     Rect.Width = SLSprite(Handle).OrigWidth '                                               use original width in rect structure
  623.     Rect.Height = SLSprite(Handle).OrigHeight '                                             use original height in rect structure
  624.     Rect.Left = Rect.Width '                                                                start at opposite side of left
  625.     Rect.Top = Rect.Height '                                                                start at opposite side of top
  626.     Rect.Right = 0 '                                                                        start at opposite side of right
  627.     Rect.Bottom = 0 '                                                                       start at opposite side of bottom
  628.     '  _________________________________________________________________________________
  629.     ' | Scan every pixel of the image to obtain collision area characteristics          |
  630.     ' |---------------------------------------------------------------------------------|
  631.     ' | If a pixel location within the image is not a transparent color then test to    |
  632.     ' | see if that pixel is one of the outer boundaries of the collision area. The     |
  633.     ' | collison area will encompass any pixel that is not a transparent one. If the    |
  634.     ' | pixel is transparent however draw a pixel on the sprite mask image in the same  |
  635.     ' | spot as white. This will create a negative mask, white being where a tranparent |
  636.     ' | pixel is and black being where the image is located.                            |
  637.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  638.     DO '                                                                                    cycle through the width of the image
  639.         y = 0 '                                                                             reset height counter
  640.         DO '                                                                                cycle through the height of the image
  641.             IF POINT(x, y) <> SLSprite(Handle).ClearColor THEN '                            is this pixel transparent?
  642.                 '  _____________________________________________________________________
  643.                 ' | pixel is part of image so look for outer boundary                   |
  644.                 '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  645.                 IF x < Rect.Left THEN Rect.Left = x '                                       no, if left-most so far record it
  646.                 IF y < Rect.Top THEN Rect.Top = y '                                         if top-most so far record it
  647.                 IF x > Rect.Right THEN Rect.Right = x '                                     if right-most so far record it
  648.                 IF y > Rect.Bottom THEN Rect.Bottom = y '                                   if bottom-most so far record it
  649.             ELSE '                                                                          yes, the pixel is transparent
  650.                 '  _____________________________________________________________________
  651.                 ' | pixel is part of the transparent area so create mask instead        |
  652.                 '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  653.                 PSET (x, y), _RGB32(255, 255, 255) '                                        draw white pixel on mask in same spot
  654.             END IF
  655.             y = y + 1 '                                                                     increment height counter
  656.         LOOP UNTIL y = Rect.Height '                                                        leave when height of image reached
  657.         x = x + 1 '                                                                         increment width counter
  658.     LOOP UNTIL x = Rect.Width '                                                             leave when width of image reached
  659.     _DEST odest '                                                                           restore current destination surface
  660.     _SOURCE osource '                                                                       restore current source surface
  661.     SLSprite(Handle).OrigColl = Rect '                                                      record original collision area values
  662.     '  _________________________________________________________________________________
  663.     ' | Reset on-screen sprite and collision area coordinates                           |
  664.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  665.     Rect.Width = 0 '                                                                        create empty rectangular structure
  666.     Rect.Height = 0
  667.     Rect.Left = 0
  668.     Rect.Top = 0
  669.     Rect.Right = 0
  670.     Rect.Bottom = 0
  671.     SLSprite(Handle).Scrn = Rect '                                                          reset on-screen location coordinates
  672.     SLSprite(Handle).ScrnColl = Rect '                                                      reset on-screen collision area coords
  673.     '  _________________________________________________________________________________
  674.     ' | Reset sprite animation settings                                                 |
  675.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  676.     SLSprite(Handle).Anim.Auto = SLFALSE
  677.     SLSprite(Handle).Anim.Cell = 0
  678.     SLSprite(Handle).Anim.FromCell = 0
  679.     SLSprite(Handle).Anim.ToCell = 0
  680.     SLSprite(Handle).Anim.FrameRate = 0
  681.     SLSprite(Handle).Anim.Direction = 0
  682.     '  _________________________________________________________________________________
  683.     ' | Reset sprite motion settings                                                    |
  684.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  685.     SLSprite(Handle).Move.Auto = SLFALSE
  686.     SLSprite(Handle).Move.Degree = 0
  687.     SLSprite(Handle).Move.Xdir = 0
  688.     SLSprite(Handle).Move.Ydir = 0
  689.     '  _________________________________________________________________________________
  690.     ' | Reset sprite rotation settings                                                  |
  691.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  692.     IF Rotates THEN '                                                                       will this sprite be able to rotate?
  693.         '  _____________________________________________________________________________
  694.         ' | Create a new or use existing unused index in collision rotation array       |
  695.         ' |-----------------------------------------------------------------------------|
  696.         ' | When a sprite is set as being allowed to rotate its image is rotated 360    |
  697.         ' | degrees to obtain collision area coordinates for every angle. This          |
  698.         ' | information is stored in the collision rotation array at either a new index |
  699.         ' | created to hold the information or an unused one freed up by a sprite being |
  700.         ' | removed. A key is used as an index pointer by the sprite to find its        |
  701.         ' | information in the collision rotation array.                                |
  702.         '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  703.         RotKey = -1 '                                                                       yes, reset handle array index pointer
  704.         DO '                                                                                cycle through rotated collision array
  705.             RotKey = RotKey + 1 '                                                           increment handle array index pointer
  706.         LOOP UNTIL SLRot(RotKey, 0).InUse = SLFALSE OR RotKey = UBOUND(SLrot, 1) '          leave when suitable array index found
  707.         IF SLRot(RotKey, 0).InUse THEN '                                                    is this array index currently in use?
  708.             RotKey = RotKey + 1 '                                                           yes, increase the array index size
  709.             REDIM _PRESERVE SLRot(RotKey, 359) AS SLROT '                                   create new index in rotated coll array
  710.         END IF
  711.         SLSprite(Handle).Spin.key = RotKey '                                                mark this array index as in use
  712.         DO '                                                                                cycle through 360 degrees
  713.             IF SLSprite(Handle).ClearColor = SLNOTRANSPARENCY THEN '                        does this sprite contain transparency?
  714.                 '  _____________________________________________________________________
  715.                 ' | The sprite not transparent so use the full rotated width and height |
  716.                 '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  717.                 SLRot(RotKey, degree).Coll.Width = SLMap(Sheet, degree).width '             no, record rotated collision area width
  718.                 SLRot(RotKey, degree).Coll.Height = SLMap(Sheet, degree).height '           record rotated collision area height
  719.                 SLRot(RotKey, degree).Coll.Left = 0 '                                       record rotated collision left offset
  720.                 SLRot(RotKey, degree).Coll.Top = 0 '                                        record rotated collision top offset
  721.                 SLRot(RotKey, degree).Coll.Right = SLMap(Sheet, degree).width - 1 '         record rotated collision right offset
  722.                 SLRot(RotKey, degree).Coll.Bottom = SLMap(Sheet, degree).height - 1 '       record rotated collision bottom offset
  723.             ELSE '                                                                          yes, this sprite contains transparency
  724.                 '  _____________________________________________________________________     _____________________________________
  725.                 ' | Map original sprite onto rotated image using SLMap data made before |   | These rotated sprite images could   |
  726.                 ' |---------------------------------------------------------------------|   | be saved into an array in a later   |
  727.                 ' | The precalculated values        px(0),py(0)           px(3),py(3)   |   | version of the sprite library       |
  728.                 ' | created when the sheet was           +---------------------+        |   | eleviating the need to once again   |
  729.                 ' | loaded and placed in SLMap       ,>  |~\_     _MAPTRIANGLE |  >,    |   | rotate them in SLPutSprite later.   |
  730.                 ' | are now used by _MAPTRIANGLE    /    |   ~\_       #2      |    \   |   | This would take a considerable      |
  731.                 ' | to rotate the image onto       |     |      ~\_            |     |  |   | amount of memory to store however   |
  732.                 ' | the rotated sprite image      |      |         ~\_         |      | |   | depending on the number of sprites  |
  733.                 ' | surface. SLMap also contains   |     |            ~\_      |     |  |   | that require rotating in a given    |
  734.                 ' | the rotated width and height    \    | _MAPTRIANGLE  ~\_   |    /   |   | game/program. This will need to be  |
  735.                 ' | needed to create the rotated     `<  |      #1          ~\_|  <'    |   | investigated at a later date.       |
  736.                 ' | sprite image surface.                +---------------------+        |   |                                     |
  737.                 ' |                                 px(1),py(1)           px(2),py(2)   |   |                       tr 10/30/18   |
  738.                 '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  739.                 rotatedsprite = _NEWIMAGE(SLMap(Sheet, degree).width,_
  740.                                           SLMap(Sheet, degree).height, 32) '                create rotated sprite image surface
  741.  
  742.                 _MAPTRIANGLE (0, 0)-(0, SLSprite(Handle).OrigHeight - 1)-_
  743.                     (SLSprite(Handle).OrigWidth - 1, SLSprite(Handle).OrigHeight - 1),_
  744.                     SLSprite(Handle).OrigImage TO _
  745.                     (SLMap(Sheet, degree).px0, SLMap(Sheet, degree).py0)-_
  746.                     (SLMap(Sheet, degree).px1, SLMap(Sheet, degree).py1)-_
  747.                     (SLMap(Sheet, degree).px2, SLMap(Sheet, degree).py2), rotatedsprite '   map triangle #1 to rotated sprite image
  748.                 _MAPTRIANGLE (0, 0)-(SLSprite(Handle).OrigWidth - 1, 0)-_
  749.                     (SLSprite(Handle).OrigWidth - 1, SLSprite(Handle).OrigHeight - 1),_
  750.                     SLSprite(Handle).OrigImage TO _
  751.                     (SLMap(Sheet, degree).px0, SLMap(Sheet, degree).py0)-_
  752.                     (SLMap(Sheet, degree).px3, SLMap(Sheet, degree).py3)-_
  753.                     (SLMap(Sheet, degree).px2, SLMap(Sheet, degree).py2), rotatedsprite '   map triangle #2 to rotated sprite image
  754.                 '  _____________________________________________________________________
  755.                 ' | The sprite is transparent so the rotated image will need scanned    |
  756.                 ' |---------------------------------------------------------------------|
  757.                 ' | If a pixel location within the image is not a transparent color     |
  758.                 ' | then test to see if that pixel is one of the outer boundaries of    |
  759.                 ' | the collision area. The collision area will encompass any pixel     |
  760.                 ' | that is not a transparent one.                                      |
  761.                 '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  762.                 Rect.Width = SLMap(Sheet, degree).width '                                   use rotated width in rect structure
  763.                 Rect.Height = SLMap(Sheet, degree).height '                                 use rotated height in rect structure
  764.                 Rect.Left = Rect.Width '                                                    start at opposite side of left
  765.                 Rect.Top = Rect.Height '                                                    start at opposite side of top
  766.                 Rect.Right = 0 '                                                            start at opposite side of right
  767.                 Rect.Bottom = 0 '                                                           start at opposite side of bottom
  768.                 osource = _SOURCE '                                                         save current source surface
  769.                 _SOURCE rotatedsprite '                                                     set rotated image as source surface
  770.                 x = 0 '                                                                     reset width counter
  771.                 DO '                                                                        cycle through the width of the image
  772.                     y = 0 '                                                                 reset height counter
  773.                     DO '                                                                    cycle through the height of the image
  774.                         IF POINT(x, y) <> SLSprite(Handle).ClearColor THEN '                is this pixel transparent?
  775.                             '  _________________________________________________________
  776.                             ' | pixel is part of image so look for outer boundary       |
  777.                             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  778.                             IF x < Rect.Left THEN Rect.Left = x '                           no, if left-most so far record it
  779.                             IF y < Rect.Top THEN Rect.Top = y '                             if top-most so far record it
  780.                             IF x > Rect.Right THEN Rect.Right = x '                         if right-most so far record it
  781.                             IF y > Rect.Bottom THEN Rect.Bottom = y '                       if bottom-most so far record it
  782.                         END IF
  783.                         y = y + 1 '                                                         increment height counter
  784.                     LOOP UNTIL y = Rect.Height '                                            leave when height of image reached
  785.                     x = x + 1 '                                                             increment width counter
  786.                 LOOP UNTIL x = Rect.Width '                                                 leave when width of image reached
  787.                 _SOURCE osource '                                                           restore current source surface
  788.                 Rect.Width = Rect.Right - Rect.Left '                                       record width of rotated collision area
  789.                 Rect.Height = Rect.Bottom - Rect.Top '                                      record height of rotated collision area
  790.                 SLRot(RotKey, degree).Coll = Rect '                                         record rotated collision area values
  791.                 _FREEIMAGE rotatedsprite '                                                  remove rotated image from memory
  792.             END IF
  793.             degree = degree + 1 '                                                           increment degree counter
  794.         LOOP UNTIL degree = 360 '                                                           leave when 360 degrees processed
  795.     ELSE '                                                                                  no, this sprite will not rotate
  796.         SLSprite(Handle).Spin.key = 0 '                                                     reset rotation file index pointer
  797.     END IF
  798.     SLSprite(Handle).Spin.Auto = SLFALSE '                                                  disable auto rotation
  799.     SLSprite(Handle).Spin.Rotates = Rotates '                                               enable/disable sprite rotation status
  800.     SLSprite(Handle).Spin.Degree = 0 '                                                      reset rotation degree angle
  801.     SLSprite(Handle).Spin.Rate = 0 '                                                        reset rotation spin rate (speed)
  802.     '  _________________________________________________________________________________
  803.     ' | Reset sprite/mouse interaction settings                                         |
  804.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  805.     SLSprite(Handle).Mouse.Event = SLNONE '                                                 reset most recent mouse interaction
  806.     SLSprite(Handle).Mouse.Xloc = 0 '                                                       reset mouse x coordinate location
  807.     SLSprite(Handle).Mouse.Yloc = 0 '                                                       reset mouse y coordinate location
  808.     SLSprite(Handle).Mouse.SXloc = 0 '                                                      reset mouse on screen x coordinate
  809.     SLSprite(Handle).Mouse.SYloc = 0 '                                                      reset mouse on screen y coordinate
  810.     '  _________________________________________________________________________________
  811.     ' | Reset sprite collision settings                                                 |
  812.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  813.     SLSprite(Handle).Coll.Detect = SLNONE '                                                 reset sprite collision detection method
  814.     SLSprite(Handle).Coll.Event = 0 '                                                       reset collision event trigger
  815.     SLSprite(Handle).Coll.With = 0 '                                                        reset collision with object identifier
  816.     SLSprite(Handle).Coll.Xloc = 0 '                                                        reset collision x coordinate location
  817.     SLSprite(Handle).Coll.Yloc = 0 '                                                        reset collision y coordinate location
  818.     SLSprite(Handle).Coll.Mask = 0 '                                                        reset mask image surface
  819.     SL_MakeSprite = Handle '                                                                return the sprite handle index pointer
  820.  
  821.  
  822. '----------------------------------------------------------------------------------------------------------------------------------
  823. FUNCTION SL_CopySprite (Handle AS INTEGER) '                                                                          SL_CopySprite
  824.     '  ___________________________________________________________________________________________________________________________
  825.     ' | Creates an identical copy of a sprite and assigns a new handle pointer value.                                             |
  826.     ' |---------------------------------------------------------------------------------------------------------------------------|
  827.     ' | Usage : NewSprite = SL_CopySPrite(MySPrite)                                                                               |
  828.     ' |                                                                                                                           |
  829.     ' | Input : Handle = the handle pointer of the sprite being copied                                                            |
  830.     ' | Output: a handle pointer value of the new sprite created                                                                  |
  831.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  832.     SHARED SLSprite() AS SLSPRITE ' master sprite array
  833.     DIM CopyHandle AS INTEGER
  834.  
  835.     CopyHandle = -1 '                                                                       reset handle array index pointer
  836.     DO '                                                                                    cycle through sprite array
  837.         CopyHandle = CopyHandle + 1 '                                                       increment handle array index pointer
  838.     LOOP UNTIL SLSprite(CopyHandle).InUse = SLFALSE OR CopyHandle = UBOUND(SLSprite) '      leave when suitable array index found
  839.     IF SLSprite(CopyHandle).InUse THEN '                                                    is this array index currently in use?
  840.         CopyHandle = CopyHandle + 1 '                                                       yes, increase the array index size
  841.         REDIM _PRESERVE SLSprite(CopyHandle) AS SLSPRITE '                                  create new index in sprite array
  842.     END IF
  843.     SLSprite(CopyHandle) = SLSprite(Handle) '                                               copy the entire contents of sprite
  844.     SLSprite(CopyHandle).OrigImage = _COPYIMAGE(SLSprite(Handle).OrigImage, 32) '           copy the sprite's original image
  845.     IF SLSprite(Handle).OrigMask THEN '                                                     does the sprite being copied have mask?
  846.         SLSprite(CopyHandle).OrigMask = _COPYIMAGE(SLSprite(Handle).OrigMask, 32) '         yes, copy sprite's original image mask
  847.     END IF
  848.     SL_CopySprite = CopyHandle '                                                            return the new sprite's handle pointer
  849.  
  850.  
  851. '----------------------------------------------------------------------------------------------------------------------------------
  852. SUB SL_FreeSprite (Handle AS INTEGER)
  853.     '  ___________________________________________________________________________________________________________________________
  854.     ' | Removes a sprite from the sprite array and all associated images from memory.                                             |
  855.     ' |---------------------------------------------------------------------------------------------------------------------------|
  856.     ' | Usage : SL_FreeSprite(MySprite)                                                                                           |
  857.     ' |                                                                                                                           |
  858.     ' | Input : Handle = the handle pointer of the sprite being removed                                                           |
  859.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  860.     SHARED SLSprite() AS SLSPRITE ' master sprite array
  861.  
  862.     IF SL_ValidSprite(Handle) = SLFALSE THEN SL_Error 1, "SL_FreeSprite" '                  report error if invalid sprite
  863.     IF SLSprite(Handle).OrigMask THEN _FREEIMAGE SLSprite(Handle).OrigMask '                free mask image if present
  864.     IF SLSprite(Handle).ScrnHardware THEN _FREEIMAGE SLSprite(Handle).ScrnHardware '        free screen hardware image if present
  865.     IF SLSprite(Handle).ScrnImage THEN _FREEIMAGE SLSprite(Handle).ScrnImage '              free screen software image if present
  866.     _FREEIMAGE SLSprite(Handle).OrigImage '                                                 free original sprite image
  867.     IF (Handle = UBOUND(slsprite)) AND (Handle <> 0) THEN '                                 is this the last sprite in array?
  868.         REDIM _PRESERVE SLSprite(Handle - 1) AS SLSPRITE '                                  yes, remove last element in array
  869.     ELSE '                                                                                  no, this sprite resides somewhere else
  870.         SLSprite(Handle).InUse = SLFALSE '                                                  mark the index in array as reusable
  871.     END IF
  872.  
  873.  
  874. '----------------------------------------------------------------------------------------------------------------------------------
  875. FUNCTION SL_LoadSheet (Filename AS STRING, CellWidth AS INTEGER, CellHeight AS INTEGER, ClearColor AS _UNSIGNED LONG) 'SL_LoadSheet
  876.     '  ___________________________________________________________________________________________________________________________
  877.     ' | Load a sprite sheet image and create a _MAPTRIANGLE rotation array to be used for sprite rotation.                        |
  878.     ' |---------------------------------------------------------------------------------------------------------------------------|
  879.     ' | Usage : SheetName = ("spritesheet.png", 32, 48, _RGB32(255, 0, 255))                                                      |
  880.     ' |                                                                                                                           |
  881.     ' | Input : filename   = the name of the image file to load as a sprite sheet                                                 |
  882.     ' |         CellWidth  = the width of each sprite on the sheet                                                                |
  883.     ' |         CellHeight = the height of each sprite on the sheet                                                               |
  884.     ' |         ClearColor = the color to use as the transparent layer of the sprite sheet                                        |
  885.     ' | Output: An array index that acts as a handle pointer to the newly loaded sprite sheet                                     |
  886.     ' |                                                                                                                           |
  887.     ' | A .map file will be created with the same name as the image filename provided, "filename.map", that holds precalculated   |
  888.     ' | coordinates that _MAPTRIANGLE will use for sprite rotation.                                                               |
  889.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  890.     SHARED SLSheet() AS SLSHEET '   master sprite sheet array
  891.     SHARED SLMap() AS SLMAP '       master sprite sheet _MAPTRIANGLE coordinate array
  892.     DIM Handle AS INTEGER '         index pointer to new sheet
  893.     DIM MapFileName AS STRING '     name of .map file where _MAPTRIANGLE coordinates are stored
  894.     DIM Degree AS INTEGER '         0 through 359 degree counter
  895.     DIM FileNumber AS INTEGER '     next free file handle
  896.     DIM Polar AS INTEGER '          counter used for calculating _MAPTRIANGLE x,y coordinate pairs
  897.     DIM px(3) AS SINGLE '           _MAPTRIANGLE x coordinates
  898.     DIM py(3) AS SINGLE '           _MAPTRIANGLE y coordinates
  899.     DIM Xoffset AS INTEGER '        _MAPTRIANGLE x coordinate offset to center image
  900.     DIM Yoffset AS INTEGER '        _MAPTRIANGLE y coordinate offset to center image
  901.     DIM x AS SINGLE '               rotated x location of a image corner
  902.     DIM y AS SINGLE '               rotated y location of a image corner
  903.     DIM SINr AS SINGLE '            SIN of image corner rotation
  904.     DIM COSr AS SINGLE '            COSINE of image corner rotation
  905.     DIM Left AS INTEGER '           new left x coordinate of rotated cell image
  906.     DIM Top AS INTEGER '            new top y coordinate of rotated cell image
  907.     DIM Right AS INTEGER '          new right x coordinate of rotated cell image
  908.     DIM Bottom AS INTEGER '         new bottom y coordinate of rotated cell image
  909.     '  _________________________________________________________________________________
  910.     ' | Create a new or use existing unused index in sprite sheet array to hold sheet.  |
  911.     ' |---------------------------------------------------------------------------------|
  912.     ' | When a sprite sheet is removed (SL_RemoveSheet) the array index is marked as    |
  913.     ' | unused and can be later reused by another sprite sheet being loaded. If no      |
  914.     ' | unused array positions exist then a new array index will be created to hold the |
  915.     ' | new sprite sheet's information.                                                 |
  916.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  917.     Handle = -1 '                                                                           reset handle array index pointer
  918.     DO '                                                                                    cycle through sprite sheet array
  919.         Handle = Handle + 1 '                                                               increment handle array index pointer
  920.     LOOP UNTIL SLSheet(Handle).InUse = SLFALSE OR Handle = UBOUND(SLSheet) '                leave when suitable array index found
  921.     IF SLSheet(Handle).InUse THEN '                                                         is this array index currently in use?
  922.         Handle = Handle + 1 '                                                               yes, increase the array index size
  923.         REDIM _PRESERVE SLSheet(Handle) AS SLSHEET '                                        create new index in sprite sheet array
  924.         REDIM _PRESERVE SLMap(Handle, 359) AS SLMAP '                                       create new index in coordinate array
  925.     END IF
  926.     '  _________________________________________________________________________________
  927.     ' | Load sprite sheet and record basic information about the sheet                  |
  928.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  929.     SLSheet(Handle).InUse = SLTRUE '                                                        mark this array index as being used
  930.     SLSheet(Handle).Image = _LOADIMAGE(Filename, 32) '                                      load the sprite sheet image
  931.     SLSheet(Handle).CellWidth = CellWidth '                                                 record each cell's width
  932.     SLSheet(Handle).CellHeight = CellHeight '                                               record each cell's height
  933.     IF ClearColor = SLNOTRANSPARENCY THEN '                                                 has sheet transparency been disabled?
  934.         SLSheet(Handle).ClearColor = SLNOTRANSPARENCY '                                     yes, record this setting
  935.     ELSE '                                                                                  no, set the transparent color of sheet
  936.         _CLEARCOLOR ClearColor, SLSheet(Handle).Image '                                     set the sheet's transparent color
  937.         SLSheet(Handle).ClearColor = _CLEARCOLOR(SLSheet(Handle).Image) '                   record the sheet's transparent color
  938.     END IF
  939.     SLSheet(Handle).Columns = _WIDTH(SLSheet(Handle).Image) \ CellWidth '                   record number of cell columns on sheet
  940.     SLSheet(Handle).Rows = _HEIGHT(SLSheet(Handle).Image) \ CellHeight '                    record number of cell rows on sheet
  941.     SLSheet(Handle).TotalCells = SLSheet(Handle).Columns * SLSheet(Handle).Rows '           record total number of cells on sheet
  942.     '  _________________________________________________________________________________
  943.     ' | Create or retrieve the _MAPTRIANGLE rotational map file for sprite rotation     |
  944.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  945.     MapFileName = LEFT$(Filename, INSTR(Filename, ".")) + "map" '                           create the map file's file name
  946.     FileNumber = FREEFILE '                                                                 get the next free file handle
  947.     IF _FILEEXISTS(MapFileName) THEN '                                                      does the map file already exist?
  948.         '  _____________________________________________________________________________
  949.         ' | The file has been previously created. Open it and load its contents.        |
  950.         ' |-----------------------------------------------------------------------------|
  951.         ' | This is done for speed. Calculations will only need to be performed once    |
  952.         ' | per sprite sheet. However, if the sprite sheet's characteristics are ever   |
  953.         ' | changed the .map file will need to be deleted to have the new coordinate    |
  954.         ' | information calculated and saved. This will be in the documentation.        |
  955.         '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  956.         OPEN MapFileName FOR BINARY AS #FileNumber '                                        yes, open the map file for reading
  957.         DO '                                                                                cycle through 360 degrees
  958.             GET #FileNumber, , SLMap(Handle, Degree) '                                      get the rotational data for this degree
  959.             Degree = Degree + 1 '                                                           increment degree counter
  960.         LOOP UNTIL Degree = 360 '                                                           leave when 360 degrees cycled through
  961.         CLOSE #FileNumber '                                                                 close the map file
  962.     ELSE '                                                                                  no, the map file does not exist
  963.         '  _____________________________________________________________________________     _____________________________________
  964.         ' | The file must be created. This is the first time the sheet has been loaded. |   | If the .map file were to somehow    |
  965.         ' |-----------------------------------------------------------------------------|   | get deleted from the user's drive   |
  966.         ' | The original cell width and height        px(0),py(0)           px(3),py(3) |   | it will simply get recreated the    |
  967.         ' | are used to calculate the four         ....... +---------------------+      |   | next time the program is executed.  |
  968.         ' | corners of the image. These four          ^    |~\_     _MAPTRIANGLE |      |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  969.         ' | corners are then rotated through 360      |    |   ~\_       #2      |      |
  970.         ' | degrees to the new corner locations      cell  |      ~\_            |      |
  971.         ' | for _MAPTRIANGLE, and also to           height |         ~\_         |      |
  972.         ' | calculate the new width and height        |    |            ~\_      |      |
  973.         ' | of the rotated image. These values        |    | _MAPTRIANGLE  ~\_   |      |
  974.         ' | are then saved to a .map file for         V    |      #1          ~\_|      |
  975.         ' | later retrieval to speed up the        ....... +---------------------+      |
  976.         ' | process of _MAPTRIANGLE coordinate        px(1),py(1)           px(2),py(2) |
  977.         ' | calculations. This process will only           :                     :      |
  978.         ' | need to be performed once per sprite           :<--- cell width ---->:      |
  979.         ' | sheet unless the physical character-           :                     :      |
  980.         ' | istics of the sprite sheet change.                                          |
  981.         '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  982.         OPEN MapFileName FOR BINARY AS #FileNumber '                                        open the map file for writing
  983.         Degree = 0 '                                                                        reset the degree counter
  984.         DO '                                                                                cycle through 360 degrees
  985.             px(0) = -CellWidth / 2 '                                                        reset image corner coordinates
  986.             py(0) = -CellHeight / 2
  987.             px(1) = px(0)
  988.             py(1) = CellHeight / 2
  989.             px(2) = CellWidth / 2
  990.             py(2) = py(1)
  991.             px(3) = px(2)
  992.             py(3) = py(0)
  993.             SINr = SIN(-Degree / 57.2957795131) '                                           calculate the SIN of rotation
  994.             COSr = COS(-Degree / 57.2957795131) '                                           calculate the COSINE of rotation
  995.             Left = 0 '                                                                      reset rotated image boundaries
  996.             Top = 0
  997.             Right = 0
  998.             Bottom = 0
  999.             Polar = 0 '                                                                     reset polar coordinate counter
  1000.             DO '                                                                            cycle through the 4 polar coordinates
  1001.                 x = (px(Polar) * COSr + SINr * py(Polar)) '                                 calculate rotated image x corner
  1002.                 y = (py(Polar) * COSr - px(Polar) * SINr) '                                 calculate rotated image y corner
  1003.                 px(Polar) = x '                                                             record new corner x location
  1004.                 py(Polar) = y '                                                             record new corner y location
  1005.                 IF px(Polar) < Left THEN Left = px(Polar) '                                 get smallest left x value seen so far
  1006.                 IF px(Polar) > Right THEN Right = px(Polar) '                               get greatest right x value seen so far
  1007.                 IF py(Polar) < Top THEN Top = py(Polar) '                                   get smallest top y value seen so far
  1008.                 IF py(Polar) > Bottom THEN Bottom = py(Polar) '                             get greatest bottom y value seen so far
  1009.                 Polar = Polar + 1 '                                                         increment to next polar coordinate pair
  1010.             LOOP UNTIL Polar = 4 '                                                          leave when all four corners processed
  1011.             SLMap(Handle, Degree).width = Right - Left + 1 '                                record the width of the rotated image
  1012.             SLMap(Handle, Degree).height = Bottom - Top + 1 '                               record the height of the rotated image
  1013.             Xoffset = SLMap(Handle, Degree).width \ 2 '                                     calculate x offset to center image
  1014.             Yoffset = SLMap(Handle, Degree).height \ 2 '                                    calculate y offset to center image
  1015.             SLMap(Handle, Degree).px0 = INT(px(0)) + Xoffset '                              record all 4 centered coordinate pairs
  1016.             SLMap(Handle, Degree).px1 = INT(px(1)) + Xoffset
  1017.             SLMap(Handle, Degree).px2 = INT(px(2)) + Xoffset
  1018.             SLMap(Handle, Degree).px3 = INT(px(3)) + Xoffset
  1019.             SLMap(Handle, Degree).py0 = INT(py(0)) + Yoffset
  1020.             SLMap(Handle, Degree).py1 = INT(py(1)) + Yoffset
  1021.             SLMap(Handle, Degree).py2 = INT(py(2)) + Yoffset
  1022.             SLMap(Handle, Degree).py3 = INT(py(3)) + Yoffset
  1023.             PUT #1, , SLMap(Handle, Degree) '                                               save the rotational data for the degree
  1024.             Degree = Degree + 1 '                                                           increment the degree counter
  1025.         LOOP UNTIL Degree = 360 '                                                           leave when 360 degrees cycled through
  1026.         CLOSE #FileNumber '                                                                 close the map file
  1027.     END IF
  1028.     '  _________________________________________________________________________________
  1029.     ' | Return the array index as a pointer to this new sprite sheet                    |
  1030.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1031.     SL_LoadSheet = Handle '                                                                 return array index pointer to new sheet
  1032.  
  1033.  
  1034. '----------------------------------------------------------------------------------------------------------------------------------
  1035. SUB SL_GetCellCoordinates (Sheet AS INTEGER, Cell AS INTEGER, Rect AS SLRECT) '                               SL_GetCellCoordinates
  1036.     '  ___________________________________________________________________________________________________________________________
  1037.     ' | Returns the rectangular coordinates of a cell given the sprite sheet that it belongs to.                                  |
  1038.     ' |---------------------------------------------------------------------------------------------------------------------------|
  1039.     ' | Usage : SL_GetCellCoordinates MySheet, CellNumber, RectStructure                                                          |
  1040.     ' |                                                                                                                           |
  1041.     ' | Input : Sheet = the handle pointer of the sheet the cell resides in                                                       |
  1042.     ' |         Cell  = the cell number to return the coordinates of                                                              |
  1043.     ' |         Rect  = the rectangular structure (SLRECT) that the resuls are returned in                                        |
  1044.     ' |                                                                                                                           |
  1045.     ' | Output: the values in Rect will be modified with the coordinate information:                                              |
  1046.     ' |         Rect.left   = left   x coordinate of cell                                                                         |
  1047.     ' |         Rect.top    = top    y coordinate of cell                                                                         |
  1048.     ' |         Rect.right  = right  x coordinate of cell                                                                         |
  1049.     ' |         Rect.bottom = bottom y coordinate of cell                                                                         |
  1050.     ' |         Rect.width  = width of cell                                                                                       |
  1051.     ' |         Rect.height = height of cell                                                                                      |
  1052.     ' |          _________________________________________________________                                                        |
  1053.     ' | Note  : | ** INTERNAL USE ONLY ** not to be used by programmer ** |                                                       |
  1054.     ' |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                        |
  1055.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1056.     SHARED SLSheet() AS SLSHEET '   master sprite sheet array
  1057.     DIM Column AS INTEGER '         the column the cell resides in
  1058.     DIM Row AS INTEGER '            the row the cell resides in
  1059.     '  _________________________________________________________________________________
  1060.     ' | Calculate the row and column the sheet's cell reside in                         |
  1061.     ' |---------------------------------------------------------------------------------|
  1062.     ' | Sprite images within a sprite sheet are seen as cells with equal widths and     |
  1063.     ' | heights. The cells are numbered beginning at the top left corner and counting   |
  1064.     ' | to the right, beginning again at the next row down when the end of the current  |
  1065.     ' | row has been reached.                                                           |
  1066.     ' |                              <----- COLUMNS ----->                              |
  1067.     ' |                    1         2         3         4         5 ....               |
  1068.     ' |               +-------------------------------------------------+               |
  1069.     ' |               |         |         |         |         |         |               |
  1070.     ' |        ^    1 | cell 01 | cell 02 | cell 03 | cell 04 | cell 05 |               |
  1071.     ' |        |      |         |         |         |         |         |               |
  1072.     ' |        |      +-------------------------------------------------+               |
  1073.     ' |        |      |         |         |         |         |         |               |
  1074.     ' |      ROWS   2 | cell 06 | cell 07 | cell 08 | cell 09 | cell 10 |               |
  1075.     ' |        |      |         |         |         |         |         |               |
  1076.     ' |        |      +-------------------------------------------------+               |
  1077.     ' |        |      |         |         |         |         |         |               |
  1078.     ' |        V    3 | cell 11 | cell 12 | cell 13 | cell 14 | cell 15 |               |
  1079.     ' |             : |         |         |         |         |         |               |
  1080.     ' |             : +-------------------------------------------------+               |
  1081.     ' |                                                                                 |
  1082.     ' | Modulus division using the cell number will yield the current column a cell     |
  1083.     ' | resides in, execpt for the far right column. The result of a modulus division   |
  1084.     ' | with a cell in the far right column will produce 0 (zero). A result of zero can |
  1085.     ' | then be interpreted as the cell being in the column farthest to the right.      |
  1086.     ' |                                                                                 |
  1087.     ' | Once you have the column a cell resides in you can then subract that value from |
  1088.     ' | the cell, divide that result by the total number of columns and add 1 to get    |
  1089.     ' | the row a cell resides in.                                                      |
  1090.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1091.     Column = Cell MOD SLSheet(Sheet).Columns '                                              MOD remainder equals the column number
  1092.     IF Column = 0 THEN Column = SLSheet(Sheet).Columns '                                    unless it's 0, then column is greatest
  1093.     Row = (Cell - Column) / SLSheet(Sheet).Columns + 1 '                                    calculate the row number from column
  1094.     '  _________________________________________________________________________________
  1095.     ' | Calculate and return the rectangular coordinates of the sheet's cell            |
  1096.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1097.     Rect.Left = (Column - 1) * SLSheet(Sheet).CellWidth '                                   calculate left x coordinate of cell
  1098.     Rect.Top = (Row - 1) * SLSheet(Sheet).CellHeight '                                      calculate top y coordinate of cell
  1099.     Rect.Right = Rect.Left + SLSheet(Sheet).CellWidth - 1 '                                 calculate right x coordinate of cell
  1100.     Rect.Bottom = Rect.Top + SLSheet(Sheet).CellHeight - 1 '                                calculate bottom y coordinate of cell
  1101.     Rect.Width = SLSheet(Sheet).CellWidth '                                                 report cell width
  1102.     Rect.Height = SLSheet(Sheet).CellHeight '                                               report cell height
  1103.  
  1104.  
  1105. '----------------------------------------------------------------------------------------------------------------------------------
  1106. FUNCTION SL_FixDegree (Degree AS INTEGER) '                                                                            SL_FixDegree
  1107.     '  ___________________________________________________________________________________________________________________________
  1108.     ' | Returns a corrected degree value of 0 to 359 given the value passed in.                                                   |
  1109.     ' |---------------------------------------------------------------------------------------------------------------------------|
  1110.     ' | Usage : ValidDegree = SL_FixDegree(720)                                                                                   |
  1111.     ' |                                                                                                                           |
  1112.     ' | Input : Degree = the degree value to correct                                                                              |
  1113.     ' | Output: the corrected degree value between 0 and 359 degrees                                                              |
  1114.     ' | Credit: This function uses code contributed by CodeGuy - https://www.qb64.org/forum/index.php?topic=537.15                |
  1115.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1116.     DIM Deg AS INTEGER '            degree value supplied
  1117.  
  1118.     Deg = Degree MOD 360 '                                                                  get -359 to 359
  1119.     IF Deg < 0 THEN '                                                                       need to make positive?
  1120.         SL_FixDegree = Deg + 360 '                                                          yes, correct value and return degree
  1121.     ELSE '                                                                                  no correction needed
  1122.         SL_FixDegree = Deg '                                                                return degree
  1123.     END IF
  1124.  
  1125.  
  1126. '----------------------------------------------------------------------------------------------------------------------------------
  1127. FUNCTION SL_PPDistance (x1 AS INTEGER, y1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER) '                                 SL_PPDistance
  1128.     '  ___________________________________________________________________________________________________________________________
  1129.     ' | Calculates the distance in pixels between any two coordinate pair points.                                                 |
  1130.     ' |---------------------------------------------------------------------------------------------------------------------------|
  1131.     ' | Usage : Distance = SL_PPDistance(100, 100, 200, 200)                                                                      |
  1132.     ' |                                                                                                                           |
  1133.     ' | Input : x1 = x coordinate location of first point                                                                         |
  1134.     ' |         y1 = y coordinate location of first point                                                                         |
  1135.     ' |         x2 = x coordinate location of second point                                                                        |
  1136.     ' |         y2 = y coordinate location of second point                                                                        |
  1137.     ' | Output: the distance in pixels between the two coordinate pair points                                                     |
  1138.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1139.     DIM SideA AS INTEGER '          side A of right triangle
  1140.     DIM SideB AS INTEGER '          side B of right triangle
  1141.     '  _________________________________________________________________________________
  1142.     ' | Use Pythagoras to calculate the distance between the two points.                |
  1143.     ' |---------------------------------------------------------------------------------|
  1144.     ' | By using the Pythagorean Theorum                               x1,y1            |
  1145.     ' | Aý + Bý = Cý the distance between any                           /|              |
  1146.     ' | two points can be calculated by                               /  |              |
  1147.     ' | creating a right triangle between the                       /    |              |
  1148.     ' | two points, solving for sides A and B,        hypotenuse  /      |              |
  1149.     ' | and then solving for side C, the                SIDE C  /        | SIDE B       |
  1150.     ' | hypotenuse. The following formula can                 /          |              |
  1151.     ' | be utilized:                                        /            |              |
  1152.     ' |       _________                                   /              |              |
  1153.     ' |  C = û Aý + Bý                                  /               _|              |
  1154.     ' |                                               /________________I_|              |
  1155.     ' |                                            x2,y2     SIDE A                     |
  1156.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1157.     SideA = x1 - x2 '                                                                       calculate length of side A
  1158.     SideB = y1 - y2 '                                                                       calculate length of side B
  1159.     SL_PPDistance = INT(SQR(SideA * SideA + SideB * SideB)) '                               return length of side C (hypotenuse)
  1160.  
  1161.  
  1162. '----------------------------------------------------------------------------------------------------------------------------------
  1163. FUNCTION SL_SSDistance (Handle1 AS INTEGER, Handle2 AS INTEGER) '                                                     SL_SSDistance
  1164.     '  ___________________________________________________________________________________________________________________________
  1165.     ' | Calculates the distance in pixels between any two supplied sprites.                                                       |
  1166.     ' |---------------------------------------------------------------------------------------------------------------------------|
  1167.     ' | Usage : Distance = SL_SSDistance(Sprite1, Sprite2)                                                                        |
  1168.     ' |                                                                                                                           |
  1169.     ' | Input : Handle1 = the handle pointer name of first sprite                                                                 |
  1170.     ' |         Handle2 = the handle pointer name of second sprite                                                                |
  1171.     ' | Output: the distance in pixels between the two supplied sprites                                                           |
  1172.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1173.     SHARED SLSprite() AS SLSPRITE ' master sprite array
  1174.     '  _________________________________________________________________________________
  1175.     ' | Pass the sprite coordinates to SL_PPDistance to use Pythagoras to calculate.    |
  1176.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1177.     SL_SSDistance = SL_PPDistance(SLSprite(Handle1).Centerx, SLSprite(Handle1).Centery,_
  1178.                                   SLSprite(Handle2).Centerx, SLSprite(Handle2).Centery) '   return distance between the sprites
  1179.  
  1180.  
  1181. '----------------------------------------------------------------------------------------------------------------------------------
  1182. FUNCTION SL_SPDistance (Handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                              SL_SPDistance
  1183.     '  ___________________________________________________________________________________________________________________________
  1184.     ' | Calculates the distance in pixels between a sprite and a coordinate point.                                                |
  1185.     ' |---------------------------------------------------------------------------------------------------------------------------|
  1186.     ' | Usage : Distance = SL_SPDistance(Sprite, 100, 100)                                                                        |
  1187.     ' |                                                                                                                           |
  1188.     ' | Input : Handle = the handle pointer name of the sprite                                                                    |
  1189.     ' |         x      = the x coordinate value of the point                                                                      |
  1190.     ' |         y      = the y coordinate value of the point                                                                      |
  1191.     ' | Output: the distance in pixels between the sprite and the supplied coordinate point                                       |
  1192.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1193.     SHARED SLSprite() AS SLSPRITE ' master sprite array
  1194.     '  _________________________________________________________________________________
  1195.     ' | Pass the sprite coordinates and supplied coordinate to SL_PPDistance to use     |
  1196.     ' | Pythagoras to calculate.                                                        |
  1197.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1198.     SL_SPDistance = SL_PPDistance(SLSprite(Handle).Centerx, SLSprite(Handle).Centery, x, y) 'return distance to point from sprite
  1199.  
  1200.  
  1201. '----------------------------------------------------------------------------------------------------------------------------------
  1202. FUNCTION SL_PPAngle (x1 AS INTEGER, y1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER) '                                       SL_PPAngle
  1203.     '  ___________________________________________________________________________________________________________________________
  1204.     ' | Calculates the angle (0 to 359) between two coordinate pairs.                                                             |
  1205.     ' |---------------------------------------------------------------------------------------------------------------------------|
  1206.     ' | Usage : Angle = SL_PPAngle(100, 100, 200, 200)                                                                            |
  1207.     ' |                                                                                                                           |
  1208.     ' | Input : x1 = x coordinate location of first point                                                                         |
  1209.     ' |         y1 = y coordinate location of first point                                                                         |
  1210.     ' |         x2 = x coordinate location of second point                                                                        |
  1211.     ' |         y2 = y coordinate location of second point                                                                        |
  1212.     ' | Output: the angle from x1,y1 to x2,y2.                                                                                    |
  1213.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1214.     DIM angle AS INTEGER '          angle from x1,y1 to x2,y2
  1215.  
  1216.     IF y1 = y2 THEN '                                                                       both y values same?
  1217.         IF x1 = x2 THEN '                                                                   yes, both x values same?
  1218.             EXIT FUNCTION '                                                                 yes, there is no angle (0), leave
  1219.         END IF
  1220.         IF x2 > x1 THEN '                                                                   is second x to the right of first x?
  1221.             SL_PPAngle = 90 '                                                               yes, the angle must be 90 degrees
  1222.         ELSE '                                                                              no, second x is to the left of first x
  1223.             SL_PPAngle = 270 '                                                              the angle must be 270 degrees
  1224.         END IF
  1225.         EXIT FUNCTION '                                                                     leave function, angle computed
  1226.     END IF
  1227.     IF x1 = x2 THEN '                                                                       both x values same?
  1228.         IF y2 > y1 THEN '                                                                   yes, is second y lower than first y?
  1229.             SL_PPAngle = 180 '                                                              yes, the angle must be 180
  1230.         END IF
  1231.         EXIT FUNCTION '                                                                     leave function, angle computed
  1232.     END IF
  1233.     angle = ATN((x2 - x1) / (y2 - y1)) * -57.2957795131 '                                   calculate initial angle
  1234.     IF y2 < y1 THEN '                                                                       is second y higher than first y?
  1235.         IF x2 > x1 THEN '                                                                   yes, is second x to right of first x?
  1236.             SL_PPAngle = angle '                                                            yes, angle needs no adjustment
  1237.         ELSE '                                                                              no, second x is to left of first x
  1238.             SL_PPAngle = angle + 360 '                                                      adjust angle accordingly
  1239.         END IF
  1240.     ELSE '                                                                                  no, second y is lower than first y
  1241.         SL_PPAngle = angle + 180 '                                                          adjust angle accordingly
  1242.     END IF
  1243.  
  1244.  
  1245. '----------------------------------------------------------------------------------------------------------------------------------
  1246. FUNCTION SL_SSAngle (Handle1 AS INTEGER, Handle2 AS INTEGER) '                                                           SL_SSAngle
  1247.     '  ___________________________________________________________________________________________________________________________
  1248.     ' | Calculates the angle between any two supplied sprites.                                                                    |
  1249.     ' |---------------------------------------------------------------------------------------------------------------------------|
  1250.     ' | Usage : Angle = SL_SSAngle(Sprite1, Sprite2)                                                                              |
  1251.     ' |                                                                                                                           |
  1252.     ' | Input : Handle1 = the handle pointer name of first sprite                                                                 |
  1253.     ' |         Handle2 = the handle pointer name of second sprite                                                                |
  1254.     ' | Output: the angle from sprite1 to sprite2                                                                                 |
  1255.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1256.     SHARED SLSprite() AS SLSPRITE ' master sprite array
  1257.     '  _________________________________________________________________________________
  1258.     ' | Pass the sprite coordinates to SL_PPAngle to calculate the angle.               |
  1259.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1260.     SL_SSAngle = SL_PPAngle(SLSprite(Handle1).Centerx, SLSprite(Handle1).Centery,_
  1261.                             SLSprite(Handle2).Centerx, SLSprite(Handle2).Centery) '         return the angle between the sprites
  1262.  
  1263.  
  1264. '----------------------------------------------------------------------------------------------------------------------------------
  1265. FUNCTION SL_SPAngle (Handle AS INTEGER, x AS INTEGER, y AS INTEGER) '                                                    SL_SPAngle
  1266.     '  ___________________________________________________________________________________________________________________________
  1267.     ' | Calculates the angle between a sprite an a supplied coordinate pair.                                                      |
  1268.     ' |---------------------------------------------------------------------------------------------------------------------------|
  1269.     ' | Usage : Angle = SL_SPAngle(Sprite, 100, 100)                                                                              |
  1270.     ' |                                                                                                                           |
  1271.     ' | Input : Handle = the handle pointer name of the sprite                                                                    |
  1272.     ' |         x      = the x coordinate value of the point                                                                      |
  1273.     ' |         y      = the y coordinate value of the point                                                                      |
  1274.     ' | Output: the angle from the sprite to the supplied coordinate pair.                                                        |
  1275.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1276.     SHARED SLSprite() AS SLSPRITE ' master sprite array
  1277.     '  _________________________________________________________________________________
  1278.     ' | Pass the sprite coordinates to SL_PPAngle to calculate the angle.               |
  1279.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1280.     SL_SPAngle = SL_PPAngle(SLSprite(Handle).Centerx, SLSprite(Handle).Centery, x, y) '     return the angle from sprite to point
  1281.  
  1282.  
  1283. '----------------------------------------------------------------------------------------------------------------------------------
  1284. SUB SL_SpriteSet (Handle AS INTEGER, Action AS INTEGER, Value AS LONG) ' (MULTI-FUNCTION COMMAND)                      SL_SpriteSet
  1285.     '  ___________________________________________________________________________________________________________________________
  1286.     ' | Sets various aspects of sprite depending on action and value provided.                                                    |
  1287.     ' |---------------------------------------------------------------------------------------------------------------------------|
  1288.     ' | Usage : SL_SpriteSet MySPrite, SLZOOM, 150                                                                                |
  1289.     ' |                                                                                                                           |
  1290.     ' | Input : Handle = the handle pointer name of the sprite                                                                    |
  1291.     ' |         Action = the setting to be acted upon                                                                             |
  1292.     ' |         Value  = the new setting value                                                                                    |
  1293.     ' |                                                                                                                           |
  1294.     ' | Valid Action and Value combinations:                                                                                      |
  1295.     ' |                                                                                                                           |
  1296.     ' |     Action           Value(s)                                   Description                                               |
  1297.     ' | --------------  ------------------  ------------------------------------------------------------------------------------- |
  1298.     ' | SLZOOM          1 - 32767           Sets the zoom level for a sprite (100 = 100%, 200 = 200%, etc..)                      |
  1299.     ' | SLFLIP          SLNONE              reset sprite's orientation to normal (no flipping)                                    |
  1300.     ' |                 SLVERTICAL          flips a sprite vertically                                                             |
  1301.     ' |                 SLHORIZONTAL        flips a sprite horizontally                                                           |
  1302.     ' |                 SLBOTH              flips a sprite both horizontally and vertically                                       |
  1303.     ' | SLVISIBLE       SLTRUE              sets the sprite as visible on screen                                                  |
  1304.     ' |                 SLFALSE             sets the sprite as invisible (will not be shown on screen)                            |
  1305.     ' | SLLAYER         0 - max layers      sets the layer associated with the sprite                                             |
  1306.     ' | SLSCORE         any LONG INT        sets the score associated with a sprite                                               |
  1307.     ' | SLAUTOANIMATE   SLTRUE              enables sprite auto-animation                                                         |
  1308.     ' |                 SLFALSE             disables sprite auto-animation                                                        |
  1309.     ' | SLFROMCELL      1 - max cells       sets the sprite's animation sequence starting cell number (must be less than ending)  |
  1310.     ' | SLTOCELL        1 - max cells       sets the sprite's animation sequence ending cell number (must be greater than start)  |
  1311.     ' | SLANIMATEDIR    SLFORWARD           animation sequence will proceed from start to end then recylce back to start          |
  1312.     ' |                 SLBACKWARD          animation sequence will proceed from end to start then recycle back to end            |
  1313.     ' |                 SLBACKFORTH         animation sequence will proceed SLFORWARD, then SLBACKWARD, then recyle to SLFORWARD  |
  1314.     ' | SLFRAMERATE     1 - global rate     sets the local independent frame rate of the sprite                                   |
  1315.     ' | SLAUTOMOTION    SLTRUE              enables sprite auto-motion                                                            |
  1316.     ' |                 SLFALSE             disables sprite auto-motion                                                           |
  1317.     ' | SLMOTIONANGLE   -359 to 359         sets the sprite's direction of motion (SLXDIR and SLYDIR computed from this)          |
  1318.     ' | SLXDIR          -32768 - 32767      sets the sprite's x motion vextor (used to over-ride SLMOTIONANGLE if desired)        |
  1319.     ' | SLYDIR          -32768 - 32767      sets the sprite's y motion vector (used to over-ride SLMOTIONANGLE if desired)        |
  1320.     ' | SLAUTOROTATE    SLTRUE              enables sprite auto-rotation                                                          |
  1321.     ' |                 SLFALSE             disables sprite auto-rotation                                                         |
  1322.     ' | SLROTATEANGLE   -359 to 359         set rotation angle of sprite                                                          |
  1323.     ' | SLROTATESPEED   -359 to 359         set the rotation rate (or spin) of a sprite                                           |
  1324.     ' | SLDETECTION     SLNONE              disable sprite collision detection                                                    |
  1325.     ' |                 SLRECTANGLE         enable rectangular sprite collision detection                                         |
  1326.     ' |                 SLCIRCLE            enable circular sprite collision detection                                            |
  1327.     ' |                 SLPIXEL             enable pixel-perfect sprite collision detection                                       |
  1328.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1329.     SHARED SLSheet() AS SLSHEET '   master sprite sheet array
  1330.     SHARED SLSprite() AS SLSPRITE ' master sprite array
  1331.     SHARED SLGlobal AS SLGLOBAL '   global variables
  1332.  
  1333.     IF SL_ValidSprite(Handle) = SLFALSE THEN SL_Error 1, "SL_SpriteSet" '                   report error if invalid sprite
  1334.     SELECT CASE Action '                                                                    which value will be set?
  1335.         CASE SLZOOM '                                                                       set sprite zoom level
  1336.             '  _________________________________________________________________________
  1337.             ' | Valid values: 1 through 32767                                           |
  1338.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1339.             IF (Value < 1) OR (Value > 32767) THEN SL_Error 2, "SL_SpriteSet" '             report error if invalid zoom level
  1340.             SLSprite(Handle).Zoom = Value '                                                 set sprite's zoom level
  1341.         CASE SLFLIP '                                                                       set sprite flipping behavior
  1342.             '  _________________________________________________________________________
  1343.             ' | Valid values: SLNONE, SLVERTICAL, SLHORIZONTAL, SLBOTH                  |
  1344.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1345.             IF (Value < SLNONE) OR (Value > SLBOTH) THEN SL_Error 3, "SL_SpriteSet" '       report error if invalid flip setting
  1346.             SLSprite(Handle).Flipped = Value '                                              set sprite's flipping behavior
  1347.         CASE SLVISIBLE '                                                                    set sprite visibility
  1348.             '  _________________________________________________________________________
  1349.             ' | Valid values: SLTRUE, SLFALSE                                           |
  1350.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1351.             IF (Value <> SLFALSE) AND (Value <> SLTRUE) THEN SL_Error 4, "SL_SpriteSet" '   reprt error if invalid visible setting
  1352.             SLSprite(Handle).Visible = Value '                                              set sprite's visibility
  1353.         CASE SLLAYER '                                                                      set layer sprite belongs to
  1354.             '  _________________________________________________________________________
  1355.             ' | Valid values: 0 through UBOUND(SLLayers)                                |
  1356.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1357.             IF (Value < 0) OR (Value > SLGlobal.Layers) THEN SL_Error 5, "SL_SpriteSet" '   report error if invalid layer requested
  1358.             SLSprite(Handle).Layer = Value '                                                set sprite's layer
  1359.         CASE SLSCORE '                                                                      set score value of sprite
  1360.             '  _________________________________________________________________________
  1361.             ' | Valid values: any number in LONG integer range                          |
  1362.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1363.             SLSprite(Handle).Score = Value '                                                set sprite's score
  1364.         CASE SLAUTOANIMATE '                                                                enable or disable auto animation
  1365.             '  _________________________________________________________________________
  1366.             ' | Valid values: SLTRUE, SLFALSE                                           |
  1367.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1368.             IF (Value <> SLFALSE) AND (Value <> SLTRUE) THEN SL_Error 6, "SL_SpriteSet" '   report error if invalid auto-motion
  1369.             SLSprite(Handle).Anim.Auto = Value '                                            set sprite's auto-motion
  1370.         CASE SLFROMCELL '                                                                   set animation starting cell
  1371.             '  _________________________________________________________________________
  1372.             ' | Valid values: 1 through total number of cells on sheet                  |
  1373.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1374.             IF (Value < 1) OR (Value > SLSheet(SLSprite(Handle).OrigSheet).TotalCells) THEN 'invalid cell requested?
  1375.                 SL_Error 7, "SL_SpriteSet" '                                                yes, report error
  1376.             END IF
  1377.             SLSprite(Handle).Anim.FromCell = Value '                                        set sprite's animation start cell
  1378.         CASE SLTOCELL '                                                                     set animation ending cell
  1379.             '  _________________________________________________________________________
  1380.             ' | Valid values: 1 through total number of cells on sheet                  |
  1381.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1382.             IF (Value < 1) OR (Value > SLSheet(SLSprite(Handle).OrigSheet).TotalCells) OR _
  1383.                (Value <= SLSprite(Handle).Anim.FromCell) THEN '                             invalid cell requested?
  1384.                 SL_Error 7, "SL_SpriteSet" '                                                yes, report error
  1385.             END IF
  1386.             SLSprite(Handle).Anim.ToCell = Value '                                          set sprite's animation end cell
  1387.         CASE SLANIMATEDIR '                                                                 set direction of animation sequence
  1388.             '  _________________________________________________________________________
  1389.             ' | Valid values: SLFORWARD, SLBACKWARD, SLBACKFORTH                        |
  1390.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1391.             IF (Value < SLFORWARD) OR (Value > SLBACKFORTH) THEN SL_Error 8, "SL_SpriteSet" 'report error if invalid direction
  1392.             SLSprite(Handle).Anim.Direction = Value '                                       set sprite's animation direction
  1393.         CASE SLFRAMERATE '                                                                  set local animation frame rate
  1394.             '  _________________________________________________________________________
  1395.             ' | Valid values: 1 through global frame rate                               |
  1396.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1397.             IF (Value < 1) OR (Value > SLGlobal.FrameRate) THEN SL_Error 9, "SL_SpriteSet" 'report error if invalid frame rate
  1398.             SLSprite(Handle).Anim.FrameRate = Value '                                       set sprite's local frame rate
  1399.         CASE SLAUTOMOTION '                                                                 enable or disable auto motion
  1400.             '  _________________________________________________________________________
  1401.             ' | Valid values: SLTRUE, SLFALSE                                           |
  1402.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1403.             IF (Value <> SLFALSE) AND (Value <> SLTRUE) THEN SL_Error 10, "SL_SpriteSet" '  report error if invalid auto motion
  1404.             SLSprite(Handle).Move.Auto = Value '                                            set sprite's auto motion
  1405.         CASE SLMOTIONANGLE '                                                                set angle in degrees of motion
  1406.             '  _________________________________________________________________________
  1407.             ' | Valid values: -359 through 359                                          |
  1408.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1409.             SLSprite(Handle).Move.Degree = SL_FixDegree(Value) '                            set sprite's angle of motion
  1410.         CASE SLXDIR '                                                                       set x motion direction vector
  1411.             '  _________________________________________________________________________
  1412.             ' | Valid values: -32768 through 32767                                      |
  1413.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1414.             IF (Value < -32768) OR (Value > 32767) THEN SL_Error 11, "SL_SpriteSet" '       report error if invalid x vector value
  1415.             SLSprite(Handle).Move.Xdir = Value '                                            set sprite's x vector
  1416.         CASE SLYDIR '                                                                       set y motion direction vector
  1417.             '  _________________________________________________________________________
  1418.             ' | Valid values: -32768 through 32767                                      |
  1419.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1420.             IF (Value < -32768) OR (Value > 32767) THEN SL_Error 12, "SL_SpriteSet" '       report error if invalid y vector value
  1421.             SLSprite(Handle).Move.Ydir = Value '                                            set sprite's y vector
  1422.         CASE SLAUTOROTATE '                                                                 enable or disable auto rotation
  1423.             '  _________________________________________________________________________
  1424.             ' | Valid values: SLTRUE, SLFALSE                                           |
  1425.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1426.             IF (Value <> SLFALSE) AND (Value <> SLTRUE) THEN SL_Error 13, "SL_SpriteSet" '  report error if invalid auto rotation
  1427.             SLSprite(Handle).Spin.Auto = Value '                                            set sprite's auto rotation
  1428.         CASE SLROTATEANGLE '                                                                set angle in degrees of rotation
  1429.             '  _________________________________________________________________________
  1430.             ' | Valid values: -359 through 359                                          |
  1431.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1432.             SLSprite(Handle).Spin.Degree = SL_FixDegree(Value) '                            set sprite's angle of rotation
  1433.         CASE SLROTATESPEED '                                                                set spin speed of rotation
  1434.             '  _________________________________________________________________________
  1435.             ' | Valid values: -359 through 359                                          |
  1436.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1437.             IF ABS(Value) > 359 THEN SL_Error 14, "SL_SpriteSet" '                          report error if invalid rotate speed
  1438.             SLSprite(Handle).Spin.Rate = Value '                                            set sprite's spin rate
  1439.         CASE SLDETECTION '                                                                  set sprite collision detection method
  1440.             '  _________________________________________________________________________
  1441.             ' | Valid values: SLNONE, SLRECTANGLE, SLCIRCLE, SLPIXEL                    |
  1442.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1443.             IF (Value < SLNONE) OR (Value > SLPIXEL) THEN SL_Error 15, "SL_SpriteSet" '     report error if invalid detection
  1444.             SLSprite(Handle).Coll.Detect = Value '                                          set sprite's collision detection method
  1445.         CASE ELSE
  1446.             SL_Error 16, "SL_SpriteSet" '                                                   report invalid use of command
  1447.     END SELECT
  1448.  
  1449.  
  1450. '----------------------------------------------------------------------------------------------------------------------------------
  1451. FUNCTION SL_SpriteGet (Handle AS INTEGER, Action AS INTEGER) ' (MULTI-FUNCTION COMMAND)                                SL_SpriteGet
  1452.     '  ___________________________________________________________________________________________________________________________
  1453.     ' | Gets various aspects of a sprite depending on the action provided.                                                        |
  1454.     ' |---------------------------------------------------------------------------------------------------------------------------|
  1455.     ' | Usage : Setting = SL_SpriteGet(MySprite, SLZOOM)                                                                          |
  1456.     ' |                                                                                                                           |
  1457.     ' | Input : Handle = the handle pointer name of the sprite                                                                    |
  1458.     ' |         Action = the setting to be acted upon                                                                             |
  1459.     ' | Output: A return value based on the setting to obtain a value from                                                        |
  1460.     ' |                                                                                                                           |
  1461.     ' | Valid Actions and their return value(s):                                                                                  |
  1462.     ' |                                                                                                                           |
  1463.     ' |     Action       Return Value(s)                                Description                                               |
  1464.     ' | --------------  ------------------  ------------------------------------------------------------------------------------- |
  1465.     ' | SLZOOM          1 - 32767           retrieve the current zoom level of the sprite (100 = 100%, 200 = 200%, etc..)         |
  1466.     ' | SLFLIP          SLNONE              sprite flipping disabled                                                              |
  1467.     ' |                 SLVERTICAL          sprite set to flip vertically                                                         |
  1468.     ' |                 SLHORIZONTAL        sprite set to flip horizontally                                                       |
  1469.     ' |                 SLBOTH              sprite set to flip vertically and horizontally                                        |
  1470.     ' | SLVISIBLE       SLTRUE              sprite is set to be visible on screen                                                 |
  1471.     ' |                 SLFALSE             sprite is set to be invisible                                                         |
  1472.     ' | SLLAYER         1 to max layers     the layer a sprite belongs to                                                         |
  1473.     ' | SLSCORE         Any LONG integer    the score associated with the sprite                                                  |
  1474.     ' | SLLEFT          -32768 to 32767     the left x coordinate of the sprite                                                   |
  1475.     ' | SLTOP           -32768 to 32767     the top y coordinate of the sprite                                                    |
  1476.     ' | SLRIGHT         -32768 to 32767     the right x coordinate of the sprite                                                  |
  1477.     ' | SLBOTTOM        -32768 to 32767     the bottom y coordinate of the sprite                                                 |
  1478.     ' | SLWIDTH         1 to 32767          the width of the sprite                                                               |
  1479.     ' | SLHEIGHT        1 to 32767          the height of the sprite                                                              |
  1480.     ' | SLCENTERX       1 to 16382          the center x coordinate of the sprite                                                 |
  1481.     ' | SLCENTERY       1 to 16382          the center y coordinate of the sprite                                                 |
  1482.     ' | SLFRAMERATE     1 to global rate    the current independent animation frame rate of the sprite                            |
  1483.     ' | SLAUTOANIMATE   SLTRUE              auto-animation is enabled for the sprite                                              |
  1484.     ' |                 SLFALSE             auto-animation is disabled for the sprite                                             |
  1485.     ' | SLFROMCELL      1 to max cells      the sprite's animation start cell (must be less than SLTOCELL)                        |
  1486.     ' | SLTOCELL        1 to max cells      the sprite's animation end cell (must be greater than SLFROMCELL)                     |
  1487.     ' | SLANIMATEDIR    SLFORWARD           the sprite's animation will proceed from start to end cell then back to start         |
  1488.     ' |                 SLBACKWARD          the sprite's animation will proceed from end to start cell then back to end           |
  1489.     ' |                 SLBACKFORTH         the sprite's animation will proceed from start to end then end to start               |
  1490.     ' | SLAUTOMOTION    SLTRUE              auto-motion is enabled for the sprite                                                 |
  1491.     ' |                 SLFALSE             auto-motion is disabled for the sprite                                                |
  1492.     ' | SLMOTIONANGLE   0 to 359            the sprite's current angle of motion                                                  |
  1493.     ' | SLXDIR          -32768 to 32767     the sprite's current x motion vector                                                  |
  1494.     ' | SLYDIR          -32768 to 32767     the sprite's current y motion vector                                                  |
  1495.     ' | SLAUTOROTATE    SLTRUE              auto-rotation is enabled for the sprite                                               |
  1496.     ' |                 SLFALSE             auto-rotation is disabled for the sprite                                              |
  1497.     ' | SLROTATEANGLE   0 to 359            the sprite's current rotation angle                                                   |
  1498.     ' | SLROTATESPEED   0 to 359            the sprite's current spin rate                                                        |
  1499.     ' | SLDETECTION     SLNONE              collision detection for the sprite is disabled                                        |
  1500.     ' |                 SLRECTANGLE         collision detection is set to rectangle collsiion                                     |
  1501.     ' |                 SLCIRCLE            collision detection is set for circular collision                                     |
  1502.     ' |                 SLPIXEL             collsiion detection is set for pixel-perfect collision                                |
  1503.     ' | SLCOLLISION     SLTRUE              this sprite has collided with another object                                          |
  1504.     ' |                 SLFALSE             no collisions have been detected with this sprite                                     |
  1505.     ' | SLCOLLIDEWITH   1 to max sprites    the sprite has collided with this sprite                                              |
  1506.     ' |                 SLNONE              no other sprite has been collided with                                                |
  1507.     ' | SLCOLLIDEX      -32768 to 32767     the x coordinate location of sprite collision                                         |
  1508.     ' | SLCOLLIDEY      -32768 to 32767     the y coordinate location of sprite collision                                         |
  1509.     ' | SLMOUSE         SLNONE              no interaction with the mouse pointer has been recorded                               |
  1510.     ' |                 SLLEFTCLICK         the left mouse button was clicked while on the sprite                                 |
  1511.     ' |                 SLRIGHTCLICK        the right mouse button was clicked while on the sprite                                |
  1512.     ' |                 SLMIDDLECLICK       the middle mouse button was clicked while on the sprite                               |
  1513.     ' |                 SLHOVER             the mouse pointer is currently hovering over the sprite                               |
  1514.     ' | SLMOUSEX        0 - screen width-1  the current mouse x location on the screen in relation to the sprite                  |
  1515.     ' | SLMOUSEY        0 - screen height-1 the current mouse y location on the screen in relation to the sprite                  |
  1516.     ' | SLSPRITEMOUSEX  sprite left - right the current mouse x location on the sprite                                            |
  1517.     ' | SLSPRITEMOUSEY  sprite top - bottom the current mouse y location on the sprite                                            |
  1518.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1519.     SHARED SLSprite() AS SLSPRITE ' master sprite array
  1520.  
  1521.     IF SL_ValidSprite(Handle) = SLFALSE THEN SL_Error 1, "SL_SpriteGet" '                   report error if invalid sprite
  1522.     SELECT CASE Action
  1523.         CASE SLZOOM
  1524.             '  _________________________________________________________________________
  1525.             ' | Valid returns: 1 - 32767                                                |
  1526.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1527.             SL_SpriteGet = SLSprite(Handle).Zoom
  1528.         CASE SLFLIP
  1529.             '  _________________________________________________________________________
  1530.             ' | Valid returns: SLNONE, SLVERTICAL, SLHORIZONTAL, SLBOTH                 |
  1531.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1532.             SL_SpriteGet = SLSprite(Handle).Flipped
  1533.         CASE SLVISIBLE
  1534.             '  _________________________________________________________________________
  1535.             ' | Valid returns: SLTRUE, SLFALSE                                          |
  1536.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1537.             SL_SpriteGet = SLSprite(Handle).Visible
  1538.         CASE SLLAYER
  1539.             '  _________________________________________________________________________
  1540.             ' | Valid returns: 0 - UBOUND(SLLayers)                                     |
  1541.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1542.             SL_SpriteGet = SLSprite(Handle).Layer
  1543.         CASE SLSCORE
  1544.             '  _________________________________________________________________________
  1545.             ' | Valid returns: any number in LONG integer range                         |
  1546.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1547.             SL_SpriteGet = SLSprite(Handle).Score
  1548.         CASE SLLEFT
  1549.             '  _________________________________________________________________________
  1550.             ' | Valid returns: -32768 through 32767                                     |
  1551.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1552.             SL_SpriteGet = SLSprite(Handle).Scrn.Left
  1553.         CASE SLTOP
  1554.             '  _________________________________________________________________________
  1555.             ' | Valid returns: -32768 through 32767                                     |
  1556.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1557.             SL_SpriteGet = SLSprite(Handle).Scrn.Top
  1558.         CASE SLRIGHT
  1559.             '  _________________________________________________________________________
  1560.             ' | Valid returns: -32768 through 32767                                     |
  1561.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1562.             SL_SpriteGet = SLSprite(Handle).Scrn.Right
  1563.         CASE SLBOTTOM
  1564.             '  _________________________________________________________________________
  1565.             ' | Valid returns: -32768 through 32767                                     |
  1566.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1567.             SL_SpriteGet = SLSprite(Handle).Scrn.Bottom
  1568.         CASE SLWIDTH
  1569.             '  _________________________________________________________________________
  1570.             ' | Valid returns: -32768 through 32767                                     |
  1571.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1572.             SL_SpriteGet = SLSprite(Handle).Scrn.Width
  1573.         CASE SLHEIGHT
  1574.             '  _________________________________________________________________________
  1575.             ' | Valid returns: -32768 through 32767                                     |
  1576.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1577.             SL_SpriteGet = SLSprite(Handle).Scrn.Height
  1578.         CASE SLCENTERX
  1579.             '  _________________________________________________________________________
  1580.             ' | Valid returns: -32768 through 32767                                     |
  1581.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1582.             SL_SpriteGet = SLSprite(Handle).Centerx
  1583.         CASE SLCENTERY
  1584.             '  _________________________________________________________________________
  1585.             ' | Valid returns: -32768 through 32767                                     |
  1586.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1587.             SL_SpriteGet = SLSprite(Handle).Centery
  1588.         CASE SLFRAMERATE
  1589.             '  _________________________________________________________________________
  1590.             ' | Valid returns: 1 through global frame rate                              |
  1591.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1592.             SL_SpriteGet = SLSprite(Handle).Anim.FrameRate
  1593.         CASE SLAUTOANIMATE
  1594.             '  _________________________________________________________________________
  1595.             ' | Valid returns: SLTRUE, SLFALSE                                          |
  1596.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1597.             SL_SpriteGet = SLSprite(Handle).Anim.Auto
  1598.         CASE SLFROMCELL
  1599.             '  _________________________________________________________________________
  1600.             ' | Valid returns: 1 through total number of cells on sheet                 |
  1601.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1602.             SL_SpriteGet = SLSprite(Handle).Anim.FromCell
  1603.         CASE SLTOCELL
  1604.             '  _________________________________________________________________________
  1605.             ' | Valid returns: 1 through total number of cells on sheet                 |
  1606.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1607.             SL_SpriteGet = SLSprite(Handle).Anim.ToCell
  1608.         CASE SLANIMATEDIR
  1609.             '  _________________________________________________________________________
  1610.             ' | Valid returns: SLFORWARD, SLBACKWARD, SLBACKFORTH                       |
  1611.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1612.             SL_SpriteGet = SLSprite(Handle).Anim.Direction
  1613.         CASE SLAUTOMOTION
  1614.             '  _________________________________________________________________________
  1615.             ' | Valid returns: SLTRUE, SLFALSE                                          |
  1616.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1617.             SL_SpriteGet = SLSprite(Handle).Move.Auto
  1618.         CASE SLMOTIONANGLE
  1619.             '  _________________________________________________________________________
  1620.             ' | Valid returns: 0 through 359                                            |
  1621.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1622.             SL_SpriteGet = SLSprite(Handle).Move.Degree
  1623.         CASE SLXDIR
  1624.             '  _________________________________________________________________________
  1625.             ' | Valid returns: -32768 through 32767                                     |
  1626.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1627.             SL_SpriteGet = SLSprite(Handle).Move.Xdir
  1628.         CASE SLYDIR
  1629.             '  _________________________________________________________________________
  1630.             ' | Valid returns: -32768 through 32767                                     |
  1631.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1632.             SL_SpriteGet = SLSprite(Handle).Move.Ydir
  1633.         CASE SLAUTOROTATE
  1634.             '  _________________________________________________________________________
  1635.             ' | Valid returns: SLTRUE, SLFALSE                                          |
  1636.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1637.             SL_SpriteGet = SLSprite(Handle).Spin.Auto
  1638.         CASE SLROTATEANGLE
  1639.             '  _________________________________________________________________________
  1640.             ' | Valid returns: 0 through 359                                            |
  1641.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1642.             SL_SpriteGet = SLSprite(Handle).Spin.Degree
  1643.         CASE SLROTATESPEED
  1644.             '  _________________________________________________________________________
  1645.             ' | Valid returns: -359 through 359                                         |
  1646.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1647.             SL_SpriteGet = SLSprite(Handle).Spin.Rate
  1648.         CASE SLDETECTION
  1649.             '  _________________________________________________________________________
  1650.             ' | Valid returns: SLNONE, SLRECTANGLE, SLCIRCLE, SLPIXEL                   |
  1651.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1652.             SL_SpriteGet = SLSprite(Handle).Coll.Detect
  1653.         CASE SLCOLLISION
  1654.             '  _________________________________________________________________________
  1655.             ' | Valid returns: SLTRUE, SLFALSE                                          |
  1656.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1657.             SL_SpriteGet = SLSprite(Handle).Coll.Event
  1658.         CASE SLCOLLIDEWITH
  1659.             '  _________________________________________________________________________
  1660.             ' | Valid returns: 1 through maximum number of sprite handles               |
  1661.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1662.             SL_SpriteGet = SLSprite(Handle).Coll.With
  1663.         CASE SLCOLLIDEX
  1664.             '  _________________________________________________________________________
  1665.             ' | Valid returns: -32768 through 32767                                     |
  1666.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1667.             SL_SpriteGet = SLSprite(Handle).Coll.Xloc
  1668.         CASE SLCOLLIDEY
  1669.             '  _________________________________________________________________________
  1670.             ' | Valid returns: -32768 through 32767                                     |
  1671.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1672.             SL_SpriteGet = SLSprite(Handle).Coll.Yloc
  1673.         CASE SLMOUSE
  1674.             '  _________________________________________________________________________
  1675.             ' | Valid returns: SLNONE, SLLEFTCLICK, SLRIGHTCLICK, SLMIDDLECLICK, SLHOVER|
  1676.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1677.             SL_SpriteGet = SLSprite(Handle).Mouse.Event
  1678.         CASE SLMOUSEX
  1679.             '  _________________________________________________________________________
  1680.             ' | Valid returns: 0 through screen width - 1                               |
  1681.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1682.             SL_SpriteGet = SLSprite(Handle).Mouse.SXloc
  1683.         CASE SLMOUSEY
  1684.             '  _________________________________________________________________________
  1685.             ' | Valid returns: 0 through screen height - 1                              |
  1686.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1687.             SL_SpriteGet = SLSprite(Handle).Mouse.SYloc
  1688.         CASE SLSPRITEMOUSEX
  1689.             '  _________________________________________________________________________
  1690.             ' | Valid returns: sprite.left through sprite.right                         |
  1691.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1692.             SL_SpriteGet = SLSprite(Handle).Mouse.Xloc
  1693.         CASE SLSPRITEMOUSEY
  1694.             '  _________________________________________________________________________
  1695.             ' | Valid returns: sprite.top through sprite.bottom                         |
  1696.             '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1697.             SL_SpriteGet = SLSprite(Handle).Mouse.Yloc
  1698.         CASE ELSE
  1699.             SL_Error 17, "SL_SpriteGet" '                                                   report invalid use of command
  1700.     END SELECT
  1701.  
  1702.  
  1703. '----------------------------------------------------------------------------------------------------------------------------------
  1704. FUNCTION SL_ValidSprite (Handle AS INTEGER) '                                                                        SL_ValidSprite
  1705.     '  ___________________________________________________________________________________________________________________________
  1706.     ' | Checks that the supplied sprite handle points to a valid sprite.                                                          |
  1707.     ' |---------------------------------------------------------------------------------------------------------------------------|
  1708.     ' | Usage : Valid = SL_ValidSprite(MySprite)                                                                                  |
  1709.     ' |                                                                                                                           |
  1710.     ' | Input : Handle = the handle pointer name of the sprite                                                                    |
  1711.     ' | Output: SLTRUE if the sprite handle is valid, SLFALSE otherwise.                                                          |
  1712.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1713.     SHARED SLSprite() AS SLSPRITE ' master sprite array
  1714.  
  1715.     IF Handle > UBOUND(SLSprite) OR Handle < 0 THEN '                                       is this a valid handle pointer?
  1716.         SL_ValidSprite = SLFALSE '                                                          no, return SLFALSE
  1717.     ELSEIF SLSprite(Handle).InUse THEN '                                                    yes, is the sprite currently in use?
  1718.         SL_ValidSprite = SLTRUE '                                                           yes, return SLTRUE
  1719.     END IF
  1720.     '  _________________________________________________________________________________
  1721.     ' | If the handle was not in use the function will return 0 (SLFALSE)               |
  1722.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1723.  
  1724. '----------------------------------------------------------------------------------------------------------------------------------
  1725. FUNCTION SL_Min (Num1 AS INTEGER, Num2 AS INTEGER) '                                                                         SL_Min
  1726.     '  ___________________________________________________________________________________________________________________________
  1727.     ' | Returns the smaller of the two numbers supplied.                                                                          |
  1728.     ' |---------------------------------------------------------------------------------------------------------------------------|
  1729.     ' | Usage : Smallest = SL_Min(Number1, Number2)                                                                               |
  1730.     ' |                                                                                                                           |
  1731.     ' | Input : Num1, Num2 = the two numbers to be compared                                                                       |
  1732.     ' | Output: The smaller of the two numbers (if equal then Num2 will always be returned)                                       |
  1733.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1734.     IF Num1 < Num2 THEN SL_Min = Num1 ELSE SL_Min = Num2 '                                  return the smallest of the two numbers
  1735.  
  1736.  
  1737. '----------------------------------------------------------------------------------------------------------------------------------
  1738. FUNCTION SL_Max (Num1 AS INTEGER, Num2 AS INTEGER) '                                                                         SL_Max
  1739.     '  ___________________________________________________________________________________________________________________________
  1740.     ' | Returns the larger of the two numbers supplied.                                                                           |
  1741.     ' |---------------------------------------------------------------------------------------------------------------------------|
  1742.     ' | Usage : Largest = SL_Max(Number1, Number2)                                                                                |
  1743.     ' |                                                                                                                           |
  1744.     ' | Input : Num1, Num2 = the two numbers to be compared                                                                       |
  1745.     ' | Output: The larger of the two numbers (if equal then Num2 will always be returned)                                        |
  1746.     '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1747.     IF Num1 > Num2 THEN SL_Max = Num1 ELSE SL_Max = Num2 '                                  return the largest of the two numbers
  1748.  
  1749.  
  1750. '----------------------------------------------------------------------------------------------------------------------------------
  1751. SUB SL_Error (ErrNo AS INTEGER, Routine AS STRING)
  1752.     '  ___________________________________________________________________________________________________________________________
  1753.     ' |                                                                                                                           |
  1754.     ' |---------------------------------------------------------------------------------------------------------------------------|
  1755.     ' | Usage :                                                                                                                   |
  1756.     ' |                                                                                                                           |
  1757.     ' | Input :                                                                                                                   |
  1758.     ' |                                                                                                                           |
  1759.     ' | Output:                                                                                                                   |
  1760.  
  1761.     BEEP
  1762.  
  1763.     SCREEN 0, 0, 0, 0
  1764.     PRINT ErrNo, Routine
  1765.  
  1766.     SELECT CASE ErrNo
  1767.         CASE 1 ' invalid sprite
  1768.         CASE 2 ' invalid sprite zoom level
  1769.         CASE 3 ' invalid sprite flpping behavior
  1770.         CASE 4 ' invalid sprite visibility setting
  1771.         CASE 5 ' invalid layer requested
  1772.         CASE 6 ' invalid auto-animation setting
  1773.         CASE 7 ' invalid cell requested
  1774.         CASE 8 ' invalid animation direction requested
  1775.         CASE 9 ' invalid sprite frame rate requested
  1776.         CASE 10 ' invalid auto-motion setting
  1777.         CASE 11 ' invalid x direction vector
  1778.         CASE 12 ' invalid y direction vector
  1779.         CASE 13 ' invalid auto-rotation setting
  1780.         CASE 14 ' invalid rotation speed
  1781.         CASE 15 ' invalid colllsion detection method
  1782.         CASE 16 ' invalid use of SL_SpriteSet
  1783.         CASE 17 ' invalid use of SL_SpriteGet
  1784.  
  1785.     END SELECT
  1786.  
  1787.     END
  1788.  
  1789.  
  1790.  
Title: Re: Sprite Library Revisited
Post by: TempodiBasic on November 04, 2018, 07:00:07 am
Hi Terry

while you are working in progress with your library
you raccomande us to use old library or the new in progress because only news are in evolution and the rest part is done and it will not change?
Title: Re: Sprite Library Revisited
Post by: madscijr on December 04, 2020, 11:00:41 am
Just an update to state I'm still working on the library. Here is the current state of the code:

I'm new to QB64 and just learning by making some simple games.
This library seems really useful - have you updated it since this post?
Does this have a home on git hub?
A tutorial and especially example programs (such as simple basic games) that illustrate how to utilize it would be very helpful.
Title: Re: Sprite Library Revisited
Post by: bplus on December 04, 2020, 12:22:13 pm
I'm new to QB64 and just learning by making some simple games.
This library seems really useful - have you updated it since this post?
Does this have a home on git hub?
A tutorial and especially example programs (such as simple basic games) that illustrate how to utilize it would be very helpful.


Welcome madscijr!  Mad Scientist Jr?

Terry hasn't been around for awhile at least with public posts here but you can find links to his wonderful tutorial from this .org Home page or the Wiki for QB64 or maybe it's in his signature or maybe someone can paste one up here directly, I can't find mine at moment.

Here is Wiki which you might bookmark anyway on your browser (if you hadn't already), very handy!
https://www.qb64.org/wiki/Main_Page
Title: Re: Sprite Library Revisited
Post by: TempodiBasic on December 04, 2020, 08:40:56 pm
Hi Madscijr
welcome to the forum
here a link to the tutorial for game programming of Terry
https://www.qb64.org/forum/index.php?topic=3204.0 (https://www.qb64.org/forum/index.php?topic=3204.0)
here one of the last post of Terry
https://www.qb64.org/forum/index.php?topic=2264.msg114989#msg114989 (https://www.qb64.org/forum/index.php?topic=2264.msg114989#msg114989)
Title: Re: Sprite Library Revisited
Post by: bplus on December 04, 2020, 09:12:19 pm
Found it! Terry's Tutorial: https://www.qb64sourcecode.com

? I thought it was on Home page and at Wiki but couldn't find at either.
Title: Re: Sprite Library Revisited
Post by: FellippeHeitor on December 04, 2020, 09:20:40 pm
Found it! Terry's Tutorial: https://www.qb64sourcecode.com

? I thought it was on Home page and at Wiki but couldn't find at either.

Link to Terry's tutorial is in the wiki's landing page.
Title: Re: Sprite Library Revisited
Post by: bplus on December 04, 2020, 11:01:46 pm
Yeah now I see it on Wiki.