wiktor16s Temat założony przez niniejszego użytkownika |
problem z kompilacją » 2012-02-06 21:20:30 Tak to znowu ja xD Poradziłem sobie z większością problemów. Został mi jeden malusieniusieńki problemik zaznaczyłem go //od tąd.......................................................... ... .. . //do tąd........................................................... Zanim przejde do kodu opowiem co nie działa. Więc, przy próbie kompilacji "nie kompiluje" wyświetla mi log: C:\wiktor\wiktor16s\src\allegro.cpp||In function 'bool kolizja()':| C:\wiktor\wiktor16s\src\allegro.cpp|57|warning: no return statement in function returning non-void| C:\wiktor\wiktor16s\src\allegro.cpp|81|error: expected unqualified-id before 'while'| ||=== Build finished: 1 errors, 1 warnings ===| Nie mam pojęcia o co chodzi... #include <allegro.h> #include <cmath>
int mx = 0, my = 0, mb = 0; void myszka() { if( mx != mouse_x || my != mouse_y || mb != mouse_b ) { mx = mouse_x; my = mouse_y; mb = mouse_b; } };
volatile long speed = 0; void increment_speed() { speed++; } END_OF_FUNCTION( increment_speed ); LOCK_VARIABLE( speed ); LOCK_FUNCTION( increment_speed );
int samochod_x = 100, samochod_y = 100; double tab_sin[ 72 ]; double tab_cos[ 72 ];
int sx = 188, sy = 384; double dx = 0, dy = 0; int kierunek = 54; double v = 0; int tx = 100, ty = 100;
void laduj_sin_cos() { for( int i = 0; i < 72; i++ ) { tab_sin[ i ] = sin(( M_PI *( i * 5 ) ) / 180 ); tab_cos[ i ] = cos(( M_PI *( i * 5 ) ) / 180 ); } }
bool kolizja( void ) { if( samochod_x < 500 ) v = 0; if( samochod_x > 100 ) v = 0; if( samochod_y < 800 ) v = 0; if( samochod_y > 0 ) v = 0; }
int mapa_x = 0, mapa_y = 0; BITMAP * teren = NULL; BITMAP * bufor = NULL; BITMAP * samochod = NULL; BITMAP * tlo = NULL; BITMAP * panbomba = NULL; BITMAP * tlo1 = NULL; BITMAP * przycisk = NULL; BITMAP * wyjscie = NULL; BITMAP * start = NULL; BITMAP * info = NULL; BITMAP * menutlo = NULL;
int start_x = 273, start_y = 320; int info_x = 273, info_y = 370; int wyjscie_x = 273, wyjscie_y = 420; int menutlo_x = 0, menutlo_y = 0;
while( !key[ KEY_ESC ] )
{ myszka(); menu: stop_sample( loseyou ); int kursor_x = mx - 40, kursor_y = my - 40; if( mouse_x >= start_x && mouse_x <= start_x + 260 ) { if( mouse_y >= start_y && mouse_y <= start_y + 48 ) { if( mb == 1 ) { play_sample( klik, 255, 127, 1000, 0 ); goto start; } } } if( mouse_x >= wyjscie_x && mouse_x <= wyjscie_x + 260 ) { if( mouse_y >= wyjscie_y && mouse_y <= wyjscie_y + 48 ) { if( mb == 1 ) { play_sample( klik, 255, 127, 1000, 0 ); goto wyjscie; } } } if( mouse_x >= info_x && mouse_x <= info_x + 260 ) { if( mouse_y >= info_y && mouse_y <= info_y + 48 ) { if( mb == 1 ) { play_sample( klik, 255, 127, 1000, 0 ); goto info; } } } clear_to_color( bufor, makecol( 100, 100, 100 ) ); masked_blit( menutlo, bufor, 0, 0, menutlo_x, menutlo_y, menutlo->w, menutlo->h ); textprintf_ex( bufor, font, 600, 589, makecol( 200, 200, 200 ), - 1, "x = %d, y = %d, mb= %d", mx, my, mb ); masked_blit( start, bufor, 0, 0, start_x, start_y, start->w, start->h ); masked_blit( info, bufor, 0, 0, info_x, info_y, info->w, info->h ); masked_blit( wyjscie, bufor, 0, 0, wyjscie_x, wyjscie_y, wyjscie->w, wyjscie->h ); masked_blit( kursor, bufor, 0, 0, kursor_x, kursor_y, kursor->w, kursor->h ); blit( bufor, screen, 0, 0, 0, 0, 800, 600 ); clear_keybuf(); }
short int map[ 15 ][ 20 ] = { 3, 3, 3, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 4, 3, 3, 3, 3, 3, 8, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 8, 3, 3, 3, 3, 3, 8, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 8, 3, 3, 3, 3, 3, 8, 0, 0, 7, 9, 9, 9, 9, 9, 9, 9, 4, 0, 0, 8, 3, 3, 3, 3, 3, 8, 0, 0, 8, 3, 3, 3, 3, 3, 3, 3, 8, 0, 0, 8, 3, 3, 3, 3, 3, 8, 0, 0, 8, 3, 3, 3, 3, 3, 3, 3, 8, 0, 0, 8, 3, 3, 3, 3, 3, 8, 0, 0, 8, 3, 3, 3, 3, 3, 3, 3, 8, 0, 0, 8, 3, 3, 3, 3, 3, 8, 0, 0, 8, 3, 3, 3, 3, 3, 3, 3, 8, 0, 0, 8, 3, 3, 3, 3, 3, 8, 0, 0, 8, 3, 3, 3, 3, 3, 3, 3, 8, 0, 0, 8, 3, 3, 3, 3, 3, 8, 10, 10, 8, 3, 3, 3, 3, 3, 3, 3, 8, 0, 0, 8, 3, 3, 3, 3, 3, 8, 0, 0, 8, 3, 3, 3, 3, 3, 3, 3, 8, 0, 0, 8, 3, 3, 3, 3, 3, 8, 0, 0, 6, 9, 9, 9, 9, 9, 9, 9, 5, 0, 0, 8, 3, 3, 3, 3, 3, 8, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 8, 3, 3, 3, 3, 3, 8, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 8, 3, 3, 3, 3, 3, 6, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 5, 3, 3 };
void wys_mape() { int licznik_x, licznik_y; for( licznik_x = 0; licznik_x < 20; licznik_x++ ) { for( licznik_y = 0; licznik_y < 15; licznik_y++ ) { blit( teren, bufor, ( map[ licznik_y + mapa_y ][ licznik_x + mapa_x ] % 4 ) * 40, ( map[ licznik_y + mapa_y ][ licznik_x + mapa_x ] / 4 ) * 40, licznik_x * 40, licznik_y * 40, 40, 40 ); } } };
int main() { allegro_init(); install_keyboard(); set_color_depth( 16 ); set_gfx_mode( GFX_AUTODETECT_FULLSCREEN, 800, 600, 0, 0 ); install_mouse(); show_mouse( screen ); unscare_mouse(); install_timer(); install_int_ex( increment_speed, BPS_TO_TIMER( 40 ) ); laduj_sin_cos(); samochod = load_bmp( "samochod.bmp", default_palette ); if( !samochod ) { set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 ); allegro_message( "nie mogê za³adowaæ obrazka Samochod !" ); allegro_exit(); return 0; } tlo = load_bmp( "tlo.bmp", default_palette ); if( !samochod ) { set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 ); allegro_message( "nie mogê za³adowaæ tla !" ); allegro_exit(); return 0; } bufor = create_bitmap( 800, 600 ); if( !bufor ) { set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 ); allegro_message( "Nie mogê utworzyæ bufora !" ); allegro_exit(); return 0; } teren = load_bmp( "teren.bmp", default_palette ); tlo1 = load_bmp( "tlo1.bmp", default_palette ); wyjscie = load_bmp( "bexit.bmp", default_palette ); start = load_bmp( "bstart.bmp", default_palette ); info = load_bmp( "bsettings.bmp", default_palette ); menutlo = load_bmp( "menutlo.bmp", default_palette ); while( !key[ KEY_ESC ] ) { while( speed > 0 ) { if(( key[ KEY_UP ] ) &&( samochod_y > 40 ) ) { v += 0.02; } if(( key[ KEY_DOWN ] ) &&( samochod_y < 600 ) ) { v -= 0.02; } if(( key[ KEY_LEFT ] ) &&( samochod_x > 20 ) ) { kierunek--; } else if(( key[ KEY_RIGHT ] ) &&( samochod_x < 780 ) ) { kierunek++; } if( key[ KEY_SPACE ] ) v -= 0.04; if( v < 0 ) v =- 0; speed--; } if( kierunek > 71 ) kierunek = 0; if( kierunek < 0 ) kierunek = 71; if( v > 1.1 ) v = 1.1; if( v <- 0.2 ) v =- 0.2; if( v <- 0.5 ) v =- 0.5; if( sx > 675 ) v = 0; if( sx < 132 ) v = 0; if( sy < 10 ) v = 0; if( sy > 550 ) v = 0; dx += v * tab_cos[ kierunek ]; dy += v * tab_sin[ kierunek ]; if( dx >= 1 || dx <= - 1 ) { sx += int( dx ); dx = dx - int( dx ); } if( dy >= 1 || dy <= - 1 ) { sy += int( dy ); dy = dy - int( dy ); } masked_blit( samochod, bufor,( kierunek % 18 ) * 30,( kierunek / 18 ) * 30, sx, sy, 30, 30 ); blit( bufor, screen, 0, 0, 0, 0, 800, 600 ); blit( bufor, screen, 0, 0, 0, 0, 800, 600 ); masked_blit( tlo1, bufor, 0, 0, 0, 0, 800, 600 ); clear_to_color( bufor, makecol( 150, 150, 150 ) ); wys_mape(); } remove_int( increment_speed ); destroy_bitmap( teren ); destroy_bitmap( bufor ); destroy_bitmap( samochod ); allegro_exit(); return 0; } END_OF_MAIN(); |