Author Topic: Sprite Library Revisited  (Read 26741 times)

0 Members and 1 Guest are viewing this topic.

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
Re: Sprite Library Revisited
« Reply #30 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.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Sprite Library Revisited
« Reply #31 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.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #32 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
In order to understand recursion, one must first understand recursion.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #33 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.
In order to understand recursion, one must first understand recursion.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Sprite Library Revisited
« Reply #34 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.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #35 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.
« Last Edit: September 23, 2018, 04:29:57 pm by TerryRitchie »
In order to understand recursion, one must first understand recursion.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Sprite Library Revisited
« Reply #36 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.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Sprite Library Revisited
« Reply #37 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.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #38 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.  
In order to understand recursion, one must first understand recursion.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #39 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.  
dkong.png
* dkong.png (Filesize: 9.14 KB, Dimensions: 512x576, Views: 111)
« Last Edit: September 25, 2018, 07:56:20 pm by TerryRitchie »
In order to understand recursion, one must first understand recursion.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Sprite Library Revisited
« Reply #40 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.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #41 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.
In order to understand recursion, one must first understand recursion.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #42 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.  
« Last Edit: September 27, 2018, 12:14:29 am by TerryRitchie »
In order to understand recursion, one must first understand recursion.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #43 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.
« Last Edit: September 28, 2018, 03:51:22 pm by TerryRitchie »
In order to understand recursion, one must first understand recursion.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • Steve’s QB64 Archive Forum
Re: Sprite Library Revisited
« Reply #44 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?)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!