Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - TerryRitchie

Pages: 1 [2] 3 4
16
QB64 Discussion / Qb64 Editor having trouble resizing
« on: March 04, 2020, 03:14:35 am »
Has this happened to any one else? Sometimes when I start the editor (perhaps 1 out of 100 times) it will flash rapidly between the default size and the size I set it to previously perhaps 20 or so times and just give up and return to the default size.

I believe I've noticed a pattern to this as well. If I set the size manually using values in the editor I don't believe I've ever noticed this behavior when I restart the editor. However, if I resize the editor using the mouse by dragging the sides or corners then upon restart this behavior may happen.

By the way this is happening in version 1.3. I have not moved everything fully over to 1.4 yet which may have had this issue resolved.

17
Programs / QB64 Simon
« on: February 29, 2020, 10:46:46 pm »
I was going through some of my old code and came across the Simon game I created back in 2015. I don't believe I ever posted it here. It's an exact replica of the Simon game from the 1980's (well, I added the QB64 bee graphic).

Game play can be done with keyboard, mouse, or both. Press F1 for a help screen.

The .ZIP file below contains the source code and asset files needed to compile and play the game.

18
Programs / Vector Library and WideScreen Asteroids
« on: February 05, 2020, 11:13:16 pm »
---------------------------------------
UPDATE 02/11/20 9:21PM EST
Updated the .ZIP file below again. I made it to level 12 and ... crash. Found the bug and fixed it. The maximum asteroids that can ever be on the screen at once in a perfect scenario is 64 (16 large asteroids times 4 small asteroids). I set the asteroids array to 63 when it should have been 64. Oops.
---------------------------------------
UPDATE 02/07/20 3:15PM EST
The .ZIP has again been updated. The Button function has been completely rewritten to use the vector library's ObjPrint vector text command instead. _PRINTSTRING is just way too resource heavy to be used in real-time menus. Also made a few more efficiency changes. No matter how many objects on the screen now the drop down menu does not slow anything down.
---------------------------------------
UPDATE 02/06/20 11:15PM EST
I updated the .ZIP file below with a bug fixed and some inefficiencies in the collision routines I corrected. I also removed the pre-compiled .EXE to make the .ZIP file smaller.
---------------------------------------

Sorry I have been away for so long but I come bearing gifts :-)

I had to put the Sprite library on the back-burner because of unforeseen problems I encountered with it. Because of that I decided to step away from programming for a bit. When I got my head on straight again I decided to write a vector library. Of course I need to write a game to prove the library so I wrote Widescreen Asteroids.

Widescreen Asteroids is not a clone. It's what I always wanted in an Asteroids game. It's very close to the original with a few enhancements. The vector engine is fast so the game is filled with particle effects and, of course, asteroids. I hope you'll like the game. Please report any bugs or errors you find in the game.

I don't have documentation written yet for the vector library. Below is a crude listing of commands that it supports. I'll have the documentation finished soon.

The ZIP file contains everything needed to run and compile the game. It contains a pre-compiled .EXE so you can run the game right away if you wish. If you prefer to compile yourself simply delete "asteroids.exe".

--- CRUDE COMMAND LISTING FOR VECTOR LIBRARY ---

Sub         ObjActive   ObjID, Flag               Sets the active value of an object
Sub         ObjAngle   ObjID, Angle            Set the angle of an object
Sub         ObjBind      ObjID, X1, Y1, X2, Y2, Mode   Set the minimum X and Y coordinates allowed for object
Sub         ObjColor   ObjID, Lnumber, Clr         Set or reset the color for one or all line segments within an object
Sub         ObjDraw      ObjID                  Draw an object to the screen
Sub         ObjFriction   ObjID, Friction            Set the friction amount for an object
Sub         ObjInit                           Initialize variables for object library
Sub         ObjLines   ObjID                  Get all line info from an object at current angle (INTERNAL USE ONLY)
Sub         ObjMove      ObjID                  Update an object's position based on all current values
Sub         ObjPrint   tx, tx, Text, Scale, Clr   Print vector text at the coordinates specified
Sub         ObjPush      ObjID, Force            Push an object in its current direction
Sub         ObjPut      ObjID, X, Y               Set the X,Y coordinates of an object
Sub         ObjRotate   ObjID, Angle, Mode         Rotate an object to either absolute or relative angle, or auto rotate
Sub         ObjScale   ObjID, Scale            Set the X and Y scale of an object
Sub         ObjScaleX   ObjID, Scale            Set the X scale of an object
Sub         ObjScaleY   ObjID, Scale            Set the Y scale of an object
Sub         ObjStamp   ObjID, x, y, Angle, Scale, Clr   Place a copy of an object on-screen
Sub         ObjVectorX   ObjID, XV               Set the X vector value for an object
Sub         ObjVectorY   ObjID, YV               Set the Y vector value for an object

Function   ObjActive   ObjID                  Get the active value of an object
Function   ObjAngle   ObjID                  Get current angle of object
Function    ObjAngleO2O   ObjID1, ObjID1            Get the angle between two object center points
Function   ObjAngleP2P   x1, y1, x2, y2            Get the angle between two X,Y coordinate pairs
Function   ObjBoxHit   ObjID1, ObjID2            Return TRUE if two objects touching via bounding boxes
Function   ObjColor   ObjID, Lnumber            Get color of line within object
Function   ObjDistO2O   ObjID1, ObjID2            Get distance between center point of two objects
Function   ObjDistP2P   x1, y1, x2, y2            Get distance between two X,Y coordinate pairs
Function   ObjFixAngle   Angle                  Return the angle passed in from 0 to 360
Function   ObjFriction   ObjID                  Get current friction of object
Function   ObjHeight   ObjID                  Get current height of object
Function   ObjIntersect   p1x, p1y, q1x, q1y, p2x, p2y, q2x, q2y   Return TRUE if two line segments are intersecting
Function   ObjLineHit   ObjID, p2x, p2y, q2x,q2y   Return TRUE if a line segment is touching an object
Function   ObjLoad      File                  Load an object file into memory
Function   ObjObjectHit   ObjID1, ObjID2         Return TRUE if any line segments in two objects touch
Function   ObjMake      ObjID                  Make an object from objects in memory
Function   ObjMax      n1, n2                  Return the largest of two numbers
Function   ObjMaxX      ObjID                  Get maximum X coordinate allowed for object
Function   ObjMaxY      ObjID                  Get maximum Y coordinate allowed for object
Function   ObjMin      n1, n2                  Return the smallest of two numbers
Function   ObjMinX      ObjID                  Get minimum X coordinate allowed for object
Function   ObjMinY      ObjID                  Get minimum Y coordinate allowed for object
Function   ObjNCosine   Angle                  Get the cosine value of a negative angle
Function   ObjNSine   Angle                  Get the sine value of a negative angle
Function   OBJPCosine   Angle                  Get the cosine value of a positive angle
Function   ObjPSine   Angle                  Get the since value of a positive angle
Function   ObjRadius   ObjID                  Get current radius of object
Function   ObjRadiusHit   ObjID1, ObjID2         Return TRUE if two objects touching via radii distance
Function   ObjScale   ObjID                  Get scale of object if X and Y scales are the same, otherwise -1
Function   ObjScaleX   ObjID                  Get X scale of object
Function   ObjScaleY   ObjID                  Get Y scale of object
Function   ObjSpeed   ObjID                  Get current speed of object
Function   ObjVectorX   ObjID                  Get current X vector of object
Function   ObjVectorY   ObjID                  Get current Y vector of object
Function   ObjX      ObjID                  Get current X coordinate of object
Function   ObjX1      ObjID, Lnumber            Get start X coordinate of line within object
Function   ObjX2      ObjID, Lnumber            Get end X coordinate of line within object
Function   ObjY      ObjID                  Get current Y coordinate of object
Function   ObjY1      ObjID, Lnumber            Get start Y coordinate of line within object
Function   ObjY2      ObjID, Lnumber            Get end Y coordinate of line within object
Fucntion   ObjWidth   ObjID                  Get current width of object
Function   onSegment   p, q, r                  Return TRUE if point q lies on line segment pr (INTERNAL USE ONLY)
Function   Orientation   p, q, r                  Returns orientation of ordered triplet pair (INTERNAL USE ONLY)

19
QB64 Discussion / The future of QB64
« on: October 30, 2018, 05:37:31 pm »
The following article is a good read: https://www.tomshardware.com/news/play-windows-games-linux-steam-play,37990.html

Back in 2015 Valve was sounding the alarm that Microsoft's intention is to one day only allow Microsoft approved apps to be installed on Windows computers through the Windows store. To this end Valve became heavily involved in the Linux community helping to develop WINE further so more PC games could be played on the Linux platform. For years this looked like it had stalled but as the above article highlights they have come a long way.

