Author Topic: Neko the Cat!  (Read 5211 times)

0 Members and 1 Guest are viewing this topic.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Neko the Cat!
« on: October 02, 2018, 11:25:06 am »
Here's another little example program showing what the sprite library can do so far. Some of you may remember Neko from 1990 and Windows 3.0. He was a little cat that would run around on the screen and chase the mouse pointer. I've recreated him here for your enjoyment. You'll need the Neko sprite sheet included below.

The further up the screen you make Neko run, the farther in the distance he goes. The further down the screen, the closer he gets.

Neko will:

- Randomly start with a different cat breed (White Angola, Black Spooky, Calico, Siamese)
- Chase the mouse pointer around. If you make him chase too long he'll take a nap.
- React to being clicked on while sleeping or sitting.
- Scratch at the mouse if it is close enough or you move the mouse off screen then he scratches at the edge of the screen.
- Randomly clean himself and take naps.
- Resume chasing the mouse pointer if he feels like it.

Basically, he acts like a real finicky cat would.

While creating this little demo it highlighted some more bugs I had to work out in the library's code. I completely removed anything software related to sprites. All sprites are now hardware based. I still need to code in software objects for interaction with the library's software layers. I also realized a few more commands needed while creating the demo.

Let me know what you think.

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

FellippeHeitor

  • Guest
Re: Neko the Cat!
« Reply #1 on: October 02, 2018, 12:48:32 pm »
This is adorable! I can't be playing with kittens at work! Make it stahp!

I'll seriously get to studying this sample tonight, thanks for sharing, Terry!

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Neko the Cat!
« Reply #2 on: October 02, 2018, 01:11:56 pm »
I found myself playing with the cat way too much as well when I was coding and debugging it. Addictive. :)
In order to understand recursion, one must first understand recursion.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Neko the Cat!
« Reply #3 on: October 02, 2018, 04:12:13 pm »
Hey very cute!

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Neko the Cat!
« Reply #4 on: October 03, 2018, 02:09:23 am »
Line 446 in SUB ChaseThe (mouse, neko) should read:

Code: QB64: [Select]
  1.     mouseangle = SL_GET_ANGLE_TO_SPRITE(neko, mouse)

I forgot to change that before uploading

Edit: I changed the code above in the original post.
« Last Edit: October 03, 2018, 12:01:03 pm by TerryRitchie »
In order to understand recursion, one must first understand recursion.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Neko the Cat!
« Reply #5 on: October 03, 2018, 03:05:31 am »
That's the cat's ASCII!

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

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Neko the Cat!
« Reply #6 on: October 03, 2018, 11:56:51 am »
That's the cat's ASCII!

Pete :D

LOL, your comments always crack me up.

Quote
Totally awesome!!!!  Thank you TerryRitchie!

You're welcome :)
In order to understand recursion, one must first understand recursion.

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Neko the Cat!
« Reply #7 on: October 03, 2018, 10:29:08 pm »
This is neat, Terry!  Nice work.  Your sprite library is looking great!

- Dav

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Neko the Cat!
« Reply #8 on: October 04, 2018, 09:32:49 am »
Hi Terry
Neko the cat is very beautyfull!

And you have waked up in my mind another windows' cat: Felix.
see here https://i.ytimg.com/vi/QfYy89F2uHk/hqdefault.jpg
and here https://www.youtube.com/watch?v=SqII8cvJWpA
and here https://www.youtube.com/watch?v=QfYy89F2uHk
be careful for your ears!

Thanks

Programming isn't difficult, only it's  consuming time and coffee