[SFML] Kolizja
Ostatnio zmodyfikowano 2017-11-19 02:54
pysiek.1996 Temat założony przez niniejszego użytkownika |
[SFML] Kolizja » 2017-11-18 23:08:30 Witam serdecznie. Mam napisane wykrywanie kolizji playera z obiektami, jednak jest ono niedokładne ponieważ gracz się obraca. Wiec moje pytanie, jak uzyskać BoudingBox który się nie obraca pomimo tego iż gracz bedzie się obracał. void Engine::check_collision() { if( player.getStatus() == Gracz::STOP ) return; FloatRect box1( player.getBoundingBox() ); box1.left +=( player.getSpeed( AD, WS ).x ) * 10; box1.top +=( player.getSpeed( AD, WS ).y ) * 10; int x =( box1.left + 15 ) / level.tile_width; int y =( box1.top + 15 ) / level.tile_height; if( level.poziom[ y ][ x ].isWall && box1.intersects( sprite[ y ][ x ].getGlobalBounds() ) ) { player.stoj(); } x =( box1.left + level.tile_width + 15 ) / level.tile_width; y =( box1.top + 15 ) / level.tile_height; if( level.poziom[ y ][ x ].isWall && box1.intersects( sprite[ y ][ x ].getGlobalBounds() ) ) { player.stoj(); } x =( box1.left + 15 ) / level.tile_width; y =( box1.top + 15 + level.tile_height ) / level.tile_height; if( level.poziom[ y ][ x ].isWall && box1.intersects( sprite[ y ][ x ].getGlobalBounds() ) ) { player.stoj(); } x =( box1.left + level.tile_width ) / level.tile_width; y =( box1.top + level.tile_height ) / level.tile_height; if( level.poziom[ y ][ x ].isWall && box1.intersects( sprite[ y ][ x ].getGlobalBounds() ) ) { player.stoj(); } }
|
|
latajacaryba |
» 2017-11-19 02:54:46 Odpowiedź to koło, ale czy ono będzie dla Ciebie wystarczająco dokładne? |
|
« 1 » |