Hi,
Sprite commands are oh-so-easy to learn. I think I can help you understand it exactly.
Sprite is something that lies above everything you draw on the screen. It's like an image stamped to the screen as Chris K had told you. So when you PRINT a text on the screen and position a sprite right on it. You won't see the word, just see the sprite, if it is big enough to cover all the word. Or you will see parts of the word if the sprite is not big enough. Do you understand?
Sprite is
grabbed exactly form an image.
Image is something like a bitmap, and uses memmory of your computer to store it. It will be freed after the programme finished. The image is a part of a bitmap or a whole bitmap. Is it any clearer now?
1.So to have a sprite, the first thing is to have an image and connect the image to the sprite.
To LOAD an image from a bitmap file, simply use the command
LOAD IMAGE
Filename,
ImageNumber
You will find this command in the MANUAL coming along with the DarBasic programme you purchased, or in the HELP section in DarkBasic programme.
Or you can grab a part of an image from a bitmap, but first, you must load a bitmap (too clear as if there is no bitmap, where can you grab an image from?). Use the command LOAD BITMAP
Filename,
BitmapNumber
Before you can grab an image, you must set the current bitmap to the one you want your image grab. Use SET CURRENT BITMAP
BitmapNumber command to do this. The screen holds the BitmapNumber of 0. Every other bitmaps use memory to retain, you cannot see them. When SET CURRENT BITMAP, all operation will take place on the bitmap you set current. Like if you SET CURRENT BITMAP 1, and PRINT "A", the letter A will be printed on bitmap number 1. Understand?
Use GET IAMGE
ImageNumber,
Left,
Top,
Right,
Bottom to grab from the current bitmap.
The screen consists of dots called pixels, you can grab the image by pointing out the correct frontier on the bitmap. The image must be a rectangle. The first pixel on the screen has an X coordinate 0 and Y coordinate 0.
If the pixels on the scren is like this:
00000000000000000000000
00011111111111111111000
00011111111111111111000
00011111111111111111000
00011111111111111111000
00011111111111111111000
00011111111111111111000
00000000000000000000000
Number 1 represents the part will be grabbed from the bitmap.
To grab the image like that, type in:
GET IMAGE 1, 4, 1, 19, 7
After grabbing an image, you can return to the screen, and do all the operation on it by SET CURRENT BITMAP 0
2. To position a sprite, use:
SPRITE
SpriteNumber,
XPos,
YPos,
ImageNumber
This will create a sprite has a number ID and links to a certain image, and place it on the screen at X, Y. The X and Y is just like what I show you above, X refers to the pixels counted from the left of the screen to the left of the Sprite, Y refers to the pixels counted from the top of the screen to the top of the Sprite.
To move a Sprite, just specify another value of XPos and YPos.
To set the sprite top-left assign XPos and YPos to 0 as the first pixel of the screen has X = 0, and Y = 0.
To set it top-right, set XPos to the width of your screen subtract 1 and subtract the width of the sprite (you will see how to get the width of the srpite below) as the fisrt pixel has the X = 0, and set YPos to 0. To get the width of your screen, use SCREEN WIDTH() command.
To set it top-center, set XPos to Int(the width of your screen - the width of the sprite) / 2), and set Ypos = 0. To get the width of your sprite, use SPRITE WIDTH
(SpriteNumber) command. INT() command will take the part before the dot in the number like 0.5. INT(0.5) will return 0. Since XPos and YPos cannot be 0.3 or 0.5, or something like that, you must do it.
To set it center of the screen, set XPos to Int(the width of your screen - the width of the sprite) / 2), and set Ypos = Int(the height of your screen - the height of the sprite) / 2). To get the height of your sprite, use SPRITE HEIGHT
(SpriteNumber) command.
I hope this will help you understand what sprite is and how to place them. Deleting the image the sprite links to will make the sprite disapear. You can delete the bitmap the image links to without losing the image. Use
DELETE IMAGE
ImageNumber
DELETE SRITE
SpriteNumber
DELETE BITMAP
BitmapNumber
You should SET SPRITE
SpriteNumber,
1,
1 or your sprite will appear on the
BLUE screen.
Refer to the MANUAL for help.
********************
You will find loads of Sprite commands in the MANUAL, read the instruction carefully and you will be able to use every of them. There may be some mispelled words, just forgive me. This text is too long...
Hope my long post help,
See you,
Bye bye,