So why do I bring this up? Well, when the switch to approved only apps happens this means that programs will need to be in the UWP (Universal Windows Platform) format leaving QB64 out in the cold. My guess is, and this is just my opinion, this change will happen soon after Windows 7 end of life. I'm sure at first traditional software will be allowed in the store but over time, slowly but surely, legacy software will be pushed aside in favor of UWP.

The future of QB64 after that? In one word ... Linux. Valve increasingly making it more popular for gamers to move to Linux will mean that soon after Windows 7 end of life we'll probably see an influx of users to Linux. Over time (with any luck) Windows will become a wasteland of Windows store apps that no one wants and Windows itself will become a has-been (Zune anyone?).

My point, I believe more development in the Linux arena should be considered now for the future of QB64. We'll see how this pans out 5 years from now, but my humble guess is this will happen and it's going to be ugly.

20
QB64 Discussion / Color Constants
« on: October 18, 2018, 12:41:20 am »
Hey everyone, I could have swore I saw a file someone made of CONSTant values for common colors.

Something like:

CONST RED = &HFF0000
CONST YELLOW = &HFFFF00
CONST GOLDENROD = &HDAA520

etc..

However, after searching the site I can't seem to find it. Was I seeing things? If you are the person that posted it could you please point me to the post?

Thanks everyone :)

21
Programs / Sprite Library Layering
« on: October 08, 2018, 03:45:38 pm »
I was having a few really hard to track down issues with layering so I decided to break the sprite library into modules for easy debugging and coding. This is the library control and layering routines section. I have all the layering issues sorted out now and the little parallax demo below shows how easy the layers are to manipulate.

You can move the mouse to the right or left on the image to get the scrolling to change direction.

You'll need the layers.zip file as well that contains 7 layer images.

Code: QB64: [Select]
  1.  
  2.  
  3. CONST SL_ALL = -32767
  4. CONST SL_VALID = -32766
  5. CONST SL_DEST = -32765
  6. CONST SL_SOURCE = -32764
  7. CONST SL_VISIBLE = -32763
  8. CONST SL_INVISIBLE = -32762
  9. CONST SL_LEFT = -32761
  10. CONST SL_TOP = -32760
  11. CONST SL_RIGHT = -32759
  12. CONST SL_BOTTOM = -32758
  13. CONST SL_CENTERX = -32757
  14. CONST SL_CENTERY = -32756
  15. CONST SL_WIDTH = -32755
  16. CONST SL_HEIGHT = -32754
  17. CONST SL_GET = -32753
  18. CONST SL_TOTAL = -32752
  19. CONST SL_UP = -32751
  20. CONST SL_DOWN = -32750
  21. CONST SL_UPRIGHT = -32749
  22. CONST SL_DOWNRIGHT = -32748
  23. CONST SL_DOWNLEFT = -32747
  24. CONST SL_UPLEFT = -32746
  25.  
  26.  
  27.  
  28. TYPE SL_RECT '                          RECTANGULAR OBJECT PROPERTIES
  29.     left AS INTEGER
  30.     top AS INTEGER
  31.     right AS INTEGER
  32.     bottom AS INTEGER
  33.     centerx AS INTEGER
  34.     centery AS INTEGER
  35.     height AS INTEGER
  36.  
  37. TYPE SL_ROUND
  38.     centerx AS INTEGER
  39.     centery AS INTEGER
  40.     radius AS INTEGER
  41.  
  42. TYPE SL_LAYERS ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ LAYER DATABASE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  43.     image AS LONG '                     software image of screen layer
  44.     visible AS INTEGER '                -1 (TRUE) if layer is visible
  45.     dest AS INTEGER '                   -1 (TRUE) if layer is destination   ** needed? **
  46.     source AS INTEGER '                 -1 (TRUE) if layer is source        ** needed? **
  47. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  48.  
  49. TYPE SL_GLOBAL ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ GLOBALS DATABASE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  50.     screen AS SL_RECT '                 screen coordinate properties
  51.     framerate AS INTEGER '              global frame rate
  52.     source AS INTEGER '                 current source layer                        0 - x, 0 for main screen, -1 if no layer is a source
  53.     destination AS INTEGER '            current destination layer                   0 - x, 0 for main screen, -1 if no layer is a destination
  54. END TYPE ' ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  55.  
  56. REDIM SL_layer(1) AS SL_LAYERS '       master layer array
  57. DIM SL_global AS SL_GLOBAL '            common globals
  58.  
  59.  
  60. ' main program (for testing)
  61.  
  62.  
  63. DIM layer AS INTEGER
  64. DIM direction AS INTEGER
  65.  
  66.  
  67. SL_WINDOW 960, 540, 7
  68.  
  69. SL_SET_LAYER 7, SL_DEST
  70. _PUTIMAGE , _LOADIMAGE("layer7.png", 32)
  71. SL_SET_LAYER 6, SL_DEST
  72. _PUTIMAGE , _LOADIMAGE("layer6.png", 32)
  73. SL_SET_LAYER 5, SL_DEST
  74. _PUTIMAGE , _LOADIMAGE("layer5.png", 32)
  75. SL_SET_LAYER 4, SL_DEST
  76. _PUTIMAGE , _LOADIMAGE("layer4.png", 32)
  77. SL_SET_LAYER 3, SL_DEST
  78. _PUTIMAGE , _LOADIMAGE("layer3.png", 32)
  79. SL_SET_LAYER 2, SL_DEST
  80. _PUTIMAGE , _LOADIMAGE("layer2.png", 32)
  81. SL_SET_LAYER 1, SL_DEST
  82. _PUTIMAGE , _LOADIMAGE("layer1.png", 32)
  83.  
  84.     _LIMIT 30
  85.     IF _MOUSEX < SL_GET_SCREEN(SL_CENTERX) THEN direction = SL_RIGHT ELSE direction = SL_LEFT
  86.     FOR layer = 1 TO 7
  87.         SL_SHIFT_LAYER layer, direction, 8 - layer
  88.     NEXT layer
  89.     SL_DISPLAY
  90.  
  91. SL_QUIT
  92.  
  93.  
  94.  
  95.  
  96. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  97. '                                                                    ----------==========                         ==========----------
  98. '                                                                    ----------========== LIBARY CONTROL ROUTINES ==========----------
  99. '                                                                    ----------==========                         ==========----------
  100. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  101.  
  102. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  103. SUB SL_WINDOW (swidth AS INTEGER, sheight AS INTEGER, layers AS INTEGER) '                                                                                                                    SL_WINDOW
  104.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  105.  
  106.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  107.     SHARED SL_global AS SL_GLOBAL '     common globals
  108.     DIM layer AS INTEGER '              layer counter
  109.  
  110.     IF layers < 1 THEN '                                                                                creating at least one layer?
  111.         SL_error "SL_WINDOW", 1, "" '                                                                   no, report error to programmer
  112.     END IF
  113.     IF swidth < 1 OR sheight < 1 THEN '                                                                 window width and/or height greater than zero?
  114.         SL_error "SL_WINDOW", 2, "" '                                                                   no, report error to programmer
  115.     END IF
  116.     REDIM SL_layer(layers) AS SL_LAYERS '                                                               increase layer array to match requested number of layers
  117.     SL_global.screen.width = swidth '                                                                   save screen dimensions
  118.     SL_global.screen.height = sheight
  119.     SL_global.screen.top = 0
  120.     SL_global.screen.left = 0
  121.     SL_global.screen.right = swidth - 1
  122.     SL_global.screen.bottom = sheight - 1
  123.     SL_global.screen.centerx = swidth \ 2 - 1
  124.     SL_global.screen.centery = sheight \ 2 - 1
  125.     layer = 0 '                                                                                         reset layer counter
  126.     DO '                                                                                                cycle through layers
  127.         layer = layer + 1 '                                                                             increment layer counter
  128.         SL_layer(layer).image = _NEWIMAGE(swidth, sheight, 32) '                                        create layer software image
  129.         SL_layer(layer).visible = -1 '                                                          (TRUE)  layer is visible
  130.     LOOP UNTIL layer = UBOUND(SL_layer) '                                                               leave when all layers created
  131.     SCREEN _NEWIMAGE(swidth, sheight, 32) '                                                             initialize working screen
  132.     SL_SET_LAYER 1, SL_DEST '                                                                           set layer 1 as the destination
  133.     SL_SET_LAYER 1, SL_SOURCE '                                                                         set layer 1 as the source
  134.  
  135.  
  136. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  137. SUB SL_DISPLAY () '                                                                                                                                                                          SL_DISPLAY
  138.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  139.  
  140.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  141.     SHARED SL_global AS SL_GLOBAL '     common globals array
  142.     DIM layer AS INTEGER '              layer counter
  143.     DIM merge AS LONG '                 software image to merge all layers onto
  144.     DIM hwimage AS LONG '               final hardware image of merged layers
  145.  
  146.     merge = _NEWIMAGE(SL_global.screen.width, SL_global.screen.height, 32) '                            create image to merge layers
  147.     layer = UBOUND(SL_layer) '                                                                          start with the highest numbered layer
  148.  
  149.     DO '                                                                                                cycle through layers backwards (high to low)
  150.         IF SL_layer(layer).visible THEN '                                                               is this layer visible?
  151.             _PUTIMAGE , SL_layer(layer).image, merge '                                                  place this layer onto merge image
  152.         END IF
  153.         layer = layer - 1 '                                                                             decrement layer counter
  154.     LOOP UNTIL layer = 0 '                                                                              leave when all layers merged
  155.     hwimage = _COPYIMAGE(merge, 33) '                                                                   create hardware image of merged layers
  156.     _PUTIMAGE , hwimage, 0 '                                                                            place hardware image on main screen
  157.     _FREEIMAGE merge '                                                                                  merged software image no longer needed
  158.     _FREEIMAGE hwimage '                                                                                merged hardware image no longer needed
  159.  
  160.     '*
  161.     '* SL_draw_sprites '                                                                                   draw all sprites in use <---------------------------------------------------- LOOK
  162.     '*
  163.  
  164.     _DISPLAY '                                                                                          update display screen with changes
  165.  
  166.  
  167. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  168. SUB SL_QUIT () '                                                                                                                                                                                SL_QUIT
  169.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  170.  
  171.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  172.     DIM count AS INTEGER '              layer counter
  173.  
  174.     SCREEN 0, 0, 0, 0 '                                                                                 go to a text screen
  175.     DO '                                                                                                cycle through layers
  176.         count = count + 1 '                                                                             increment layer counter
  177.         _FREEIMAGE SL_layer(count).image '                                                              remove layer image from meory
  178.     LOOP UNTIL count = UBOUND(SL_layer) '                                                               leave when all layers removed
  179.     SYSTEM '                                                                                            return to OS
  180.  
  181.  
  182. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  183. SUB SL_SET_SCREEN (x AS INTEGER, y AS INTEGER) '                                                                                                                                          SL_SET_SCREEN
  184.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  185.  
  186.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  187.     SHARED SL_global AS SL_GLOBAL '     common globals array
  188.     DIM osource AS LONG '               original source
  189.     DIM odest AS LONG '                 original destination
  190.     DIM temp AS LONG '                  temporary screen and layer image
  191.     DIM current AS LONG '               current screen and layer image
  192.     DIM layer AS INTEGER '              layer counter
  193.     DIM source AS INTEGER '             -1 (TRUE) if layer is the source
  194.     DIM destination AS INTEGER '        -1 (TRUE) if layer is the destination
  195.  
  196.     IF (x < 1) OR (y < 1) THEN SL_error "SL_SET_SCREEN", 9, "" '                                        report error to programmer
  197.  
  198.     ' change the screen's dimensions
  199.  
  200.     osource = _SOURCE '                                                                                 save current source
  201.     odest = _DEST '                                                                                     save current destination
  202.     _SOURCE 0 '                                                                                         set screen as the source
  203.     _DEST 0 '                                                                                           set screen as the destination
  204.     current = _SOURCE '                                                                                 get current screen source handle
  205.     temp = _COPYIMAGE(current, 32) '                                                                    make a copy of the screen
  206.     SCREEN temp '                                                                                       make the copy the current screen
  207.     _FREEIMAGE current '                                                                                remove the old screen from memory
  208.     'currentscreen = _NEWIMAGE(x, y, 32)
  209.     'SCREEN currentscreen
  210.     '_PUTIMAGE (0, 0), tempscreen, currentscreen
  211.     SCREEN _NEWIMAGE(x, y, 32) '                                                                        create the new screen with new dimensions
  212.     _PUTIMAGE , temp '                                                                                  put the old screen image back on top
  213.     _FREEIMAGE temp '                                                                                   remove the temporary image from memory
  214.     _DEST odest '                                                                                       restore the original destination
  215.     _SOURCE osource '                                                                                   restore the original source
  216.     SL_global.screen.width = x '                                                                        save screen dimensions
  217.     SL_global.screen.height = y
  218.     SL_global.screen.top = 0
  219.     SL_global.screen.left = 0
  220.     SL_global.screen.right = x - 1
  221.     SL_global.screen.bottom = y - 1
  222.     SL_global.screen.centerx = x \ 2 - 1
  223.     SL_global.screen.centery = y \ 2 - 1
  224.  
  225.     ' change each layer's dimensions to match new screen dimensions
  226.  
  227.     layer = 0 '                                                                                         reset layer counter
  228.     DO '                                                                                                cycle through all layers
  229.         layer = layer + 1 '                                                                             increment layer counter
  230.         source = 0 '                                                                                    reset source indicator
  231.         destination = 0 '                                                                               reset destination indicator
  232.         temp = _NEWIMAGE(1, 1, 32) '                                                                    create a tempory source and destination place holder
  233.         IF _SOURCE = SL_layer(layer).image THEN _SOURCE temp: source = -1 '                             remember that this layer is the source
  234.         IF _DEST = SL_layer(layer).image THEN _DEST temp: destination = -1 '                            remember that this layer is the destination
  235.         current = _COPYIMAGE(SL_layer(layer).image, 32) '                                               make a copy of the layer's image
  236.         _FREEIMAGE SL_layer(layer).image '                                                              remove current layer from memory
  237.         SL_layer(layer).image = _NEWIMAGE(SL_global.screen.width, SL_global.screen.height, 32) '        create new layer image
  238.         _PUTIMAGE (0, 0), current, SL_layer(layer).image '                                              put the old layer image back on top
  239.         _FREEIMAGE current '                                                                            remove old layer image from memory
  240.         _FREEIMAGE temp '                                                                               remove temporary image from memory
  241.         IF source THEN _SOURCE SL_layer(layer).image '                                                  this was source, set it back
  242.         IF destination THEN _DEST SL_layer(layer).image '                                               this was destination, set it back
  243.     LOOP UNTIL layer = UBOUND(SL_layer)
  244.  
  245.  
  246. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  247. FUNCTION SL_GET_SCREEN (value AS INTEGER) ' (MULTI_FUNCTION COMMAND)                                                                                                                      SL_GET_SCREEN
  248.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  249.  
  250.     ' sl_get_screen(sl_width)
  251.     ' sl_get_screen(sl_height)
  252.     ' sl_get_screen(sl_centerx)
  253.     ' sl_get_screen(sl_centery)
  254.     ' sl_get_screen(sl_top)
  255.     ' sl_get_screen(sl_left)
  256.     ' sl_get_screen(sl_bottom)
  257.     ' sl_get_screen(sl_right)
  258.  
  259.     SHARED SL_global AS SL_GLOBAL '     common globals array
  260.  
  261.     SELECT CASE value '                                                                                 yes, which one?
  262.         CASE SL_WIDTH '                                                                                 screen width
  263.             SL_GET_SCREEN = SL_global.screen.width '                                                    return the screen width
  264.         CASE SL_HEIGHT '                                                                                screen height
  265.             SL_GET_SCREEN = SL_global.screen.height '                                                   return the screen height
  266.         CASE SL_CENTERX '                                                                               screen x center location
  267.             SL_GET_SCREEN = SL_global.screen.centerx '                                                  return x center location
  268.         CASE SL_CENTERY '                                                                               screen y center location
  269.             SL_GET_SCREEN = SL_global.screen.centery '                                                  return y center location
  270.         CASE SL_TOP '                                                                                   upper y location
  271.             SL_GET_SCREEN = SL_global.screen.top '                                                      return upper y location
  272.         CASE SL_LEFT '                                                                                  left x location
  273.             SL_GET_SCREEN = SL_global.screen.left '                                                     return left x location
  274.         CASE SL_BOTTOM '                                                                                bottom y location
  275.             SL_GET_SCREEN = SL_global.screen.bottom '                                                   return bottom y location
  276.         CASE SL_RIGHT '                                                                                 right x location
  277.             SL_GET_SCREEN = SL_global.screen.right '                                                    return right x location
  278.         CASE ELSE '                                                                                     unknown error?
  279.             SL_error "SL_GET_SCREEN", 10, "" '                                                          report error to programmer
  280.     END SELECT
  281.  
  282.  
  283.  
  284. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  285. '                                                                       ----------==========                ==========----------
  286. '                                                                       ----------========== LAYER ROUTINES ==========----------
  287. '                                                                       ----------==========                ==========----------
  288. 'ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  289.  
  290.  
  291. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  292. FUNCTION SL_GET_LAYER (layer AS INTEGER, action AS INTEGER) ' (MULTI-FUNCTION COMMAND)                                                                                                     SL_GET_LAYER
  293.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  294.  
  295.     ' usage:
  296.     '           value = SL_GET_LAYER(SL_GET, SL_DEST)       return the value of current destination layer           returns the value of the destination layer, 0 if no destination exists
  297.     '           value = SL_GET_LAYER(SL_GET, SL_SOURCE)     return the value of the current source layer            returns the value of the source layer, 0 if no source exists
  298.     '           value = SL_GET_LAYER(SL_GET, SL_TOTAL)      return the total number of layers available             returns the total number of layers
  299.     '           value = SL_GET_LAYER(x, SL_DEST)            test if the specified layer is the destination          returns -1 if layer is destination, 0 otherwise
  300.     '           value = SL_GET_LAYER(x, SL_SOURCE)          test if the specified layer is the source               returns -1 if layer is source, otherwise 0
  301.     '           value = SL_GET_LAYER(x, SL_VALID)           return either -1 or 0 depending on layer x being valid  returns -1 if layer is valid, 0 if layer is invalid
  302.  
  303.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  304.     SHARED SL_global AS SL_GLOBAL '     common globals array
  305.  
  306.     SELECT CASE action '                                                                                which action was requested?
  307.         CASE SL_VALID '                                                                                 check for valid layer
  308.             IF layer = SL_GET THEN SL_error "SL_GET_LAYER", 3, "" '                                     report error to programmer
  309.             IF (layer > 0) AND (layer <= UBOUND(SL_layer)) THEN SL_GET_LAYER = -1 '                     if layer valid then return -1
  310.         CASE SL_DEST '                                                                                  get destination layer
  311.             IF layer = SL_GET THEN '                                                                    getting the destination layer?
  312.                 IF SL_global.destination <> -1 THEN '                                                   yes, are one of the layers set as a destination?
  313.                     IF _DEST = SL_layer(SL_global.destination).image THEN '                             yes, is this layer actually still the destination?
  314.                         SL_GET_LAYER = SL_global.destination '                                          yes, report current destination layer
  315.                     ELSE '                                                                              no, the programmer changed the destination to something else
  316.                         SL_layer(SL_global.destination).dest = 0 '                                      mark this layer as not the destination layer any longer
  317.                         SL_global.destination = -1 '                                                    set that there are currently no layers set to destination
  318.                     END IF
  319.                 END IF
  320.             ELSE '                                                                                      no, checking one layer for destination
  321.                 IF NOT SL_GET_LAYER(layer, SL_VALID) THEN SL_error "SL_GET_LAYER", 6, "" '              report error to programmer                      (function recursion)
  322.                 IF SL_GET_LAYER(SL_GET, SL_DEST) = layer THEN SL_GET_LAYER = -1 '                       report this layer is the current destination    (function recursion)
  323.             END IF
  324.         CASE SL_SOURCE '                                                                                get source layer
  325.             IF layer = SL_GET THEN '                                                                    getting the source layer?
  326.                 IF SL_global.source <> -1 THEN '                                                        yes, are one of the layers set as a source?
  327.                     IF _SOURCE = SL_layer(SL_global.source).image THEN '                                yes, is this layer actually still the source?
  328.                         SL_GET_LAYER = SL_global.source '                                               yes, report current source layer
  329.                     ELSE '                                                                              no, the programmer changed the source to something else
  330.                         SL_layer(SL_global.source).source = 0 '                                         mark this layer as not the source layer any longer
  331.                         SL_global.source = -1 '                                                         set that there are currently no layers set to source
  332.                     END IF
  333.                 END IF
  334.             ELSE '                                                                                      no, checking one layer for source
  335.                 IF NOT SL_GET_LAYER(layer, SL_VALID) THEN SL_error "SL_GET_LAYER", 6, "" '              report error to programmer                      (function recursion)
  336.                 IF SL_GET_LAYER(SL_GET, SL_SOURCE) = layer THEN SL_GET_LAYER = -1 '                     report this layer is the current source         (function recursion)
  337.             END IF
  338.         CASE SL_TOTAL
  339.             IF layer <> SL_GET THEN SL_error "SL_GET_LAYER", 11, "" '                                   report error to programmer
  340.             SL_GET_LAYER = UBOUND(SL_layer) '                                                           return total number of layers present
  341.         CASE ELSE '                                                                                     command not formatted properly
  342.             SL_error "SL_GET_LAYER", 5, "" '                                                            report error to programmer
  343.     END SELECT
  344.  
  345.  
  346. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  347. SUB SL_CLEAR_LAYER (layer AS INTEGER) '                                                                                                                                                  SL_CLEAR_LAYER
  348.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  349.  
  350.     ' usage:
  351.     '           SL_CLEAR_LAYER x             clear layer x
  352.     '           SL_CLEAR_LAYER SL_ALL        clear all layers
  353.  
  354.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  355.     SHARED SL_global AS SL_GLOBAL '     common globals array
  356.     DIM count AS INTEGER '              layer counter
  357.     DIM temp AS LONG '                  temp source/destination image
  358.     DIM source AS INTEGER '             -1 (TRUE) if current layer is the source
  359.     DIM destination AS INTEGER '        -1 (TRUE) if current layer is the destination
  360.  
  361.     IF layer <> SL_ALL THEN '                                                                           clear all layers?
  362.         IF NOT SL_GET_LAYER(layer, SL_VALID) THEN SL_error "SL_CLEAR_LAYER", 6, "" '                    report error to programmer
  363.         count = layer '                                                                                 no, just clear this one layer
  364.     ELSE '                                                                                              yes, clear all layers
  365.         count = 1 '                                                                                     start with first layer
  366.     END IF
  367.     temp = _NEWIMAGE(1, 1, 32) '                                                                        great a temp image for source / destination
  368.     DO '                                                                                                cycle through layer(s)
  369.         source = 0 '                                                                                    reset source indicator
  370.         destination = 0 '                                                                               reset destination indicator
  371.         IF _SOURCE = SL_layer(count).image THEN _SOURCE temp: source = -1 '                             remember that this layer is the source
  372.         IF _DEST = SL_layer(count).image THEN _DEST temp: destination = -1 '                            remember that this layer is the destination
  373.         _FREEIMAGE SL_layer(count).image '                                                              remove current layer from memory
  374.         SL_layer(count).image = _NEWIMAGE(SL_global.screen.width, SL_global.screen.height, 32) '        create new layer image
  375.         IF source THEN _SOURCE SL_layer(count).image '                                                  this was source, set it back
  376.         IF destination THEN _DEST SL_layer(count).image '                                               this was destination, set it back
  377.         count = count + 1 '                                                                             increment layer counter
  378.     LOOP UNTIL count = UBOUND(SL_layer) + 1 OR layer <> SL_ALL '                                        leave when layer(s) cleared
  379.     _FREEIMAGE temp '                                                                                   remove temp image from memory
  380.  
  381.  
  382. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  383. SUB SL_SET_LAYER (layer AS INTEGER, action AS INTEGER) ' (MULTI-FUNCTION COMMAND)                                                                                                          SL_SET_LAYER
  384.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  385.  
  386.     ' usage:
  387.     '           SL_SET_LAYER(x, SL_DEST)            set layer x as destination
  388.     '           SL_SET_LAYER(x, SL_SOURCE)          set layer x as the source
  389.     '           SL_SET_LAYER(x, SL_VISBILE)         set layer x as visible
  390.     '           SL_SET_LAYER(SL_ALL, SL_VISIBLE)    set all layers as visible
  391.     '           SL_SET_LAYER(x, SL_INVISIBLE)       set layer x as invisible
  392.     '           SL_SET_LAYER(SL_ALL, SL_INVISIBLE)  set all layers as invisible
  393.  
  394.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  395.     SHARED SL_global AS SL_GLOBAL '     common globals array
  396.     DIM count AS INTEGER '              layer counter
  397.     DIM visibility AS INTEGER '         layer visibility status
  398.  
  399.     IF layer <> SL_ALL THEN IF NOT SL_GET_LAYER(layer, SL_VALID) THEN SL_error "SL_SET_LAYER", 6, "" '  report error to programmer
  400.     SELECT CASE action '                                                                                which action was requested?
  401.         CASE SL_DEST '                                                                                  set destination layer
  402.             IF layer = SL_ALL THEN SL_error "SL_SET_LAYER", 7, "" '                                     report error to programmer
  403.             _DEST SL_layer(layer).image '                                                               set layer software image as destination
  404.             SL_global.destination = layer '                                                             save destination layer in global settings
  405.             SL_layer(layer).dest = -1 '                                                                 mark this layer as the destination
  406.         CASE SL_SOURCE '                                                                                set source layer
  407.             IF layer = SL_ALL THEN SL_error "SL_SET_LAYER", 7, "" '                                     report error to programmer
  408.             _SOURCE SL_layer(layer).image '                                                             set layer software image as source
  409.             SL_global.source = layer '                                                                  save source layer in global settings
  410.             SL_layer(layer).source = -1 '                                                               mark this layer as the source
  411.         CASE SL_VISIBLE, SL_INVISIBLE '                                                                 make layer(s) (in)visible
  412.             IF action = SL_VISIBLE THEN visibility = -1 '                                               determine visibility setting
  413.             IF layer = SL_ALL THEN '                                                                    change visibility of all layers?
  414.                 DO '                                                                                    cycle through all layers
  415.                     count = count + 1 '                                                                 increment layer counter
  416.                     SL_layer(count).visible = visibility '                                              change visibility of layer
  417.                 LOOP UNTIL count = UBOUND(SL_layer) '                                                   leave when all layers changed
  418.             ELSE '                                                                                      no, change visibility of one layer
  419.                 SL_layer(layer).visible = visibility '                                                  change visibility of layer
  420.             END IF
  421.         CASE ELSE '                                                                                     unknown error?
  422.             SL_error "SL_SET_LAYER", 8, "" '                                                            report error to programmer
  423.     END SELECT
  424.  
  425.  
  426. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  427. SUB SL_SHIFT_LAYER (layer AS INTEGER, angle AS INTEGER, speed AS INTEGER) '                                                                                                              SL_SHIFT_LAYER
  428.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  429.  
  430.     ' SL_SHIFT_LAYER(x, 90, 5)              SL_UP, SL_RIGHT, SL_DOWN, SL_LEFT
  431.     ' SL_SHIFT_LAYER(SL_ALL, 90, 5)         SL_UPRIGHT, SL_DOWNRIGHT, SL_DOWNLEFT, SL_UPLEFT
  432.  
  433.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  434.     SHARED SL_global AS SL_GLOBAL '     common globals array
  435.     DIM current AS LONG '               current layer image
  436.     DIM xdir AS SINGLE '                direction in x to travel
  437.     DIM ydir AS SINGLE '                direction in y to travel
  438.     DIM source AS INTEGER '             -1 (TRUE) if layer is current source
  439.     DIM destination AS INTEGER '        -1 (TRUE) if layer is current destination
  440.     DIM temp AS LONG '                  temp image for source and destination holding
  441.     DIM degrees AS INTEGER
  442.  
  443.  
  444.     IF NOT SL_GET_LAYER(layer, SL_VALID) THEN '                                                         valid layer requested?
  445.         SL_error "SL_SHIFT_LAYER", 6, "" '                                                              no, report error to programmer
  446.     END IF
  447.  
  448.     SELECT CASE angle '                                                                                 direction passed in?
  449.         CASE SL_UP '                                                                                    straight up (0 use pixel movement)
  450.             xdir = 0 '                                                                                  pixels in x direction
  451.             ydir = -speed '                                                                             pixels in y direction
  452.         CASE SL_UPRIGHT '                                                                               up and to the right (45)
  453.             xdir = speed
  454.             ydir = -speed
  455.         CASE SL_RIGHT '                                                                                 to the right (90)
  456.             xdir = speed
  457.             ydir = 0
  458.         CASE SL_DOWNRIGHT '                                                                             to the right and down (135)
  459.             xdir = speed
  460.             ydir = speed
  461.         CASE SL_DOWN '                                                                                  straight down (180)
  462.             xdir = 0
  463.             ydir = speed
  464.         CASE SL_DOWNLEFT '                                                                              to the left and down (225)
  465.             xdir = -speed
  466.             ydir = speed
  467.         CASE SL_LEFT '                                                                                  to the left (270)
  468.             xdir = -speed
  469.             ydir = 0
  470.         CASE SL_UPLEFT '                                                                                up and to the right (315)
  471.             xdir = -speed
  472.             ydir = -speed
  473.         CASE ELSE '                                                                                     use angle movements instead
  474.             degrees = SL_FIX_DEGREES(angle) '                                                           correct angle if needed
  475.             xdir = SIN(degrees * .017453292) * speed '                                                  calculate x distance given angle and speed
  476.             ydir = -COS(degrees * .017453292) * speed '                                                 calculate y distance given angle and speed
  477.     END SELECT
  478.     temp = _NEWIMAGE(1, 1, 32) '                                                                        create temp image to make source and destination
  479.     current = _COPYIMAGE(SL_layer(layer).image, 32) '                                                   get current layer image
  480.  
  481.     'xdir = _CEIL(xdir)
  482.     'ydir = _CEIL(ydir)
  483.  
  484.     IF SL_GET_LAYER(layer, SL_SOURCE) THEN _SOURCE temp: source = -1 '                                  remember that this layer is the current source
  485.     IF SL_GET_LAYER(layer, SL_DEST) THEN _DEST temp: destination = -1 '                                 remember that this layer is the currnt destination
  486.     _FREEIMAGE SL_layer(layer).image '                                                                  free the old layer image from memory
  487.     SL_layer(layer).image = _NEWIMAGE(SL_global.screen.width, SL_global.screen.height, 32) '            create a new clean layer image
  488.     _PUTIMAGE (xdir, ydir), current, SL_layer(layer).image '                                            place old layer image in new spot
  489.     _PUTIMAGE (xdir - SGN(xdir) * SL_global.screen.width, ydir), current, SL_layer(layer).image '       place old layer image to fill gap left or right
  490.     _PUTIMAGE (xdir, ydir - SGN(ydir) * SL_global.screen.height), current, SL_layer(layer).image '      place old layer image to fill gap top or bottom
  491.     _PUTIMAGE (xdir - SGN(xdir) * SL_global.screen.width, ydir - SGN(ydir) * SL_global.screen.height), current, SL_layer(layer).image ' place old layer image to fill diagonal gap
  492.     IF source THEN _SOURCE SL_layer(layer).image '                                                      return layer as source if necessary
  493.     IF destination THEN _DEST SL_layer(layer).image '                                                   return layer as destination if necessary
  494.     _FREEIMAGE temp '                                                                                   free temporary images from memory
  495.     _FREEIMAGE current
  496.  
  497.  
  498. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  499. SUB SL_SWAP_LAYER (layer1 AS INTEGER, layer2 AS INTEGER) '                                                                                                                                SL_SWAP_LAYER
  500.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  501.  
  502.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  503.     DIM current1 AS LONG '              layer 1 current image
  504.     DIM current2 AS LONG '              layer 2 current image
  505.     DIM source AS INTEGER '             -1 (TRUE) if layer is current source
  506.     DIM destination AS INTEGER '        -1 (TRUE) if layer is current destination
  507.     DIM temp AS LONG '                  source/destination place holder image
  508.  
  509.     IF (NOT SL_GET_LAYER(layer1, SL_VALID)) OR (NOT SL_GET_LAYER(layer2, SL_VALID)) THEN '              valid layers requested?
  510.         SL_error "SL_SWAP_LAYER", 6, "" '                                                               no, report error to programmer
  511.     END IF
  512.  
  513.     current1 = _COPYIMAGE(SL_layer(layer1).image, 32) '                                                 get first layer image
  514.     current2 = _COPYIMAGE(SL_layer(layer2).image, 32) '                                                 get second layer image
  515.     temp = _NEWIMAGE(1, 1, 32) '                                                                        image to act as source/destination place holder
  516.     IF SL_GET_LAYER(layer1, SL_SOURCE) THEN _SOURCE temp: source = -1 '                                 remember that this layer is the current source
  517.     IF SL_GET_LAYER(layer1, SL_DEST) THEN _DEST temp: destination = -1 '                                remember that this layer is the currnt destination
  518.     _FREEIMAGE SL_layer(layer1).image '                                                                 remove layer image from memory
  519.     SL_layer(layer1).image = _COPYIMAGE(current2, 32) '                                                 this layer now contains the other layer's image
  520.     IF source THEN _SOURCE SL_layer(layer1).image '                                                     return layer as source if necessary
  521.     IF destination THEN _DEST SL_layer(layer1).image '                                                  return layer as destination if necessary
  522.     source = 0 '                                                                                        reset source indicator
  523.     destination = 0 '                                                                                   reset destination indicator
  524.     IF SL_GET_LAYER(layer2, SL_SOURCE) THEN _SOURCE temp: source = -1 '                                 remember that this layer is the current source
  525.     IF SL_GET_LAYER(layer2, SL_DEST) THEN _DEST temp: destination = -1 '                                remember that this layer is the currnt destination
  526.     _FREEIMAGE SL_layer(layer2).image '                                                                 remove layer image from memory
  527.     SL_layer(layer2).image = _COPYIMAGE(current1, 32) '                                                 this layer now contains the other layer's image
  528.     IF source THEN _SOURCE SL_layer(layer2).image '                                                     return layer as source if necessary
  529.     IF destination THEN _DEST SL_layer(layer2).image '                                                  return layer as destination if necessary
  530.     _FREEIMAGE temp '                                                                                   remove temporary image from memory
  531.     _FREEIMAGE current2 '                                                                               remove current images from memory
  532.     _FREEIMAGE current1
  533.  
  534.  
  535. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  536. SUB SL_KILL_LAYER (layer AS INTEGER) '                                                                                                                                                    SL_KILL_LAYER
  537.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  538.  
  539.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  540.     SHARED SL_global AS SL_GLOBAL '     common globals array
  541.     DIM count AS INTEGER '              layer counter
  542.  
  543.     IF UBOUND(SL_layer) = 1 THEN SL_error "SL_KILL_LAYER", 4, "" '                                      report error to programmer
  544.     IF NOT SL_GET_LAYER(layer, SL_VALID) THEN SL_error "SL_KILL_LAYER", 6, "" '                         report error to programmer
  545.     count = layer '                                                                                     start with layer being deleted
  546.     DO
  547.         IF count <> 1 THEN '                                                                            is layer 1 being deleted?
  548.             IF _DEST = SL_layer(count).image THEN '                                                     no, is this layer the curent destination?
  549.                 _DEST SL_layer(count - 1).image '                                                       yes, make previous layer the new destination
  550.                 SL_global.destination = count - 1 '                                                     set previous layer as the new destination
  551.                 SL_layer(count - 1).dest = -1 '                                                         mark previous layer as the destination
  552.                 SL_layer(count).dest = 0 '                                                              set this layer as no longer the destination
  553.             END IF
  554.             IF _SOURCE = SL_layer(count).image THEN '                                                   is this layer the current source?
  555.                 _SOURCE SL_layer(count - 1).image '                                                     yes, make previous layer the new source
  556.                 SL_global.source = count - 1 '                                                          set previous layer as the new source
  557.                 SL_layer(count - 1).source = -1 '                                                       mark previous layer as the source
  558.                 SL_layer(count).source = 0 '                                                            set this layer as no longer the source
  559.             END IF
  560.         END IF
  561.         SL_SWAP_LAYER count, count + 1 '                                                                swap the layer images
  562.  
  563.         '*
  564.         '* add code to update sprite layers <--------------------------------------------------------------------------------------------------------------------------------------------------- LOOK
  565.         '*
  566.  
  567.         count = count + 1 '                                                                             increment layer counter
  568.     LOOP UNTIL count = UBOUND(SL_layer)
  569.     _FREEIMAGE SL_layer(UBOUND(SL_layer)).image
  570.     REDIM _PRESERVE SL_layer(UBOUND(SL_layer) - 1) AS SL_LAYERS '                                       delete the last layer from the array
  571.  
  572.  
  573. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  574. FUNCTION SL_ADD_LAYER (layers AS INTEGER) '                                                                                                                                                SL_ADD_LAYER
  575.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  576.  
  577.     SHARED SL_layer() AS SL_LAYERS '    master layer array
  578.     SHARED SL_global AS SL_GLOBAL '     common globals array
  579.     DIM newlayer AS INTEGER '           new layers counter
  580.  
  581.     newlayer = UBOUND(SL_layer) + 1 '                                                                   start of new layer(s)
  582.     SL_ADD_LAYER = newlayer '                                                                           return where new layer(s) start
  583.     REDIM _PRESERVE SL_layer(UBOUND(SL_layer) + layers) AS SL_LAYERS '                                  increase size of layer array
  584.  
  585.     DO '                                                                                                cycle through new layers
  586.         SL_layer(newlayer).image = _NEWIMAGE(SL_global.screen.width, SL_global.screen.height, 32) '     create new layer software image
  587.         SL_layer(newlayer).visible = -1 '                                                      (TRUE)   new layer is visible
  588.         newlayer = newlayer + 1 '                                                                       increment new layer counter
  589.     LOOP UNTIL newlayer = UBOUND(SL_layer) + 1 '                                                        leave when all new layers created
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619.  
  620.  
  621. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  622. FUNCTION SL_FIX_DEGREES (degrees AS INTEGER) '                                                                                                                                           SL_FIX_DEGREES
  623.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  624.  
  625.     ' Credits: this function uses code contriibuted by codeguy
  626.     '          https://www.qb64.org/forum/index.php?topic=537.15
  627.  
  628.     DIM degree AS INTEGER '             degree angle passed in
  629.  
  630.     degree = degrees MOD 360 '                                                                          get -359 to 359
  631.     IF degree < 0 THEN '                                                                                need to make positive?
  632.         SL_FIX_DEGREES = degree + 360 '                                                                 yes, correct value and return degree angle
  633.     ELSE
  634.         SL_FIX_DEGREES = degree '                                                                       no correction needed, return degree angle
  635.     END IF
  636.  
  637.  
  638. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  639. SUB SL_error (routine AS STRING, errno AS INTEGER, info AS STRING) '                                                                                                                           SL_error
  640.     'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  641.  
  642.     DIM tune AS INTEGER
  643.     tune = INT(RND(1) * 2) + 1
  644.     SELECT CASE tune
  645.         CASE 1
  646.             PLAY "o2l8eeel2c" '                                                                         duh, duh, duh, dooooh
  647.         CASE 2
  648.             PLAY "o2l8gl16ddl8ed" '                                                                     shave and a hair cut
  649.         CASE 3
  650.  
  651.     END SELECT
  652.     SCREEN 0, 0, 0, 0 '                                                                                 go to a pure text screen
  653.     _FONT 16 '                                                                                          set the standard screen 0 font
  654.     IF _FULLSCREEN THEN _FULLSCREEN _OFF '                                                              turn off full screen if on
  655.     _AUTODISPLAY '                                                                                      auto update the display
  656.     CLS '                                                                                               clear the screen
  657.     COLOR 10, 0
  658.     PRINT "                    **************************************" '                                print error header
  659.     PRINT "                    ** Sprite Library Error Encountered **"
  660.     PRINT "                    **************************************"
  661.     PRINT
  662.     COLOR 15, 0
  663.     PRINT " "; routine;
  664.     COLOR 7, 0
  665.     PRINT " has reported error";
  666.     COLOR 30, 0
  667.     PRINT STR$(errno)
  668.     COLOR 7, 0
  669.     PRINT
  670.     SELECT CASE errno '                                                                                 which error number is being reported?
  671.  
  672.         ' general purpose errors for all subs/functions
  673.  
  674.         CASE 1
  675.             PRINT " You must create at least one layer to work in."
  676.         CASE 2
  677.             PRINT " You must specify a window width and height greater than zero (0)."
  678.         CASE 3
  679.             PRINT " SL_GET can't be used with SL_VALID."
  680.             PRINT
  681.             PRINT " usage  : ";
  682.             COLOR 14, 0
  683.             PRINT "result = SL_GET_LAYER(x, SL_VALID)"
  684.             COLOR 7, 0
  685.             PRINT
  686.             PRINT "      x = the layer being checked for validity"
  687.             PRINT " result = -1 if the layer is valid, 0 if the layer is invalid"
  688.         CASE 4
  689.             PRINT " Only one layer remains. Unable to delete last remaining layer."
  690.         CASE 5
  691.             PRINT " SL_DEST, SL_SOURCE, and SL_VALID are the only second parameter values allowed."
  692.             PRINT
  693.             PRINT " usage  : ";
  694.             COLOR 14, 0
  695.             PRINT "result = SL_GET_LAYER(SL_GET, SL_DEST)"
  696.             PRINT "          result = SL_GET_LAYER(SL_GET, SL_SOURCE)"
  697.             PRINT "          result = SL_GET_LAYER(x, SL_DEST)"
  698.             PRINT "          result = SL_GET_LAYER(x, SL_SOURCE"
  699.             PRINT "          result = SL_GET_LAYER(x, SL_VALID)"
  700.             COLOR 7, 0
  701.         CASE 6
  702.             PRINT "- The specified layer(s) does not exist."
  703.         CASE 7
  704.             PRINT " SL_ALL can't be used with SL_DEST or SL_SOURCE."
  705.             PRINT
  706.             PRINT " usage  : ";
  707.             COLOR 14, 0
  708.             PRINT " SL_SET_LAYER x, SL_DEST"
  709.             PRINT
  710.             PRINT "           SL_SET_LAYER x, SL_SOURCE"
  711.             COLOR 7, 0
  712.             PRINT
  713.             PRINT "      x = the layer being set as source or destination"
  714.         CASE 8
  715.             PRINT " SL_DEST, SL_SOURCE, SL_VISIBLE, and SL_INVISIBLE are the only second"
  716.             PRINT " parameter values allowed."
  717.             PRINT
  718.             PRINT " usage  : ";
  719.             COLOR 14, 0
  720.             PRINT "SL_SET_LAYER x, SL_DEST"
  721.             PRINT "          SL_SET_LAYER x, SL_SOURCE"
  722.             PRINT "          SL_SET_LAYER x, SL_VISIBLE"
  723.             PRINT "          SL_SET_LAYER SL_ALL, SL_VISIBLE"
  724.             PRINT "          SL_SET_LAYER x, SL_INVISIBLE"
  725.             PRINT "          SL_SET_LAYER SL_ALL, SL_INVISIBLE"
  726.         CASE 9
  727.             PRINT " You must specify a screen width and height greater than zero (0)."
  728.         CASE 10
  729.             PRINT " Incorrect parameter given."
  730.             PRINT
  731.             PRINT " usage  : ";
  732.             COLOR 14, 0
  733.             PRINT "result = SL_SCREEN(SL_WIDTH)"
  734.             PRINT "          result = SL_SCREEN(SL_HEIGHT)"
  735.             PRINT "          result = SL_SCREEN(SL_CENTERX)"
  736.             PRINT "          result = SL_SCREEN(SL_CENTERY)"
  737.             PRINT "          result = SL_SCREEN(SL_TOP)"
  738.             PRINT "          result = SL_SCREEN(SL_LEFT)"
  739.             PRINT "          result = SL_SCREEN(SL_BOTTOM)"
  740.             PRINT "          result = SL_SCREEN(SL_RIGHT)"
  741.         CASE 11
  742.             PRINT "SL_GET must be used with SL_TOTAL."
  743.             PRINT
  744.             PRINT " usage  : ";
  745.             COLOR 14, 0
  746.             PRINT "result = SL_GET_LAYER(SL_GET, SL_TOTAL)"
  747.             COLOR 7, 0
  748.             PRINT
  749.             PRINT "result = the total number of layers availabel"
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.     END SELECT
  758.     COLOR 12, 0
  759.     PRINT
  760.     PRINT " See sprite library doumentation for further explanation."
  761.     COLOR 7, 0
  762.     SELECT CASE tune
  763.         CASE 1
  764.             PLAY "o2l8dddl2o1b" '                                                                       duh duh duh dum
  765.         CASE 2
  766.             PLAY "o2p8l8f#g" '                                                                          two bits
  767.     END SELECT
  768.     DO: LOOP UNTIL INKEY$ = "" '                                                                        clear the keyboard buffer
  769.     END '                                                                                               end the program
  770.  
  771.  

22
QB64 Discussion / Multi-Function Commands. Your opinions?
« on: October 03, 2018, 05:02:43 pm »
Ok, the sprite library is getting big with LOTS of commands. This is creating command overload:

SL_GET_DESTINATION_LAYER
SL_GET_SOURCE_LAYER
SL_SET_DESTINATION_LAYER
SL_SET_SOURCE_LAYER ... etc... etc..

Steve mentioned in another post that these long commands are troublesome, and I agree. Since they all deal with the same topic, layers in this case, I though about combining everything into one generalized command.

As a test I took all the layer related commands and built a multi-function command that does it all based on how it's configured. Being a FUNCTION it will always require a return value, even if it's doing something like setting a value. To this end I decided to incorporate error detection into the return value. Also, if the command is not configured properly, the return value will indicate an error as well as an audible beep.

See the code sample below to get an idea of what I'm going for here. Let me know your opinion on this.

Code: QB64: [Select]
  1. FUNCTION SL_LAYER (layer AS INTEGER, action AS INTEGER) ' (MULTI-FUNCTION COMMAND)
  2.  
  3.     ' An audible tone (BEEP) will be heard if command is configured improperly and a value of 0 returned to indicate the command did not complete successfully.
  4.     '
  5.     ' usage:
  6.     '           value = SL_LAYER(x, SL_DEST)            set layer x as destination                              returns -1 if command completed successfully, 0 otherwise
  7.     '           value = SL_LAYER(SL_GET, SL_DEST)       return the value of current destination layer           returns the value of the destination layer, 0 if no destination found
  8.     '           value = SL_LAYER(x, SL_SOURCE)          set layer x as the source                               returns -1 if command completed successfully, 0 otherwise
  9.     '           value = SL_LAYER(SL_GET, SL_SOURCE)     return the value of the current source layer            returns the value of the source layer, 0 if no source found
  10.     '           value = SL_LAYER(x, SL_CLS)             clear layer x                                           returns -1 if command completed successfully, 0 otherwise
  11.     '           value = SL_LAYER(SL_ALL, SL_CLS)        clear all layers                                        returns -1 if command completed successfully, 0 otherwise
  12.     '           value = SL_LAYER(x, SL_VALID)           return either -1 or 0 depending on layer x being valid  returns -1 if layer is valid, 0 if layer is invalid
  13.     '           value = SL_LAYER(x, SL_VISBILE)         set layer x as visible '                                returns -1 if command completed successfully, 0 otherwise
  14.     '           value = SL_LAYER(SL_ALL, SL_VISIBLE)    set all layers as visible                               returns -1 if command completed successfully, 0 otherwise
  15.     '           value = SL_LAYER(x, SL_INVISIBLE)       set layer x as invisible                                returns -1 if command completed successfully, 0 otherwise
  16.     '           value = SL_LAYER(SL_ALL, SL_INVISIBLE)  set all layers as invisible                             returns -1 if command completed successfully, 0 otherwise
  17.  
  18.     ' declare global variables
  19.  
  20.     SHARED SL_layers() AS SL_LAYERS '   master layer array
  21.     SHARED SL_global AS SL_GLOBAL '     common globals array
  22.  
  23.     ' declare local variables
  24.  
  25.     DIM count AS INTEGER '              layer counter
  26.     DIM temp AS LONG '                  temp source/destination iamge
  27.     DIM visibility AS INTEGER '         layer visibility status
  28.  
  29.     IF (layer <> SL_ALL) AND (layer <> SL_GET) THEN '                                                   was a layer value supplied?
  30.         IF layer < 1 OR layer > UBOUND(SL_layers) THEN SL_LAYER = 0: EXIT FUNCTION '                    yes, if not valid then report error and leave
  31.     END IF
  32.     SELECT CASE action '                                                                                which action was requested?
  33.         CASE SL_DEST '                                                                             (0)  get or set destination layer
  34.             IF layer = SL_ALL THEN SL_LAYER = 0: BEEP: EXIT FUNCTION '                                  SL_ALL not valid with SL_DEST
  35.             IF layer = SL_GET THEN '                                                                    retrieve current destination layer?
  36.                 SL_LAYER = SL_global.destination '                                                      yes, report current destination layer
  37.             ELSE '                                                                                      no, a layer value was supplied
  38.                 _DEST SL_layers(layer).image '                                                          set destination as layer software image
  39.                 SL_layers(layer).dest = -1 '                                                            mark this layer as the destination
  40.                 SL_global.destination = layer '                                                         save destination layer in global settings
  41.                 SL_LAYER = -1 '                                                                         report that command executed correctly
  42.             END IF
  43.         CASE SL_SOURCE '                                                                           (1)  get or set source layer
  44.             IF layer = SL_ALL THEN SL_LAYER = 0: BEEP: EXIT FUNCTION '                                  SL_ALL not valid with SL_SOURCE
  45.             IF layer = SL_GET THEN '                                                                    retrieve current source layer?
  46.                 SL_LAYER = SL_global.source '                                                           yes, report current source layer
  47.             ELSE '                                                                                      no, a layer value was supplied
  48.                 _SOURCE SL_layers(layer).image '                                                        set source as layer software image
  49.                 SL_layers(layer).source = -1 '                                                          mark this layer as the source
  50.                 SL_global.source = layer '                                                              save source layer in global settings
  51.                 SL_LAYER = -1 '                                                                         report that command executed correctly
  52.             END IF
  53.         CASE SL_CLS '                                                                              (2)  clear layer(s)
  54.             IF layer = SL_GET THEN SL_LAYER = 0: BEEP: EXIT FUNCTION '                                  SL_GET not valid with SL_CLS
  55.             temp = _NEWIMAGE(1, 1, 32) '                                                                great a temp image for source / destination
  56.             IF layer = SL_ALL THEN '                                                                    clear all layers?
  57.                 _SOURCE temp '                                                                          yes, make temp image the current source
  58.                 _DEST temp '                                                                            make temp image the current destination
  59.                 DO '                                                                                    cycle through all layers
  60.                     count = count + 1 '                                                                 increment layer counter
  61.                     _FREEIMAGE SL_layers(count).image '                                                 remove current layer from memory
  62.                     SL_layers(count).image = _NEWIMAGE(SL_global.swidth, SL_global.sheight, 32) '       create new layer image
  63.                     IF SL_global.source = count THEN _SOURCE SL_layers(count).image '                   set it back to source if necessary
  64.                     IF SL_global.destination = count THEN _DEST SL_layers(count).image '                set it back to destination if necessary
  65.                 LOOP UNTIL UBOUND(SL_layers) '                                                          leave when all layers cleared
  66.                 _FREEIMAGE temp '                                                                       remove temp image from memory
  67.                 SL_LAYER = -1 '                                                                         report that command executed correctly
  68.             ELSE '                                                                                      no, just clear one layer
  69.                 IF SL_global.source = layer THEN _SOURCE temp '                                         make temp image the source if necessary
  70.                 IF SL_global.destination = layer THEN _DEST temp '                                      make temp image the destination if necessary
  71.                 _FREEIMAGE SL_layers(layer).image '                                                     remove currentl layer from memory
  72.                 SL_layers(layer).image = _NEWIMAGE(SL_global.swidth, SL_global.sheight, 32) '           create new layer image
  73.                 IF SL_global.source = layer THEN _SOURCE SL_layers(layer).image '                       set it back to source if necessary
  74.                 IF SL_global.destination = layer THEN _DEST SL_layers(layer).image '                    set it back to destination if necessary
  75.                 _FREEIMAGE temp '                                                                       remove temp image from memory
  76.                 SL_LAYER = -1 '                                                                         report that command executed correctly
  77.             END IF
  78.         CASE SL_VALID '                                                                            (3)  check for valid layer
  79.             IF layer = SL_ALL OR layer = SL_GET THEN SL_LAYER = 0: BEEP: EXIT FUNCTION '                SL_ALL and SL_GET not valid with SL_VALID
  80.             SL_LAYER = -1 '                                                                             yes, report that this is a valid layer
  81.         CASE SL_VISIBLE, SL_INVISIBLE '                                                         (4, 5)  make layer(s) (in)visible
  82.             IF action = SL_VISIBLE THEN visibility = -1 '                                               determine visibility setting
  83.             IF layer = SL_GET THEN SL_LAYER = 0: BEEP: EXIT FUNCTION '                                  SL_GET not valid with SL_(IN)VISIBLE
  84.             IF layer = SL_ALL THEN '                                                                    change visibility of all layers?
  85.                 DO '                                                                                    cycle through all layers
  86.                     count = count + 1 '                                                                 increment layer counter
  87.                     SL_layers(count).visible = visibility '                                             change visibility of layer
  88.                 LOOP UNTIL count = UBOUND(SL_layers) '                                                  leave when all layers changed
  89.                 SL_LAYER = -1 '                                                                         report that command executed correctly
  90.             ELSE '                                                                                      no, change visibility of one layer
  91.                 SL_layers(layer).visible = visibility '                                                 change visibility of layer
  92.                 SL_LAYER = -1 '                                                                         report that command executed correctly
  93.             END IF
  94.         CASE ELSE '                                                                                     unknown error?
  95.             BEEP: SL_LAYER = 0 '                                                                        report that command did not execute correctly
  96.     END SELECT
  97.  

23
Programs / 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.  

24
Programs / Analog Clock Demo
« on: September 30, 2018, 12:52:17 am »
I'm not sure how many of you may be following the sprite library revisited thread on the site but I wanted to highlight the progress I have made so far.

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

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

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

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

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

25
QB64 Discussion / Efficient Mathematics
« on: September 28, 2018, 07:20:39 pm »
Since my sprite library is using hella math at places I decided to see if I could make it more efficient. I assumed that integer division would be faster than regular division and that reciprocal multiplication would be faster than both. When I ran the following code I was a bit surprised.

Turns out regular division is usually faster in QB64?

Code: QB64: [Select]
  1. t = TIMER
  2. FOR i = 1 TO 1000000
  3.     FOR k = 1 TO 100
  4.         j = i \ 100
  5.     NEXT k
  6. t2 = TIMER
  7. FOR i = 1 TO 1000000
  8.     FOR k = 1 TO 100
  9.         j = i / 100
  10.     NEXT k
  11. t3 = TIMER
  12. FOR i = 1 TO 1000000
  13.     FOR k = 1 TO 100
  14.         j = i * .01
  15.     NEXT k
  16. t4 = TIMER
  17.  
  18. PRINT USING "##.#### integer division"; t2 - t
  19. PRINT USING "##.#### regular division"; t3 - t2
  20. PRINT USING "##.#### reciprocal multiplication"; t4 - t3
  21.  

