Amos Professional Manual  Contents  Index

Hardware Sprites


X HARD
function: convert screen x-coordinate into hardware x-coordinate
x=X Hard(xcoordinate)
x=X Hard(screen number,xcoordinate)

Y HARD
function: convert screen y-coordinate into hardware y-coordinate
y=Y Hard(ycoordinate)
y=Y Hard(screen number,ycoordinate)

These functions convert screen coordinates into hardware coordinates, relative to the current screen. As with X SCREEN and Y SCREEN, an optional screen number can be given, and coordinates will be returned relative to that screen.

With all four of the above functions, sensible values can only be returned when the relevant screen has been fully initialised. Both the SCREEN OPEN and SCREEN DISPLAY commands only come into effect from the next vertical blank, and the following examples demonstrate that the correct coordinate values (in this case 128,50) are only returned after a WAIT VBL command.

E> Screen Open 0,320,255,16,Lowres
   Print X Hard(0,0); Y Hard(0,0)

Now try the correct version:

E> Screen Open 0,320,255,16,Lowres
   Wait Vbl
   Print X Hard(0,0); Y Hard(0,0)

The default screen is initially located at hardware coordinates (128,50), and if you find the whole business of hardware coordinates and screen coordinates tiresome, you can bypass the entire conversion system.

By setting the HOT SPOT of your Sprite images to (-128,-50), the reference point for all position calculations is removed to the far corner of the display. Once an image has been prepared in this way, it can be assigned to a Sprite and moved around using normal screen coordinates. For example:

X> Hot Spot 1,-128,-50: Rem Set up hot spot
   Sprite 8,160,100,1 : Rem Sprite 8 to screen coords 160,100

The Hot Spot
Whenever an image is drawn on screen using the SPRITE or BOB command, it is positioned using an invisible reference point known as the "hot spot". This reference point is then used for all coordinate calculations.

Back    Next
07.01.10