Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SFML/Graphics.hpp> // We only need this for all SFML Graphics stuffs
- using namespace std;
- void getEvents(sf::RenderWindow& App); // Here we pass App by reference for speed and efficiency
- int const SCREEN_WIDTH = 800;
- int const SCREEN_HEIGHT = 600;
- int main(){
- sf::RenderWindow App(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT), "Our Title");//Makes our window to draw on
- sf::Image img; // Class that holds our image to draw
- sf::Sprite s; // Object we use to draw to the screen
- if(!img.LoadFromFile("TheGame.png")) // Returns false if image fails to load
- return 0; // Kills our program if an error is thrown
- s.SetImage(img); // Sets up our sprite to draw
- while(App.IsOpened()){
- getEvents(App); // Get our window events (Closing, resizing, etc)
- //Inputs are another thing I'll refer you to tutorials about
- App.Clear(); // Clear window
- App.Draw(s); // Draw our sprite
- App.Update(); // Update our window
- }
- return 0;
- }
- void getEvents(sf::RenderWindow& App){
- Event e;//Event object for our window
- while(App.GetEvent(e)){
- if(e.Type == sf::Event::Close) // If our window closes
- App.Close(); // Close our window
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement