When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
11 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
!f
#include <SFML/Graphics.hpp>
#include <iostream>
int main() {
sf::RenderWindow window(sf::VideoMode(800, 600), "Not Tetris");
sf::Event event;
sf::Clock clock;
sf::Texture druga;
if (!druga.loadFromFile("bg.png")) {
std::cout << "nece cita nodija";
}
sf::Sprite drugi;
drugi.setOrigin(0.5, 0.5);
drugi.setTexture(druga);
sf::Texture zmaj;
if (!zmaj.loadFromFile("zmaj.png")) {
std::cout << "nece cita nodija zmaj";
}
sf::Sprite spr;
spr.setTexture(zmaj);
spr.setScale(0.2, 0.2);
zmaj.setSmooth(true);
float ax;
float ay;
float dx;
float dy;
int i = 0;
sf::Texture patos;
if (!patos.loadFromFile("zemlja.png")) {
std::cout << "nece cita nodija 2\n";
}
sf::Sprite pod;
pod.setTexture(patos);
pod.setPosition(0, 500);
while (window.isOpen()) {
while (window.pollEvent(event)) {
switch (event.type) {
case sf::Event::Closed:
window.close();
break;
case sf::Event::KeyPressed:
switch (event.key.code) {
case sf::Keyboard::Escape:
window.close();
break;
case sf::Keyboard::Left:
drugi.rotate(15.f);
break;
case sf::Keyboard::Right:
drugi.rotate(-15.f);
break;
}
break;
default:
break;
}
////////////////////// scene update
ay = 9.81;
sf::Time dt = clock.restart();
spr.setPosition(spr.getPosition().x,
spr.getPosition().y + ay * dt.asSeconds());
//////////////////////
window.clear();
window.draw(drugi);
window.draw(pod);
window.draw(spr);
window.display();
std::cout << i << std::endl;
i++;
}
}
return 0;
}
Is the drawing stuff in your event loop? I can't easily tell
Oh yeah it id
Might be as easy as moving that close brace :)
The one making the event while loop
In this formatted version it's the second to last one before the return
I would bet if you moved your mouse on the game it would run again
This is why people are religious about auto formatting btw, it makes stuff like this more obvious
@dense field Has your question been resolved? If so, run !solved :)