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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Whovian1701

Pages: [1]
1
General / Texture wont load
« on: October 30, 2021, 08:40:14 pm »
Hey, I want a Window with a green background and a texture in the middle, but my texture wont load, doess anyone know how to fix this?
This is the code:

#include <iostream>
#include <SFML/Graphics.hpp>
using namespace sf;

int main()
{
   RenderWindow Window(VideoMode(1000, 700), "MyGame");
   Texture texture;
   Sprite sprite;
   if (!texture.loadFromFile("Bug1.png"))
      std::cout << "nicht geladen" << std::endl;
      return -1;
   sprite.setTexture(texture);
   sprite.setScale(0.5f, 0.5f);
   sprite.setPosition(450, 320);
   
   while (Window.isOpen())
   {
      Event event;
      while (Window.pollEvent(event))
         if (event.type == Event::Closed) Window.close();
   }
   Window.clear(Color::Green);
   Window.draw(sprite);
   Window.display();
   

   return 0;
}

Pages: [1]
anything