26
QB64 Discussion / Hardware vs Software Screens
« on: September 27, 2018, 12:41:33 pm »
The subject is a bit misleading, but here is my situation.

I'm currently working on adding layers to the sprite library. Think of each layer as a separate screen where sprites and other objects designated as belonging to a layer do their thing only on that layer. Sprites on layer 3 for instance can't interact (collide) with sprites on layer 4. Other layers could be used for scrolling backgrounds to create parallax scenery, etc..

Each layer consists of a software and hardware image. The software image is used for software based sprite images, drawing commands (CIRCLE, LINE, etc..), background images, and any other software based images. The hardware layer is used just before a display update by copying the software image to a hardware image (33) and then displaying that layer on the screen. Since hardware sprite images don't actually "attach" themselves to a software based image when using _PUTIMAGE they are not drawn until all software layers have been drawn, converted to hardware, and then displayed.

My question is: is there any real benefit to converting the layers to hardware before displaying?

I'm beginning to wonder if there is even a need for any sprite to be software based at all.

In my loop where software and hardware sprites are drawn before updating the screen, do I need to identify and draw software sprites first, then identify hardware sprites and draw them after the layer's have been merged, or will _DISPLAYORDER _SOFTWARE _HARDWARE take care of this for me?

I don't know why I am having difficulty wrapping my head around this, but something just doesn't seem right with the way QB64 handles software and hardware images and the way they interact, or is that just stinkin' thinkin' on my part?

