Created
August 18, 2016 13:02
-
-
Save senapk/484239ad037ba0c5a58ea3072e44183f to your computer and use it in GitHub Desktop.
FUP: Pulo da Pokebola
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEMPLATE = app | |
CONFIG += console c++11 | |
CONFIG -= app_bundle | |
CONFIG -= qt | |
LIBS += -lsfml-graphics -lsfml-window -lsfml-system | |
SOURCES += main.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <SFML/Graphics.hpp> | |
#include <cstdlib> | |
using namespace std; | |
int main() | |
{ | |
//lvalue = rvalue | |
sf::CircleShape pokebola(50); | |
float x = 350.0, y = 0.0; | |
float vy = 0.2; | |
float grav = 0.001; | |
pokebola.setPosition(sf::Vector2f(x, y)); | |
pokebola.setFillColor(sf::Color::Magenta); | |
sf::RenderWindow janela(sf::VideoMode(800, 600), "Super"); | |
while(janela.isOpen()){ | |
sf::Event evento; | |
while(janela.pollEvent(evento)){ | |
if(evento.type == sf::Event::Closed){ | |
janela.close(); | |
} | |
} | |
vy = vy + grav; | |
y = y + vy; | |
if(y > 500){ | |
vy = vy * -0.7; | |
y = 500; | |
} | |
pokebola.setPosition(sf::Vector2f(x, y)); | |
janela.clear(); | |
janela.draw(pokebola); | |
janela.display(); | |
} | |
return 0; | |
} | |
//criar a janela | |
//enquanto a janela estiver aberta{ | |
// enquanto tiver eventos na fila | |
// pegar um evento | |
// processa o evento | |
// se evento for de fechar a tela | |
// fecha a tela | |
// limpa a tela | |
// desenha os objetos | |
// mostra os objetos | |
//} | |
//fecha a janela |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Vídeo em
https://youtu.be/Ycvbsc2krL4