Advertisement
Guest User

Untitled

a guest
Jan 28th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. // SFMLAudioTest.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <SFML/Graphics.hpp>
  6. #include <SFML/Audio.hpp>
  7.  
  8. int _tmain(int argc, _TCHAR* argv[])
  9. {
  10.     sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
  11.     sf::CircleShape shape(100.f);
  12.     shape.setFillColor(sf::Color::Green);
  13.     sf::Sound sound = sf::Sound();
  14.     sf::SoundBuffer buffer = sf::SoundBuffer();
  15.    
  16.     if(!buffer.loadFromFile("F:\\Soundboard\\Borderlands2\\Gaige\\TidalWaveUgly.wav"))
  17.         return -1;
  18.  
  19.     sound.setBuffer(buffer);
  20.  
  21.     while (window.isOpen())
  22.     {
  23.         sf::Event event;
  24.         while (window.pollEvent(event))
  25.         {
  26.             if (event.type == sf::Event::Closed)
  27.                 window.close();
  28.  
  29.             if (event.type == sf::Event::MouseButtonReleased)
  30.             {
  31.                 shape.setFillColor(sf::Color::Red);
  32.                 sound.play();
  33.             }
  34.         }
  35.  
  36.         window.clear();
  37.         window.draw(shape);
  38.         window.display();
  39.     }
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement