Riyyi
10 years ago
3 changed files with 76 additions and 8 deletions
@ -1,10 +1,68 @@
|
||||
#include <iostream> |
||||
|
||||
using namespace std; |
||||
#include <SFML/Graphics.hpp> |
||||
|
||||
int main() |
||||
{ |
||||
cout << "Hello World!" << endl; |
||||
std::cout << "Hello World!" << std::endl; |
||||
|
||||
std::string gameName = "rpg"; |
||||
unsigned int windowStyle = sf::Style::Titlebar | sf::Style::Close; |
||||
sf::ContextSettings settings; |
||||
settings.antialiasingLevel = 16; |
||||
|
||||
sf::RenderWindow window(sf::VideoMode(1280, 720), gameName, windowStyle, settings); |
||||
window.setVerticalSyncEnabled(true); |
||||
|
||||
sf::Clock fpsTimer; |
||||
sf::Clock timer; |
||||
sf::Time timeElapsed; |
||||
|
||||
// Run the program as long as the window is open
|
||||
while (window.isOpen()) |
||||
{ |
||||
// Check all the window's events that were triggered since the last iteration of the loop
|
||||
sf::Event event; |
||||
while (window.pollEvent(event)) |
||||
{ |
||||
// Close window : exit
|
||||
if (event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) |
||||
window.close(); |
||||
|
||||
// Enter fullscreen mode : key combination : Alt+Enter
|
||||
if (event.type == sf::Event::KeyPressed) { |
||||
if (event.key.code == sf::Keyboard::Return) { |
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::LAlt)) { |
||||
if (windowStyle == sf::Style::Fullscreen) { |
||||
windowStyle = sf::Style::Titlebar | sf::Style::Close; |
||||
} |
||||
else { |
||||
windowStyle = sf::Style::Fullscreen; |
||||
} |
||||
|
||||
window.create(sf::VideoMode(1280, 720), gameName, windowStyle, settings); |
||||
window.setVerticalSyncEnabled(true); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
window.clear(sf::Color(0, 0, 0)); |
||||
window.display(); |
||||
|
||||
timeElapsed = timer.getElapsedTime(); |
||||
if (timeElapsed.asSeconds() > 1) |
||||
{ |
||||
// Display current FPS in window title
|
||||
timeElapsed = fpsTimer.getElapsedTime(); |
||||
int fps = 1000000 / timeElapsed.asMicroseconds(); |
||||
window.setTitle(gameName + " - fps: " + std::to_string(fps)); |
||||
|
||||
timer.restart(); |
||||
} |
||||
|
||||
fpsTimer.restart(); |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
|
@ -1,10 +1,20 @@
|
||||
TEMPLATE = app |
||||
CONFIG += console |
||||
CONFIG += c++11 |
||||
CONFIG -= app_bundle |
||||
CONFIG -= qt |
||||
|
||||
SOURCES += main.cpp |
||||
|
||||
include(deployment.pri) |
||||
qtcAddDeployment() |
||||
|
||||
LIBS += -LC:/SFML/lib |
||||
|
||||
CONFIG(release, debug|release): LIBS += -lsfml-audio -lsfml-graphics -lsfml-main -lsfml-network -lsfml-window -lsfml-system |
||||
CONFIG(debug, debug|release): LIBS += -lsfml-audio-d -lsfml-graphics-d -lsfml-main-d -lsfml-network-d -lsfml-window-d -lsfml-system-d |
||||
|
||||
INCLUDEPATH += C:/SFML/include |
||||
DEPENDPATH += C:/SFML/include |
||||
|
||||
TEMPLATE = app |
||||
|
||||
SOURCES += main.cpp |
||||
|
||||
|
Loading…
Reference in new issue