|  | 
 
 
 Part 1 Static Image Frames:For this tutorial the images are supplied, however these images could be what ever you want them to be. Remember though each image has to be the same size in order for this to work. 
 There are a couple of advantages in having many frames in one image: 
 
 
 
The size of this image is 71x96 (width x height in pixels)
 To load this image into BlitzBasic we would use the following line of code: 
 Inside of the inverted comers “card.bmp” you would normally put the full location to the file you require. 
 Now to expand our single image to include other cards we continue creating all of the cards. All of these cards need to be the same size. Remember the image size above? 71x96 
 
Once all of the cards are complete its time to put them together.
 
Create a blank image 497 width x 192 height.
 
Now click on the first image (Ace of Clubs) press Ctrl+C (copy image)
 
 
Now that we have our first card in place lets put the second card into place.
 
 
 Continue copying and then pasting all of your images like you did above so they end up looking like this: 
 
As you can see not all of the images have to be on the same line.
 To load this image into BlitzBasic we do something a little different to a single image. This is the line of code we would use: 
 
 
LoadAnimImage – Tells BlitzBasic it is to load an image with more than one frame.
 
The numbers:
 ,96 - This states the height of each image ,0 - This is the first image number of all the images in the image file This could be changed to any number. Lets say 1, what will then happen is when we draw the image, instead of the first image that is drawn being the Ace we now draw the 2 instead. It’s best to just set this to 0. ,13 - This lets BlitzBasic know how many frames there are in the image. However when we come to draw the images to screen you will see that instead of saying: 
     Image 1 is the Ace and Image 13 the King 
 
The reason for this is computers don’t count like humans.
 So far then, we have now got all of our cards into 1 image. The image is saved, and we have told BlitzBasic to load the image. The next step is to display the cards. This would be done differently depending on your project needs. 
 Let’s draw our images to the screen. A simple version. 
 
 
DrawImage     - Simply tells BlitzBasic to draw an image
 
 So to summarise on what we have learned so far. 
You know how to load a single image.
 Well done! Part 2 Animated images:There are several reasons why you may want animated images. It could be you want a character to run as you change direction, a ship to tilt as you move, or any other reasons that you may want. In order to create an animated image we use the same method as used in Part 1. The difference comes when you start coding. There are other methods of creating animations, but this is the most commonly used. 
 Exactly the same process that we carried out before. You need to create every image first. This helps if you are quite good with drawing. This time I will do it with images only, no text (well very little) Step 1 - Create your images (remember the size): 
 Step 2 - Add all images into 1 large image 
 
Finally you will have your animation strip complete.
 
 
 
 That is just an example of how to run through each frame in order to animate it. To have your animated image move when you press a key or move your mouse requires slightly more complex code. So let try some new code to achieve this. 
 
 Now that may seem a little daunting but read the commenting and you should understand what is going on. 
 So now you should be able to achieve the following: 
Load a single image.
 Well there we have it, you should now be able to go out and create your own animated images, and then animated them. So lets see your works of art on the Showcase. 
I hope this tutorial has help at least someone.
 Individual frames need to be the same size. Thanks: Special thanks go out to 2 Bits Short Of A Byte for his work on the code. 
 
 
 For a printable copy of this article, please click HERE. 
 This site is Copyright© 2000-2004, BlitzCoder. All rights reserved.   |