From: "laine" Newsgroups: comp.os.msdos.djgpp Subject: Re: images Date: 14 Apr 1998 12:20:50 GMT Organization: Clinet, Espoo, Finland. Lines: 64 Message-ID: <01bd675c$722c4d00$5c3e64c2@default> References: <3 DOT 0 DOT 3 DOT 32 DOT 19980413212939 DOT 0071f9d8 AT pop DOT gate DOT net> NNTP-Posting-Host: jkl1-27.dialup.iwn.fi [194.100.62.92] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk > Hi, I'm really new to allegro... can someone please > tell me how to simply load a bmp, jpg, or pcx, and use arrow keys > to move it across the screen? > Sure, Here's a little something that might help you. A little program. void main(void) { BITMAP *the_image; // This is probably the most important thing // The image is stored here when you've loaded it int x,y; // Just some coordinates for locating the picture x=160; y=100; allegro_init(); // Let's use Allegro install_keyboard(); // To use the Allegro Keyboard functions we have to // call this. set_gfx_mode(GFX_VGA,320,200,0,0); // Set the grafics mode to // VGA (13h) more information in // The documentation the_image=load_pcx("filename.pcx",palette); // This is the function you // have to use for loading .pcx-files, I havent used // the others, so I don't know about them, but // surely you can find them in the documentation create_bitmap(10,10); // Before you can use the bitmap, you have to create // it by telling it's size. set_pallete(palette); // Sets the loaded palette while(!key[KEY_ESC]){ // While no-one has hit ESC blit(the_image,screen,0,0,x,y,10,10); // Blits the image on the screen from (0,0) to // (x,y) - the size of the image is 10,10 // Keyboard if(key[KEY_LEFT]) x--; // if you press left.. if(key[KEY_RIGHT]) x++; if(key[KEY_UP]) y--; if(key[KEY_DOWN]) y++; // This is easy.. just: key[KEY_name_of_the_key] // ie. key[KEY_ALT] or key[KEY_A] } allegro_exit(); // Makes everything as it was before } There might be some faults in this program and it's not very good. It doesn't use double buffering (wich you should use..) or any other nice stuff. But it does what it's supposed to do (I hope so, I haven't tested it, I just wrote it here for you). Hope you find something in it. Good luck. Jarkko Laine www: http://members.tripod.com/~Jakero/