-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestmain.cpp
More file actions
57 lines (53 loc) · 1.38 KB
/
testmain.cpp
File metadata and controls
57 lines (53 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
// Load a sprite to display
sf::Texture texture;
if (!texture.loadFromFile("cute_image.png"))
return EXIT_FAILURE;
sf::Sprite sprite(texture);
// Create a graphical text to display
sf::Font font;
if (!font.loadFromFile("arial.ttf"))
return EXIT_FAILURE;
sf::Text text("Hi Bunny", font, 50);
//THIS CODE DOESNT WORK!
// Load a music to play
// sf::Music music;
// if (!music.openFromFile("lem.oog"))
// return EXIT_FAILURE;
// // Play the music
// music.play();
sf::Music Music1;
if (!Music1.openFromFile("fairy.ogg"))
{
// Error...
std::cout<<"Error...";
}
Music1.play();
// Start the game loop
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close window: exit
if (event.type == sf::Event::Closed)
window.close();
}
// Clear screen
window.clear();
// Draw the sprite
window.draw(sprite);
// Draw the string
window.draw(text);
// Update the window
window.display();
}
return EXIT_SUCCESS;
}