1
General / Re: CMake error for SFML 2.3.2
« on: February 27, 2016, 07:41:25 pm »
It's done! I used the "ANDROID_NDK"and it worked. Thank you very much!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
class Block
{
public:
// Methods
Block(sf::Vector2f dimension, sf::Vector2f position, sf::Color color);
~Block();
template <class Obj>
void Collision(const Obj &object);
// Atributes
sf::RectangleShape blockShape;
sf::Vector2f blockPosition;
sf::SoundBuffer hitBuffer;
sf::Sound hitSound;
float blockLeft, blockRight, blockTop, blockBottom;
};
template <class Obj> void Block::Collision(const Obj &object)
{
// Collision variable
bool getCollision = false;
// Object borders
float objLeft = object.getPosition().x - object.getRadius() / 2;
float objRight = object.getPosition().x + object.getRadius() / 2;
float objTop = object.getPosition().y - object.getRadius() / 2;
float objBottom = object.getPosition().y + object.getRadius() / 2;
if (objLeft <= blockRight)
getCollision = true;
else if (objRight >= blockLeft)
getCollision = true;
else if (objTop <= blockBottom)
getCollision = true;
else if (objBottom >= blockTop)
getCollision = true;
// Destroy the object in case of collision
if (getCollision)
this->~Block();
}
// "Draw" the blocks (vector)
std::vector<Block> blocks;
int row = 4;
int colums = 15;
float spacement = 2.5f;
for (int i = 0; i < colums; i++)
{
Block block(sf::Vector2f(window.getSize().x / colums, 25), sf::Vector2f(i * window.getSize().x / colums + spacement, 100.f), sf::Color::Blue);
spacement += 2.5f;
blocks.push_back(block);
// Collision threads
sf::Thread blockThread(&Block::Collision<sf::CircleShape>ball, &blocks);
blockThread.launch();
}