Author Topic: Sprite Library Revisited  (Read 26605 times)

0 Members and 1 Guest are viewing this topic.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #15 on: September 15, 2018, 03:44:54 pm »
Here is a listing of the commands I have finished so far. I'm not sure how I should word the commands. Should I use all CAPS separated BY_UNDERSCORE, CamelCaseWithNoSpaces, or something else?

The convention I am using right now is:

LibraryName_Verb_Description_..._...

Any ideas on naming convention would be appreciated.

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

I have MANY more subs/functions to finish, such as auto-motion routines and event handling routines. Any ideas for features in the library are appreciated. Like Steve suggested, I would like to make this more than just a sprite handling library and go in the direction of a game engine as well.
In order to understand recursion, one must first understand recursion.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Sprite Library Revisited
« Reply #16 on: September 15, 2018, 03:58:25 pm »
Hi TerryRitchie,

This is a great list of features. I would be for preservation of underscores, it is then clearer.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #17 on: September 15, 2018, 05:36:32 pm »
I agree with using underscore but I also want to get a majority opinion. Yours has been noted, thank you.

I'm going to make an effort to keep to commands to a limit of four words or less. I know I already broke this with SL_GET_DISTANCE_POINT_TO_POINT but SL_GET_DISTANCE_P2P just looks weird.
In order to understand recursion, one must first understand recursion.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • Steve’s QB64 Archive Forum
Re: Sprite Library Revisited
« Reply #18 on: September 15, 2018, 05:50:45 pm »
I'm going to sit down soon(tm) and see what it'd take to give us an _ALIAS command for QB64, which will work very similar to CONST.  For CONST, we say TRUE = -1, and the precompile routine reads every TRUE in our code and replaces it with the value -1.

I'd envision _ALIAS working the same way:

_ALIAS GDP2P = SL_Get_Distance_Point_To_Point

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

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

I think both those features would make libraries with naming conventions like these, much, much, more appealing to me.  (And probably a few others as well.).  ;D
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #19 on: September 15, 2018, 06:01:30 pm »
I wish there were a way to mimic the way Python includes libraries. If you just:

import pygame

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

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

But if you:

from pygame import *

You no longer need to use the library name:

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

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

from pygame.locals import *

and now you have all the constants at a local level without having to refer to pygame.locals first.
In order to understand recursion, one must first understand recursion.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #20 on: September 15, 2018, 06:11:17 pm »
I'd envision _ALIAS working the same way:

_ALIAS GDP2P = SL_Get_Distance_Point_To_Point

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

'$INCLUDE: sprite.bi
'$INCLUDE: sprite.alias
In order to understand recursion, one must first understand recursion.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #21 on: September 16, 2018, 12:36:31 pm »
I was a programmer possessed yesterday. I already have more commands in this new sprite library than were contained in the old, and I'm not even close to being finished yet.

Here is what I have now:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Sprite Library Revisited
« Reply #22 on: September 16, 2018, 03:39:58 pm »
Hi,
could I ask you for a dkong.png file? :-D  oh, sorry i found it....

Nice and clear. It's a great job. I look forward to continuing.
« Last Edit: September 16, 2018, 03:48:38 pm by Petr »

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #23 on: September 17, 2018, 02:23:28 am »
I added the following commands today:

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

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

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

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

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

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

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

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

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

Also made some internal modifications to how information is stored in data TYPES and arrays in preparation for the animation commands. Tomorrow I'll be tackling the animation commands and possibly some auto-travel  ideas I have from Steve's input on giving sprites a defined path to follow.
« Last Edit: September 17, 2018, 02:25:59 am by TerryRitchie »
In order to understand recursion, one must first understand recursion.

Offline codeguy

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

SL_Correct_Degree_Angle_To_360% replaces some code that reduces angles to 0-359 range, regardless of sign. It eliminates a LOT of subtraction for angles >=360 or <=-360.
a quick view since it was appended to your demo code.
Code: QB64: [Select]
  1. '* why the long name for variables in SUB?
  2. '* to prevent the likelihood of unintended collisions with global/shared variables or constants
  3. FUNCTION SL_Correct_Degree_Angle_To_360% (SLCDAT360AngleParameter AS INTEGER)
  4.     DIM SL_Correct_Degree_Angle_To_360CDAT360 AS INTEGER
  5.     SL_Correct_Degree_Angle_To_360CDAT360 = SLCDAT360AngleParameter MOD 360
  6.     IF SL_Correct_Degree_Angle_To_360CDAT360 < 0 THEN
  7.         SL_Correct_Degree_Angle_To_360% = SL_Correct_Degree_Angle_To_360CDAT360 + 360
  8.     ELSE
  9.         SL_Correct_Degree_Angle_To_360% = SL_Correct_Degree_Angle_To_360CDAT360
  10.     END IF
  11.  

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #25 on: September 17, 2018, 01:21:18 pm »
I always forget about using MOD for things like this.

Thank you for the correction. Much better

I did create a function called SL_FIX_DEGREES yesterday to replace the many places throughout the code where degree angle needed checked/corrected. Your code now controls that function since my code was the same as the original code scattered throughout.
« Last Edit: September 17, 2018, 01:31:58 pm by TerryRitchie »
In order to understand recursion, one must first understand recursion.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #26 on: September 18, 2018, 01:55:33 am »
Animation is turning out to be a beast. I've had to rethink my strategy a few times today reorganizing the code a few times in the process.

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

I'm starting to dream code at night. :-o
In order to understand recursion, one must first understand recursion.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #27 on: September 20, 2018, 02:23:40 am »
I have made so many changes over the last two days that trying to explain it all here would take a book. The one major thing I did was completely rethink the way data types are processed and presented to make it easier to sort out variables. I also had to come up with a way to identify sprites not only by their column/row on a sheet, but also by cell number for animation tracking. Both of which I have now. Here is the code for anyone interested in viewing what I have so far.

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

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #28 on: September 22, 2018, 01:29:36 pm »
I had a LOT of bugs to work out over the past few days. I believe they are all sorted out now. There are currently 63 commands in the new library and counting with many more to go. Here is the code so far for those keeping track:

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

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
Re: Sprite Library Revisited
« Reply #29 on: September 23, 2018, 01:55:36 pm »
Ok, it looks like ellipse collision is out for two ellipses colliding. This is the formula for it .. NO JOKE LOL

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

y = sqrt(1 - x^2)/b
In order to understand recursion, one must first understand recursion.