Pessoal, tenho uma duvida, tenho um código em C++ com SFML, desenhei uma figuras na tela e fiz interação com o teclado para movimento das mesmas, mas gostaria de saber como eu faço para fazer cada figura de uma vez aumentar e diminuir de tamanho?
Se alguem puder me ajudar eu agradeço, segue o código:
[code]#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include
int main() {
// Inicializacao da biblioteca
sf::RenderWindow* app = new sf::RenderWindow(sf::VideoMode(800, 600, 32), “Teste de imput do teclado!”);
int xCircle = 300;
int yCircle = 300;
int xLine = 10;
int yLine = 10;
int x1Line = 100;
int y1Line = 100;
int xRect = 150;
int yRect = 150;
int x1Rect = 200;
int y1Rect = 200;
int xPolygon = 100;
int yPolygon = 100;
int x1Polygon = 150;
int y1Polygon = 200;
int x2Polygon = 80;
int y2Polygon = 150;
// Gamelooping
while (app->IsOpened()) {
// Process game input
sf::Event* event = new sf::Event();
while (app->GetEvent(*event)) {
if (event->Type == sf::Event::Closed) {
app->Close();
}
}
if (app->GetInput().IsKeyDown(sf::Key::Escape)) {
return EXIT_SUCCESS;
}
// Simulate Game World movimentation
if (app->GetInput().IsKeyDown(sf::Key::Up)) yCircle--;
else if (app->GetInput().IsKeyDown(sf::Key::Down)) yCircle++;
else if (app->GetInput().IsKeyDown(sf::Key::Left)) xCircle--;
else if (app->GetInput().IsKeyDown(sf::Key::Right)) xCircle++;
if (app->GetInput().IsKeyDown(sf::Key::W)) yLine--;
else if (app->GetInput().IsKeyDown(sf::Key::S)) yLine++;
else if (app->GetInput().IsKeyDown(sf::Key::A)) xLine--;
else if (app->GetInput().IsKeyDown(sf::Key::D)) xLine++;
if (app->GetInput().IsKeyDown(sf::Key::W)) y1Line--;
else if (app->GetInput().IsKeyDown(sf::Key::S)) y1Line++;
else if (app->GetInput().IsKeyDown(sf::Key::A)) x1Line--;
else if (app->GetInput().IsKeyDown(sf::Key::D)) x1Line++;
if (app->GetInput().IsKeyDown(sf::Key::I)) yRect--;
else if (app->GetInput().IsKeyDown(sf::Key::K)) yRect++;
else if (app->GetInput().IsKeyDown(sf::Key::J)) xRect--;
else if (app->GetInput().IsKeyDown(sf::Key::L)) xRect++;
if (app->GetInput().IsKeyDown(sf::Key::I)) y1Rect--;
else if (app->GetInput().IsKeyDown(sf::Key::K)) y1Rect++;
else if (app->GetInput().IsKeyDown(sf::Key::J)) x1Rect--;
else if (app->GetInput().IsKeyDown(sf::Key::L)) x1Rect++;
if (app->GetInput().IsKeyDown(sf::Key::T)) yPolygon--;
else if (app->GetInput().IsKeyDown(sf::Key::G)) yPolygon++;
else if (app->GetInput().IsKeyDown(sf::Key::F)) xPolygon--;
else if (app->GetInput().IsKeyDown(sf::Key::H)) xPolygon++;
if (app->GetInput().IsKeyDown(sf::Key::T)) y1Polygon--;
else if (app->GetInput().IsKeyDown(sf::Key::G)) y1Polygon++;
else if (app->GetInput().IsKeyDown(sf::Key::F)) x1Polygon--;
else if (app->GetInput().IsKeyDown(sf::Key::H)) x1Polygon++;
if (app->GetInput().IsKeyDown(sf::Key::T)) y2Polygon--;
else if (app->GetInput().IsKeyDown(sf::Key::G)) y2Polygon++;
else if (app->GetInput().IsKeyDown(sf::Key::F)) x2Polygon--;
else if (app->GetInput().IsKeyDown(sf::Key::H)) x2Polygon++;
// Render
app->Clear(sf::Color(255, 255, 255));
sf::Shape Line = sf::Shape::Line(xLine, yLine, x1Line, y1Line, 3, sf::Color(0,0,0), 1, sf::Color(255, 255, 0));
sf::Shape Circle = sf::Shape::Circle(xCircle, yCircle, 50, sf::Color(125, 200, 240), 1, sf::Color(0, 0, 0));
sf::Shape Rect = sf::Shape::Rectangle(xRect, yRect, x1Rect, y1Rect, sf::Color(35, 200, 100), 1, sf::Color(0, 0, 0));
sf::Shape Polygon;
Polygon.AddPoint(xPolygon, yPolygon, sf::Color(255, 0, 0), sf::Color(0, 128, 128));
Polygon.AddPoint(x1Polygon, y1Polygon, sf::Color(255, 85, 85), sf::Color(0, 128, 128));
Polygon.AddPoint(x2Polygon, y2Polygon, sf::Color(255, 170, 170), sf::Color(0, 128, 128));
app->Draw(Line);
app->Draw(Circle);
app->Draw(Rect);
app->Draw(Polygon);
app->Display();
};
return EXIT_SUCCESS;
}[/code]
Desde ja eu agradeço