Allegro problem

Started by
-1 comments, last by george1 14 years ago
We are trying to make a turn-based game with allegro, however whenever we have the enemies move, they just disapear. Here is the code: int rsx = 0; int rsy = 0; int rsxi = 0; int rsyi = 1; int rsm = 3; int rsmi = 3; int rsh = 3; int rshi = 3; int bsx = 25; int bsy = 0; int bsxi = 25; int bsyi = 1; int bsm = 3; int bsmi = 3; int bsh = 3; int bshi = 3; int tx = 0; int ty = 0; int txi = 0; int tyi = 0; int tt = 0; int ttx = 0; int tty = 0; int sol = 0; int turn = 0; int space_bar_down = 0; int left_press = 0; int right_press = 0; int down_press = 0; int up_press = 0; int enter = 0; volatile long speed_counter = 0; void increment_speed_counter() { speed_counter++; }; END_OF_FUNCTION(increment_speed_counter); int main(int argc, char *argv[]){ FILE * fout; allegro_init(); // Initialize Allegro install_keyboard(); // Initialize keyboard routines install_timer(); // Initialize the timer routines install_mouse(); LOCK_VARIABLE(speed_counter); LOCK_FUNCTION(increment_speed_counter); install_int_ex(increment_speed_counter, BPS_TO_TIMER(60)); set_color_depth(16); set_gfx_mode(GFX_AUTODETECT, 640,480,0,0); BITMAP *buffer = create_bitmap(640,480); BITMAP *redsoldier = NULL; BITMAP *bluesoldier = NULL; redsoldier = load_bitmap("redsoldier.bmp",NULL); bluesoldier = load_bitmap("bluesoldier.bmp",NULL); fout=fopen("DEBUG","w"); while(!key[KEY_ESC]){ while(speed_counter > 0){ if (turn == 0){ clear_keybuf(); if(key[KEY_SPACE]){ if(space_bar_down==0) { sol=(sol<1)? 1: 0; space_bar_down = 1; } }//key space if (sol==0){ if (rsm>0){ clear_keybuf(); if(key[KEY_DOWN]){ if(down_press==0){ if(rsy < 18)rsy++; down_press = 1; rsm--; }//down_press }//KEY_DOWN clear_keybuf(); if(key[KEY_UP]){ if (up_press==0){ if(rsy > 0)rsy--; up_press = 1; rsm--; } } clear_keybuf(); if(key[KEY_RIGHT]){ if (right_press == 0){ if(rsx < 25)rsx++; right_press = 1; rsm--; } } clear_keybuf(); if(key[KEY_LEFT]){ if(left_press == 0){ if(rsx > 0)rsx--; left_press = 1; rsm--; }//left_press }//KEY_LEFT }//rsm }//sol else{ if (rsmi>0){ clear_keybuf(); if(key[KEY_DOWN]){ if(down_press==0){ if(rsyi < 18)rsyi++; down_press = 1; rsmi--; }// }// clear_keybuf(); if(key[KEY_UP]){ if (up_press==0){ if(rsyi > 0)rsyi--; up_press = 1; rsmi--; }//up_press }//KEY_UP clear_keybuf(); if(key[KEY_RIGHT]){ if (right_press == 0){ if(rsxi < 25)rsxi++; right_press = 1; rsmi--; }//right_press }//KEY_RIGHT clear_keybuf(); if(key[KEY_LEFT]){ if(left_press == 0){ if(rsxi > 0)rsxi--; left_press = 1; rsmi--; }//left_press }//KEY_LEFT }//rsmi }//else if(!key[KEY_SPACE])space_bar_down = 0; if(!key[KEY_DOWN])down_press = 0; if(!key[KEY_UP])up_press = 0; if(!key[KEY_RIGHT])right_press = 0; if(!key[KEY_LEFT])left_press = 0; if(key[KEY_ENTER]){ //if(enter = 0){ turn=1; rsm=3; rsmi=3; enter = 1; //}//enter }//KEY_ENTER if(!key[KEY_ENTER])enter = 0; }//turn if (turn == 1){ tx = rsx; ty = rsy; if (tt == 0){ if (bsm > 0){ if (bsx > (tx + 1)){ bsx++; bsm--; }//tx if(bsx < (tx - 1)){ bsx--; bsm--; }//tx if (bsy > (ty + 1)){ bsy++; bsm--; }//tx if(bsy < (ty - 1)){ bsy--; bsm--; }//tx if((bsx == (tx - 1)) or (bsx == (tx + 1))){ tt = 0; } }//bsm else{// tt = 1; } }//tt else{ bsm = 3; turn = 0; }//else tt fprintf(fout,"debug turn = %d %s %d\n",turn,__FILE__,__LINE__); }//turn speed_counter--; }//speed_counter show_mouse(NULL); clear_to_color(buffer, makecol(0,255,0)); rectfill(buffer, 0, 324,640,480,makecol(0,0,0)); textout_ex(buffer, font, "Soldier 1", 70, 325,makecol(255, 255, 255), -1); textout_ex(buffer, font, "Soldier 2", 70, 345,makecol(255, 255, 255), -1); if (rsh > 0){ rectfill(buffer, 0, 325,20,335,makecol(255,0,0)); if (rsh > 1){ rectfill(buffer, 22, 325,42,335,makecol(255,0,0)); if (rsh > 2){ rectfill(buffer, 44, 325,64,335,makecol(255,0,0)); } } } if (rshi > 0){ rectfill(buffer, 0, 345,20,355,makecol(255,0,0)); if (rshi > 1){ rectfill(buffer, 22, 345,42,355,makecol(255,0,0)); if (rshi > 2){ rectfill(buffer, 44, 345,64,355,makecol(255,0,0)); } } } if (bsh > 0){ rectfill(buffer, 640, 325,620,335,makecol(0,0,255)); if (bsh > 1){ rectfill(buffer, 618, 325,598,335,makecol(0,0,255)); if (bsh > 2){ rectfill(buffer, 596, 325,576,335,makecol(0,0,255)); } } } if (bshi > 0){ rectfill(buffer, 640, 345,620,355,makecol(0,0,255)); if (bshi > 1){ rectfill(buffer, 618, 345,598,355,makecol(0,0,255)); if (bshi > 2){ rectfill(buffer, 596, 345,576,355,makecol(0,0,255)); } } } if (rsh > 0){ masked_blit(redsoldier, buffer,0,0,(rsx*25),(rsy*18),25,18); } if (rshi > 0){ masked_blit(redsoldier, buffer,0,0,(rsxi*25),(rsyi*18),25,18); } if (bsh > 0){ masked_blit(bluesoldier, buffer,0,0,(bsx*25),(bsy*18),25,18); } if (bshi > 0) { masked_blit(bluesoldier, buffer,0,0,(bsxi*25),(bsyi*18),25,18); } acquire_screen(); show_mouse(buffer); blit(buffer, screen,0,0,0,0,640,480); release_screen; }//KEY_ESC show_mouse(NULL); destroy_bitmap(redsoldier); destroy_bitmap(buffer); allegro_exit(); return 0; } END_OF_MAIN(); Could someone help us please. [Edited by - jbadams on April 2, 2010 11:45:07 PM]

This topic is closed to new replies.

Advertisement