int main()
{
RenderWindow App( VideoMode( 480, 480, 32 ), "..." );
App.SetFramerateLimit( 60 );
Event event;
Clock timer;
int sk = 32, wk = 32;
int map_x = 0, map_y = 0;
int Speed = 100;
float d;
Image ki1, ki2, ki3;
ki1.LoadFromFile( "images/kafelek1.png" );
ki2.LoadFromFile( "images/kafelek2.png" );
ki2.LoadFromFile( "images/kafelek3.png" );
Sprite k1, k2, k3;
k1.SetImage( ki1 );
k2.SetImage( ki2 );
k3.SetImage( ki3 );
int mapa[ 15 ][ 15 ] = {
{ 2, 2, 2, 2, 2, 1, 2, 3, 3, 1, 3, 1, 2, 3, 1 },
{ 1, 1, 3, 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, 1, 3, 2, 1, 3, 2, 2, 3 },
{ 2, 2, 2, 2, 3, 3, 3, 1, 2, 1, 2, 2, 1, 3, 1 },
{ 1, 1, 1, 1, 3, 3, 2, 1, 1, 2, 2, 1, 3, 1, 2 },
{ 2, 2, 2, 2, 2, 1, 1, 1, 3, 2, 1, 3, 2, 2, 3 },
{ 1, 1, 1, 1, 1, 1, 1, 2, 1, 3, 1, 2, 3, 1, 2 },
{ 3, 3, 3, 3, 1, 1, 3, 3, 3, 3, 1, 3, 3, 3, 3 } };
while( App.IsOpened() )
{
d = App.GetFrameTime();
timer.Reset();
map_y = 0;
for( int i = 0; i < 15; i++ )
{
map_x = 0;
for( int j = 0; j < 15; j++ )
{
if( mapa[ i ][ j ] == 1 )
{
k1.SetPosition( map_x, map_y );
App.Draw( k1 );
}
if( mapa[ i ][ j ] == 2 )
{
k2.SetPosition( map_x, map_y );
App.Draw( k2 );
}
if( mapa[ i ][ j ] == 3 )
{
k3.SetPosition( map_x, map_y );
App.Draw( k3 );
}
map_x += 32;
}
map_y += 32;
}
while( App.GetEvent( event ) )
{
if( event.Type == Event::Closed )
App.Close();
if( event.Type == Event::KeyPressed && event.Key.Code == Key::Escape )
App.Close();
const Input & ctrl = App.GetInput();
if( ctrl.IsKeyDown( Key::Left ) || ctrl.IsKeyDown( Key::A ) )
map_x--;
if( ctrl.IsKeyDown( Key::Right ) || ctrl.IsKeyDown( Key::D ) )
map_x++;
if( ctrl.IsKeyDown( Key::Up ) || ctrl.IsKeyDown( Key::W ) )
map_y--;
if( ctrl.IsKeyDown( Key::Down ) || ctrl.IsKeyDown( Key::S ) )
map_y++;
}
App.Display();
getch();
}
return 0;
}