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

Author Topic: Start a game w/o console  (Read 1426 times)

0 Members and 1 Guest are viewing this topic.

TheEnigmist

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Start a game w/o console
« on: July 23, 2011, 04:35:53 pm »
I came back some day ago on this project and i see it changed a lot :D Before I made stupid windows for console application, but now i want to try to open a win32 window. I made this stupid code for example:
Code: [Select]

#include <SFML/Graphics.hpp>

int main()
{
sf::RenderWindow App(sf::VideoMode(1024,768,32),"Test Game",sf::Style::Close);
sf::View camera;
camera.SetSize(App.GetWidth(),App.GetHeight());

sf::Image background, Ship;
if ((!background.LoadFromFile("Images/background.png")) || (!Ship.LoadFromFile("Images/ship.jpg")))
{
return EXIT_FAILURE;
}

sf::Sprite sfondo (background);
sf::Sprite nave (Ship);

App.Clear();

sf::Event Eventi;

while (App.IsOpened())
{
while (App.PollEvent(Eventi))
{
switch (Eventi.Type)
{
case sf::Event::Closed:
App.Close();
break;

case sf::Event::KeyPressed:
if (Eventi.Key.Code == sf::Keyboard::Escape)
{
App.Close();
}
break;
default:
break;
}
}

App.Draw(sfondo);
App.Display();

}

return 0;
}

But when i start the program open the windows and close it faster. What do i wrong? :O
Sorry for bad eng :(

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Start a game w/o console
« Reply #1 on: July 23, 2011, 05:50:01 pm »
Make sure that the program is not terminating on the "return EXIT_FAILURE" line, which would mean that it failed to load the images.
Laurent Gomila - SFML developer

TheEnigmist

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Start a game w/o console
« Reply #2 on: July 23, 2011, 08:23:12 pm »
Quote from: "Laurent"
Make sure that the program is not terminating on the "return EXIT_FAILURE" line, which would mean that it failed to load the images.

Found the error, it was .png not .jpg... now it open well :) Thx...
EDIT: i found a new error, when load my background.png (an image 2000x1250) it say me this error "Corrupt PNG".
What is that? Is too big for SFML? O.o
MAde again the image and now all start :S