Sprite Rysuje się na nowej pozyci za każdym razem
Ostatnio zmodyfikowano 2011-10-03 21:27
marc_xxx Temat założony przez niniejszego użytkownika |
Sprite Rysuje się na nowej pozyci za każdym razem » 2011-10-03 20:18:30 Oto moja gra: #include <SFML/Window.hpp> #include <SFML/Graphics.hpp> #include <SFML/System.hpp>
int main() { sf::RenderWindow mainWindow( sf::VideoMode( 800, 600, 32 ), "Immortal Gortat" ); sf::Image ball; ball.LoadFromFile( "ball.jpg" ); sf::Sprite spriteBall; spriteBall.SetImage( ball ); spriteBall.SetPosition( 400, 300 ); while( mainWindow.IsOpened() ) { sf::Event mainEvent; while( mainWindow.GetEvent( mainEvent ) ) { if( mainEvent.Type == sf::Event::Closed ) mainWindow.Close(); if( mainEvent.Type == sf::Event::KeyPressed && mainEvent.Key.Code == sf::Key::Escape ) mainWindow.Close(); if( mainEvent.Type == sf::Event::MouseButtonPressed && mainEvent.MouseButton.Button == sf::Mouse::Middle ) mainWindow.Close(); if( mainEvent.Type == sf::Event::KeyPressed && mainEvent.Key.Code == sf::Key::W ) spriteBall.Move( 0, - 5 ); if( mainEvent.Type == sf::Event::KeyPressed && mainEvent.Key.Code == sf::Key::S ) spriteBall.Move( 0, + 5 ); if( mainEvent.Type == sf::Event::KeyPressed && mainEvent.Key.Code == sf::Key::A ) spriteBall.Move( - 5, 0 ); if( mainEvent.Type == sf::Event::KeyPressed && mainEvent.Key.Code == sf::Key::D ) spriteBall.Move( + 5, 0 ); } mainWindow.Display(); mainWindow.Draw( spriteBall ); } return 0; } Gdy próbuję przesuwać obiekt To on rysuje mi się na każdej nowej pozycji i tworzy mi się coś w rodzaju węża jak to naprawić? |
|
SeaMonster131 |
» 2011-10-03 20:31:23 W kursie jest to chyba wszystko napisane.. 2x buforowanie chyba ;p |
|
DejaVu |
» 2011-10-03 21:27:53 Czyść ekran za każdym razem :) |
|
« 1 » |