Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Main.h:
- #pragma once
- #include <Windows.h>
- #include <WindowsX.h>
- #include <iostream>
- #include <vector>
- #include <list>
- #include <ctime>
- #include <cmath>
- #include <d3d9.h>
- #include <d3dx9.h>
- #include <SFML/Audio.hpp>
- #pragma comment (lib, "d3d9.lib")
- #pragma comment (lib, "d3dx9.lib")
- using namespace std;
- #define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
- Main.cpp:
- #include "Main.h"
- sf::SoundBuffer Buffer;
- sf::Sound Sound(Buffer);
- void LoadSoundSFML();
- void PlaySoundSFML();
- bool Edown;
- int main()
- {
- LoadSoundSFML();
- // Quit on escape key press
- while(KEY_DOWN(VK_ESCAPE) == false)
- {
- // E key
- if(KEY_DOWN(0x45) && Edown)
- {
- // Do nothing
- }
- else if(KEY_DOWN(0x45))
- {
- cout << "Playing sound\n";
- PlaySoundSFML();
- Edown = true;
- }
- else
- Edown = false;
- }
- return 0;
- }
- void LoadSoundSFML()
- {
- // Load a sound buffer from a wav file
- if (!Buffer.LoadFromFile("Test3.wav"))
- return;
- }
- void PlaySoundSFML()
- {
- // Play sound instance
- Sound.SetVolume(100);
- Sound.Play();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement