Untitled
user_5811307
plain_text
2 years ago
1.1 kB
6
Indexable
#include <iostream>
#include <SFML/Graphics.hpp>
int main()
{
int width = 1280, height = 720;
sf::RenderWindow window(sf::VideoMode(width, height), "SFML Application");
sf::CircleShape shape;
shape.setRadius(100.f);
shape.setPosition(100.f, 100.f);
shape.setFillColor(sf::Color::Cyan);
float x = 0 , y=0, g =0, h =0;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
if (g == 10){
shape.setPosition(x, y);
std::cout << y << std::endl;
if (y == 0){
h =0;
}
else if (y == height- 190)
{
h =1;
}
if (h == 0)
{
y++;
}
else if (h == 1){
y--;
}
g=0;
}
window.clear();
window.draw(shape);
window.display();
g++;
}
}Editor is loading...
Leave a Comment