Computer Science Canada [Tutorial] Character Maps |
Author: | TheOneTrueGod [ Thu Mar 23, 2006 8:49 pm ] | ||
Post subject: | [Tutorial] Character Maps | ||
Since the biggest focus in games seems to be in graphics, it makes sense that the way these graphics are incorporated into your program is important. Currently, you see most examples using a bunch of file names, such as "Up1.gif", "Up2.gif", "Up3.gif", etc... Why not compile all of these files into one file, and load it as a character map? First of all, You need the character map created. I have provided a very simple character map with the example program. (Its just an arrow moving around... or rather not moving around but animating in place). Before you create a character map, keep in mind that all the frames need to be the same size. (for the sample provided, they are all 20 X 20 pixels large) Allright, once you're done the boring (In my opinion) artwork, you just have to write the program. First of all, you need a blank screen to start with, so you gotta cls. (I havn't discovered another way to do this, so you will want to initialize all the pictures at the start, before you draw everything). Now, you just load the character map from the file to the screen, with the handy command: Pic.ScreenLoad (picName : string, x, y : int, picType) x should be 0, y should be 0, picName should be whatever you named your character map, and picType should be picCopy. Now, its better that you look at the code:
Basically, I explained most of the stuff you need to know in the comments, but i'll run through it again here. First you load the picture to the screen in the bottom left. Then you use my Handy-Dandy-Algorithm (That I don't think was originally mine) (R) to get the picture array from that picture on the screen. Then, you can plug that gathered array into your program, and voila! You now have a spiffy looking program that doesn't require upwards of 12 pictures. Excercises: 1. Make the arrow move around by the user (And keep it animated). 2. Make the arrow move in a box shape, keep it animated, and make sure its facing the right direction. 3. Make the arrow move towards the mouse, keep it animated, and make sure it faces the right direction (Might be tricky for newer people). If you feel like it, submit your programs. I might give bits if i'm feeling generous, if I have enough, etc... (The gif file is in the attachement) |
Author: | jamonathin [ Fri Mar 24, 2006 10:30 am ] | ||
Post subject: | |||
Nice little tutorial . I realize your tutorial is about getting the images from one single image, but there's one thing that needs to be fixed regarding animationCount. The way you have yours set up is - if you leave the arrow on count 2, then press right the count is then 3. Well, if we weren't dealing with arrows and actual characters he would be stuck in a walking pose. You should reset the count when no keys are being pressed, just add this to the end of your if statement
Now you'll notice that each arrow starts on it's longest tail (except for left because the order was drawn wrong ). Other than that, good work. P.S. - it's a .bmp not .gif |