50 lines
1.5 KiB
C++
50 lines
1.5 KiB
C++
#include <SFML/Graphics.hpp>
|
|
#include "vokzal.hpp"
|
|
using namespace std;
|
|
|
|
int main() {
|
|
// Створюємо вікно 1950x1200
|
|
sf::RenderWindow window(sf::VideoMode(1950, 1200), "Test Game Window");
|
|
//
|
|
vector<Platform> platforms;
|
|
platforms.push_back(Platform(299.f, 900.f, 200.f, 40.f));
|
|
platforms.push_back(Platform(700.f, 725.f, 200.f, 40.f));
|
|
platforms.push_back(Platform(1300.f, 700.f, 300.f, 50.f));
|
|
platforms.push_back(Platform(400.f, 600.f, 250.f, 30.f));
|
|
|
|
Platform ground(100.f, 1050.f, 300.f, 50.f);
|
|
|
|
window.setFramerateLimit(90); //вище 200 не рокимендую піднімати частоту після 600 буде чути писк дроселів
|
|
|
|
Player player;
|
|
|
|
sf::Clock gameClock;
|
|
|
|
while (window.isOpen()) {
|
|
sf::Event event;
|
|
while (window.pollEvent(event)) {
|
|
if (event.type == sf::Event::Closed)
|
|
window.close();
|
|
}
|
|
|
|
float deltaTime = gameClock.restart().asSeconds();
|
|
|
|
player.update(deltaTime, platforms); // логіка гравця
|
|
|
|
window.clear(sf::Color::Black); // очистка вікна
|
|
|
|
// малюємо платформи
|
|
for (auto& platform : platforms) {
|
|
platform.draw(window);
|
|
}
|
|
ground.draw(window);
|
|
|
|
// малюємо гравця
|
|
player.draw(window);
|
|
|
|
window.display(); // відображення
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|