hincu Temat założony przez niniejszego użytkownika |
[SFML, C++] Wyświetlanie mapy kafelkowej » 2011-11-18 21:52:48 Witam mam pewien problem z wyswietlaniem mapy kafelkowej dokladnie chodzi o to ze wyswietla mi sie ciagle bialy ekran i za cholere nie moge znalezc bledu w kodzie XD prosze o HALP #include <SFML/Graphics.hpp>
#define wys_kafelka 32 #define szer_kafelka 32 using namespace sf;
int map_x = 1; int map_y = 1; int main() { RenderWindow plansza( VideoMode( 800, 600, 32 ), "Plansza" ); plansza.SetFramerateLimit( 120 ); Image tile1; tile1.LoadFromFile( "gfx/tile1.png" ); Sprite spr1; spr1.SetImage( tile1 ); Image tile2; tile2.LoadFromFile( "gfx/tile2.png" ); Sprite spr2; spr2.SetImage( tile2 ); Image tile3; tile3.LoadFromFile( "gfx/tile3.png" ); Sprite spr3; spr3.SetImage( tile3 ); int mapa[ 15 ][ 15 ] = { { 2, 2, 2, 2, 2, 1, 2, 3, 3, 1, 3, 1, 2, 3, 1 }, { 1, 1, 1, 1, 1, 3, 2, 2, 1, 1, 1, 1, 3, 1, 2 }, { 2, 2, 2, 2, 2, 2, 3, 3, 1, 3, 2, 2, 3, 1, 3 }, { 1, 1, 1, 1, 1, 3, 3, 2, 2, 1, 2, 2, 1, 3, 1 }, { 3, 3, 3, 3, 3, 3, 3, 2, 2, 1, 2, 2, 1, 3, 1 }, { 2, 2, 2, 2, 2, 3, 3, 2, 2, 1, 2, 2, 1, 3, 1 }, { 1, 1, 1, 1, 1, 3, 3, 2, 2, 2, 3, 2, 1, 3, 1 }, { 2, 2, 2, 2, 2, 3, 3, 2, 2, 1, 1, 2, 1, 3, 1 }, { 1, 1, 1, 1, 3, 2, 1, 1, 3, 3, 2, 1, 3, 2, 2 }, { 3, 3, 3, 3, 2, 1, 1, 3, 3, 2, 1, 3, 2, 2, 3 }, { 2, 2, 2, 2, 3, 3, 3, 2, 2, 1, 2, 2, 1, 3, 1 }, { 1, 1, 1, 1, 3, 3, 2, 2, 1, 2, 2, 1, 3, 1, 2 }, { 2, 2, 2, 2, 2, 1, 1, 3, 3, 2, 1, 3, 2, 2, 3 }, { 1, 1, 1, 1, 1, 2, 3, 3, 1, 3, 1, 2, 3, 1, 2 }, { 3, 3, 3, 3, 2, 1, 1, 3, 3, 2, 1, 3, 2, 2, 1 } }; plansza.Clear( Color( 255, 0, 0 ) ); while( plansza.IsOpened() ) { Event zdarzenie; while( plansza.GetEvent( zdarzenie ) ) { if( zdarzenie.Type == Event::Closed ) plansza.Close(); } } for( int i = 0; i > 15; i++ ) { for( int j = 0; j > 15; j++ ) { if( mapa[ i ][ j ] == 1 ) { spr1.SetPosition( szer_kafelka * map_x, wys_kafelka * map_y ); plansza.Draw( spr1 ); break; } if( mapa[ i ][ j ] == 2 ) { spr1.SetPosition( szer_kafelka * map_x, wys_kafelka * map_y ); plansza.Draw( spr2 ); break; } if( mapa[ i ][ j ] == 3 ) { spr1.SetPosition( szer_kafelka * map_x, wys_kafelka * map_y ); plansza.Draw( spr3 ); break; } map_x++; map_y++; } } plansza.Display(); } |