init commit, with sample code
This commit is contained in:
53
main.cpp
Normal file
53
main.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "SFML/Graphics.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Game started\n";
|
||||
sf::RenderWindow window(sf::VideoMode(600, 800), "My window");
|
||||
window.setVerticalSyncEnabled(true);
|
||||
window.setFramerateLimit(60);
|
||||
|
||||
sf::RectangleShape rectangle(sf::Vector2f(120.0f, 50.0f));
|
||||
float sizeIncrement = 1.0f;
|
||||
|
||||
while (window.isOpen()) {
|
||||
window.clear();
|
||||
|
||||
if(rectangle.getSize().x > 5 && rectangle.getSize().y > 5 && rectangle.getSize().x < 300 && rectangle.getSize().y < 300) {
|
||||
rectangle.setSize(rectangle.getSize() + sf::Vector2f(sizeIncrement, sizeIncrement));
|
||||
rectangle.setPosition(
|
||||
float(window.getSize().x) / 2 - rectangle.getSize().x / 2,
|
||||
float(window.getSize().y) / 2 - rectangle.getSize().y / 2
|
||||
);
|
||||
} else {
|
||||
rectangle.setSize(sf::Vector2f(120.0f, 50.0f));
|
||||
rectangle.setPosition(
|
||||
float(window.getSize().x) / 2 - rectangle.getSize().x / 2,
|
||||
float(window.getSize().y) / 2 - rectangle.getSize().y / 2
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Tu są handlowane eventy
|
||||
sf::Event event{};
|
||||
while (window.pollEvent(event)) {
|
||||
if(event.type == sf::Event::MouseWheelScrolled) {
|
||||
if(event.mouseWheelScroll.delta > 0) {
|
||||
sizeIncrement = 1.0f;
|
||||
} else {
|
||||
sizeIncrement = -1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.type == sf::Event::Closed)
|
||||
window.close();
|
||||
}
|
||||
|
||||
window.draw(rectangle);
|
||||
window.display();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user