27
QB64 Discussion / The _HYPOT command
« on: September 22, 2018, 10:57:25 pm »
When I run the test code below provided by Steve I get:

1.539 seconds for Hypot
1.367 seconds for Math stuff

_HYPOT should be faster, correct?

This is curious, change the first line to read:

_DEFINE A-Z AS INTEGER

I get:

2.000 seconds for Hypot
1.000 seconds for Math stuff

Now that's too perfect to be a coincidence?

Code: QB64: [Select]
  1.  
  2. t = TIMER
  3. FOR a = 1 TO 10000
  4.     FOR b = 1 TO 1000
  5.         c = _HYPOT(a, b)
  6.     NEXT
  7. t2 = TIMER
  8.  
  9. FOR a = 1 TO 10000
  10.     FOR b = 1 TO 1000
  11.         c = SQR(a ^ 2 + b ^ 2)
  12.     NEXT
  13. t3 = TIMER
  14.  
  15. PRINT USING "##.### seconds for Hypot"; t2 - t
  16. PRINT USING "##.### seconds for Math stuff"; t3 - t2
  17.  

28
QB64 Discussion / Math wizards, I need help
« on: September 21, 2018, 06:34:40 pm »
I've got a bad cold today and can't think. I have a math problem here that needs solved but I just can't seem to get my mind wrapped around it.

