R0ut4 Temat założony przez niniejszego użytkownika |
[SFML/C++] Podawanie argumentów dla funkcji w innego pliku » 2021-04-23 02:05:45 Yo, Nie bardzo wiem jak to rozwiązać. Próbowałem już kilku sposobów: PROBLEM: [log ||=== Build: Debug in game (compiler: GNU GCC Compiler) ===| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.hpp|4|error: 'HM' has not been declared| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.hpp|4|error: 'WM' has not been declared| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.hpp|4|error: 'G' has not been declared| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.hpp|4|error: 'G1' has not been declared| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.hpp|4|error: 'HM' has not been declared| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.hpp|4|error: 'WM' has not been declared| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.hpp|4|error: 'G' has not been declared| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.hpp|4|error: 'G1' has not been declared| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.hpp|4|error: 'ST' has not been declared| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.cpp|6|error: 'HM' has not been declared| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.cpp|6|error: 'WM' has not been declared| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.cpp|6|error: 'G' has not been declared| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.cpp|6|error: 'G1' has not been declared| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.cpp|6|error: 'ST' has not been declared| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.cpp||In function 'void playerMove(Gracz&, sf::View, int, int, int, int, int)':| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.cpp|28|error: 'WM' was not declared in this scope| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.cpp|30|error: 'start' was not declared in this scope| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.cpp|30|note: suggested alternative: 'stat'| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.cpp|30|error: 'G1' was not declared in this scope| ||=== Build failed: 17 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===| C:\Users\routa\Desktop\Prpogramy c++\game\playermove.hpp|4|error: 'ST' has not been declared| ||=== Build failed: 18 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===| [/log] Main.cpp #include <SFML/Window.hpp> #include <SFML/Graphics.hpp> #include "tilemap.hpp" #include "playermove.hpp" #include "player.hpp"
enum Stan { Menu, Game, Game1, Eq };
int main() { sf::RenderWindow window( sf::VideoMode( 1280, 720 ), "Game" ); window.setFramerateLimit( 60 ); const int level[ ] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 1, 0, 0, 2, 0, 3, 3, 3, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 3, 3, 3, 0, 0, 0, 1, 1, 1, 2, 0, 0, 0, 0, 1, 0, 3, 0, 2, 2, 0, 0, 1, 1, 1, 1, 2, 0, 2, 0, 1, 0, 3, 0, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 3, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1, }; const int level1[ ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 2, 2, 1, 1, 1, 2, 2, 3, 0, 0, 1, 1, 1, 1, 1, 3, 3, 3, 1, 1, 1, 1, 1, 3, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; TileMap map1; if( !map1.load(( "tileset.png" ), sf::Vector2u( 100, 100 ), level, 16, 8 ) ) { return - 1; } TileMap map2; if( !map2.load(( "tileset.png" ), sf::Vector2u( 100, 100 ), level1, 16, 8 ) ) { return - 1; } Gracz spPlayer; spPlayer.setOrigin( 25.f, 25.f ); spPlayer.setPosition( 640, 360 ); sf::View kamera; kamera.setCenter( spPlayer.getPosition() ); kamera.setSize ( 640.f, 360.f ); Stan start; int widthmap = 1280, heightmap = 720; sf::Event e; while( window.isOpen() ) { while( window.pollEvent( e ) ) { if( e.type == sf::Event::Closed ) { window.close(); } } switch( start ) { case Menu: { if( sf::Keyboard::isKeyPressed( sf::Keyboard::Enter ) ) { start = Game; } } break; case Game: { playerMove( spPlayer, kamera, heightmap, widthmap, Game, Game1, start ); } break; case Game1: break; case Eq: break; } window.clear(); switch( start ) { case Menu: break; case Game: { window.draw( map1 ); window.draw( spPlayer ); window.setView( kamera ); } break; case Game1: { window.draw( map1 ); window.draw( spPlayer ); window.setView( kamera ); } break; case Eq: break; } window.display(); } }
playermove.hpp #ifndef playermove_hpp #define playermove_hpp #include "player.hpp" void playerMove( Gracz & hero, sf::View cam, HM, WM, G, G1, ST ); #endif playermove.cpp #include <SFML/Graphics.hpp> #include <SFML/Window.hpp> #include "playermove.hpp" #include "player.hpp"
void playerMove( Gracz & hero, sf::View cam, HM, WM, G, G1, ST ) { if( sf::Keyboard::isKeyPressed( sf::Keyboard::W ) ) { hero.move( 0, - 2 ); cam.move( 0, - 2 ); } if( sf::Keyboard::isKeyPressed( sf::Keyboard::S ) ) { hero.move( 0, 2 ); cam.move( 0, 2 ); } if( sf::Keyboard::isKeyPressed( sf::Keyboard::A ) ) { hero.move( - 2, 0 ); cam.move( - 2, 0 ); } if( sf::Keyboard::isKeyPressed( sf::Keyboard::D ) ) { hero.move( 2, 0 ); cam.move( 2, 0 ); } if( hero.getPosition().x == WM ) { start = G1; } }
|