Co mam zrobić, aby po kolizji 'rect' i 'shape', 'rect' znikał i pojawiał się w innym miejscu w nieskończoność?
// ConsoleApplication10.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "SFML\Graphics.hpp"
#include <iostream>
using namespace std;
using namespace sf;
int main()
{
RenderWindow window(sf::VideoMode(800, 600), "MySMFLGame!");
CircleShape shape(40.f);
shape.setPosition(400, 300);
shape.setFillColor(Color::Green);
RectangleShape rect(Vector2f(30,30));
rect.setPosition(100, 100);
rect.setFillColor(Color::Blue);
srand(time(NULL));
int rectPosX = (rand()%700)+50;
int rectPosY = (rand()%500)+30;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
if (Keyboard::isKeyPressed(Keyboard::Key::A)) {
shape.move(-0.1f, 0.0f);
}
if (Keyboard::isKeyPressed(Keyboard::Key::D)) {
shape.move(0.1f, 0.0f);
}
if (Keyboard::isKeyPressed(Keyboard::Key::W)) {
shape.move(0.0f, -0.1f);
}
if (Keyboard::isKeyPressed(Keyboard::Key::S)) {
shape.move(0.0f, 0.1f);
}
//Colissions
if(((shape.getGlobalBounds().intersects(rect.getGlobalBounds()))){
rect.setFillColor(Color::Black);
rect.setPosition(rectPosX, rectPosY);
}
window.clear(Color::White);
window.draw(rect);
window.draw(shape);
window.display();
}
return 0;
}