Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: can't draw sprite to screen  (Read 1662 times)

0 Members and 1 Guest are viewing this topic.

leonziyo

  • Newbie
  • *
  • Posts: 3
    • View Profile
can't draw sprite to screen
« on: July 23, 2011, 08:11:21 pm »
hi, can anybody tell me why this code is not working, it compiles but it crashes it only says that the game.exe stopped working and then i got to close it here is the code

Code: [Select]
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{

sf::RenderWindow mainW(sf::VideoMode(800, 600, 32),"lol this doesn't work");
sf::Image myImage;
sf::Sprite mySprite;


if(!myImage.LoadFromFile("lol.tga"))
std::cout << "error loading "<< std::endl;
else
std::cout << "load successful" <<std::endl;

mySprite.SetImage(myImage);
mySprite.SetPosition(50.f,20.f);

while(mainW.IsOpened())
{
sf::Event myEvent;
while(mainW.GetEvent(myEvent))
{

if(myEvent.Type == sf::Event::Closed)
mainW.Close();

if((myEvent.Type == sf::Event::KeyPressed) &&(myEvent.Key.Code == sf::Key::Left))
mainW.Draw(mySprite);

}

mainW.Clear();
mainW.Display();
}

return EXIT_SUCCESS;
}


i linked like this:

sfml-system-d.lib
sfml-window-d.lib
sfml-graphics-d.lib

and i included SFML_DYNAMIC in the preprocessor....and inlcuded the files to my project in the project folder... i also tried this

sfml-system.lib
sfml-window.lib
sfml-graphics.lib

but none of them work so i'm kind of lost help guys

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
can't draw sprite to screen
« Reply #1 on: July 23, 2011, 08:41:43 pm »
In case you use Visual Studio 2010 with SFML 1.6, you have to recompile SFML. The VS 2008 libraries are not compatible. Otherwise, what SFML version, OS and compiler do you use?

And make sure you link the correct libraries (with "-d" postfix in debug mode, without in release mode). If you link statically, you also need to insert "-s" at the end of your library names.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything