pic movement

This is a discussion on pic movement within the Game Programming forums, part of the General Programming Boards category; hi
this code is to get a pic keep moving it's worked in BGI but without pictures now i tried ...

"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

Draws a copy of the sprite bitmap onto the destination bitmap at the specified position. This is almost the same as blit(sprite, bmp, 0, 0, x, y, sprite->w, sprite->h), but it uses a masked drawing mode where transparent pixels are skipped, so the background image will show through the masked parts of the sprite. Transparent pixels are marked by a zero in 256 color modes or bright pink for truecolor data (maximum red and blue, zero green).

If you use allegros timer routines you set a function to be called every so often. The most common way to do it is to have counter_function() called in whatever interval you want, and you have a global variable called counter that is set to 0. The only thing in counter_function() is counter = 1; So you check to see if counter is 1, if it is you execute whatever code and set counter back to 0.

I did not include redraw(), setup() or shutdown(). Setup will just initialize allegro and load the image, set the video mode. Redraw just redraws the sprite using picx and picy coordinates. Shutdown deletes the bitmap and if you add other stuff it does that.

Be sure to install_keyboard(), from looking at your code it looks like you do not know how to use it.

Don't be an arse, that code may do the same thing that yours is *suppose* to do, but it is not like yours. It is alot cleaner and easier to read. I still don't see why you loaded two bitmaps if you just want to display one and have it move around. Why use getch() when allegro has the built in key array?

Figure out how to use timers for yourself, I try to help you. BTW, you dont need a timer for something so simple, just change the ammount it increments and decrements the coordinates. Unless you are gonna be sending this to all your 1337 friends.