I'm setting up independent frames rates for the sprite library's animation routines. The main loop will be the main frame rate, then each sprite will have it's own frame rate it can be drawn at.

Consider the following:

Main Frame Rate = 30
Sprite Frame Rate = 20
Frames To Skip = 10 (30 - 20) main frame rate - sprite frame rate
SKIP every 3rd frame (30 / 10) main frame rate / frames to skip

Main Frame Rate = 30
Sprite Frame Rate = 15
Frames To Skip = 15 (30 - 15) main frame rate - sprite frame rate
SKIP every 2nd frame (30 / 15) main frame rate / frames to skip


everything above this line we need to SKIP frames
-------------------------- (main frame rate / 2)
everything below this line we need to DRAW frames

Main Frame Rate = 30
Sprite Frame Rate = 10
DRAW every 3rd frame (30 / 10) main frame rate / sprite frame rate

Main Frame Rate = 30
Sprite Frame Rate = 5
DRAW every 6th frame (30 / 5) main frame rate / sprite frame rate

As you can see sprites would either need to be drawn or skipped at certain intervals to achieve their frame rate within the main frame rate. Any sprite frame rate that is equal to or greater than the main frame rate divided by two will require having a frame drawing SKIPPED now and then.

Any sprite frame rate that is less than the main frame rate divided by two will require having a frame drawing DRAWN now and then.

Is there an algorithm that sums this all up or will I need to manually code for two separate instances? It feels like there is a really simple solution here but I'll be darned if I can see it.

29
QB64 Discussion / Why does this keep appearing in the IDE?
« on: September 13, 2018, 05:37:38 pm »
Why does that back arrow keep appearing in the IDE offering to take me back to previous lines? (see picture below). What is it, what triggers it, and how do I stop it from appearing? Every now and then when I want to click on file I hit it instead.

Thanks.

30
QB64 Discussion / Show us where the QB64 magic happens!
« on: September 08, 2018, 06:31:58 pm »
Post a pic of your rig where your QB64 goodness is cooked.

I would have put this in the off-topic area but you can't attach pictures there?

Pages: 1 [2] 3 4