0 Members and 1 Guest are viewing this topic.
////////////////////////////////////////////////////////////// Headers////////////////////////////////////////////////////////////#include <SFML/Graphics.hpp>/////////////////////////////////////////////////////////////// Entry point of application////// \return Application exit code///////////////////////////////////////////////////////////////int main(){ // Create the main rendering window sfRenderWindow App(sfVideoMode(800, 600, 32), "SFML Graphics", false); // Load the sprite image from a file sfImage Image; if (!Image.LoadFromFile("sprite.tga")) return EXIT_FAILURE; // Create the sprite sfSprite Sprite(Image); // Change its properties Sprite.SetColor(sfColor(0, 255, 255, 128)); Sprite.SetLeft(200.f); Sprite.SetTop(100.f); Sprite.SetScale(2.f); // Start game loop bool Running = true; while (Running) { // Process events sfEvent Event; while (App.GetEvent(Event)) { // Close window : exit if (Event.Type == sfEvent::Close) Running = false; } // Get elapsed time float ElapsedTime = App.GetFrameTime(); // Move the sprite if (App.GetInput().IsKeyDown(sfKey::Left)) Sprite.SetLeft(Sprite.GetLeft() - 100 * ElapsedTime); if (App.GetInput().IsKeyDown(sfKey::Right)) Sprite.SetLeft(Sprite.GetLeft() + 100 * ElapsedTime); if (App.GetInput().IsKeyDown(sfKey::Up)) Sprite.SetTop(Sprite.GetTop() - 100 * ElapsedTime); if (App.GetInput().IsKeyDown(sfKey::Down)) Sprite.SetTop(Sprite.GetTop() + 100 * ElapsedTime); // Rotate the sprite if (App.GetInput().IsKeyDown(sfKey::Add)) Sprite.Rotate(- 100 * ElapsedTime); if (App.GetInput().IsKeyDown(sfKey::Subtract)) Sprite.Rotate(+ 100 * ElapsedTime); // Display sprite in our window App.Draw(Sprite); // Display window contents on screen App.Display(); } return EXIT_SUCCESS;}
error LNK2001: unresolved external symbol "public: bool __thiscall sfInput::IsKeyDown(enum sfKey::Code)const " (?IsKeyDown@sfInput@@QBE_NW4Code@sfKey@@@Z)
error LNK2001: unresolved external symbol "private: virtual void __thiscall sfWindow::OnEvent(class sfEvent const &)" (?OnEvent@sfWindow@@EAEXABVsfEvent@@@Z)
////////////////////////////////////////////////////////////// Headers////////////////////////////////////////////////////////////#include <SFML/Graphics.hpp>/////////////////////////////////////////////////////////////// Entry point of application////// \return Application exit code///////////////////////////////////////////////////////////////int main(){ // Create the main rendering window sfRenderWindow App(sfVideoMode(800, 600, 32), "SFML Graphics", false); sfString Text("Hello SFML", "cheeseburger.ttf", 50); bool Running = true; while (Running) { // Process events sfEvent Event; while (App.GetEvent(Event)) { // Close window : exit if (Event.Type == sfEvent::Close) Running = false; } App.Draw(Text); // Display window contents on screen App.Display(); } return EXIT_SUCCESS;}
Unhandled exception at 0x7c812a5b in sfml1.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012f45c.