CIRCLE
Member #5,301
December 2004
|
This is the code that I use for the game that I am using and a simple 102,17 bitmap of 6 frames of animation the ball graphic is located here Ball.bmp for use with this small program. When you note the ball it is red balls but when played in allegro it is Blue how do I fix this odd problem? 1 | #include "allegro.h" | 2 | #define MODE GFX_AUTODETECT_FULLSCREEN | 3 | int WIDTH = 640; | 4 | int HEIGHT = 480; | 5 | int n; | 6 | int i; | 7 | BITMAP *temp; | 8 | BITMAP *ball[6]; | 9 | BITMAP *active_page; | 10 | int bals; | 11 | struct tagBall { | 12 | int x; | 13 | int y; | 14 | int speed; | 15 | int color; | 16 | int size; | 17 | } Balls[6]; | 18 | | 19 | BITMAP *grabframe(BITMAP *source, int width, int height, int startx, int starty, int columns, int frame) | 20 | { | 21 | BITMAP *temp = create_bitmap(width,height); | 22 | int x = startx + (frame ) * width; | 23 | int y = starty + (frame ) * height; | 24 | blit(source,temp,x,0,0,0,width,height); | 25 | //void blit(BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); | 26 | | 27 | return temp; | 28 | } | 29 | | 30 | int main() | 31 | { | 32 | allegro_init(); | 33 | set_color_depth(16); | 34 | install_mouse(); | 35 | install_keyboard(); | 36 | install_timer(); | 37 | srand(time(NULL)); | 38 | | 39 | //loadsprites(); | 40 | temp = load_bitmap("ball.bmp",NULL); | 41 | for (n = 0;n<6;n++) | 42 | ball[n] = grabframe(temp,17,17,0,0,1,n); //(temp,width,height,startx,starty,colums,n) | 43 | destroy_bitmap(temp); | 44 | //setupscreen(); | 45 | int ret = set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0); | 46 | if (ret != 0) | 47 | { | 48 | allegro_message(allegro_error); | 49 | } | 50 | | 51 | BITMAP *buffer = create_video_bitmap(SCREEN_W,SCREEN_H); | 52 | BITMAP *buffer2 = create_video_bitmap(SCREEN_W,SCREEN_H); | 53 | active_page = buffer2; | 54 | | 55 | while (!key[KEY_ESC]) | 56 | { | 57 | bals++; | 58 | if (bals >= 12) | 59 | bals = 0; | 60 | draw_sprite(active_page,ball[bals/2],SCREEN_W / 2,SCREEN_H / 2); | 61 | | 62 | show_video_bitmap(active_page); | 63 | if (active_page == buffer) | 64 | active_page = buffer2; | 65 | else | 66 | active_page = buffer; | 67 | clear_to_color(active_page, makecol(0, 0, 0)); | 68 | | 69 | rest(100); | 70 | } | 71 | destroy_bitmap(buffer); | 72 | destroy_bitmap(buffer2); | 73 | for(i = 0; i < 6; ++i) | 74 | destroy_bitmap(ball<i>); | 75 | allegro_exit(); | 76 | return 0; | 77 | } | 78 | END_OF_MAIN() |
Figured I would shrink down my game into a simple sprite animation tester to show my problem.
-I edit a lot. Prepare thyself.
|