Esempio n. 1
0
bool World::resetTet(TetrominoType* type) {
    Vec2d* newCoords = new Vec2d(spawnPoint);
    if (nextTet == nullptr) {
        TetrominoType* randomType = typeFactory->getRandomType();
        int spawnOffset = randomType->getHeight();
        newCoords->setY(newCoords->getY() - spawnOffset);
        activeTet = tetFactory->getTetromino(randomType, newCoords)->withDirection(defaultDirection);
    } else {
        delete activeTet;
        activeTet = nextTet;
    }

    type = typeFactory->getRandomType();
    int spawnOffset = type->getHeight();
    delete newCoords;

    newCoords = new Vec2d(spawnPoint);
    if (mode == INFINITY_MODE) newCoords->setX((rand() % 8) + 1);
    newCoords->setY(newCoords->getY() - spawnOffset);
    nextTet = tetFactory->getTetromino(type, newCoords)->withDirection(defaultDirection);
    
    Translation translation = Translation(activeTet->getCoords());
    
    vector<Quad*>* resetQuads = translation.transform(activeTet->getQuads());
    bool success = !heap->collidesWithQuads(resetQuads);
    
    Quad::deleteQuads(resetQuads, true);

    delete newCoords;
    
    return success;
}
Esempio n. 2
0
bool World::resetTet(char letter) {
    TetrominoType* type = typeFactory->getType(letter);

    Vec2d* newCoords = new Vec2d(spawnPoint);
    int spawnOffset = type->getHeight();
    newCoords->setY(newCoords->getY() - spawnOffset);
    
    activeTet = tetFactory->getTetromino(type, newCoords)->withDirection(defaultDirection);
    nextTet = tetFactory->getTetromino(type, newCoords)->withDirection(defaultDirection);
    
    return !heap->collidesWithQuads(activeTet->getQuads());
}
Esempio n. 3
0
bool Slider::isWithinBounds(Vec2d &point)
{
	point.setY(game->getDisplay()->getDimensions().Y() - point.Y());

	Vec2d pos = mPosition + mMenuPosition;

	pos.addX(mSliderPosition);

	return (point.X() >= pos.X() &&
			point.Y() >= pos.Y() &&
			point.X() <= pos.X() + 32 &&
			point.Y() <= pos.Y() + 32
			);
}
Esempio n. 4
0
bool Button::isWithinBounds(Vec2d point)
{
	point.setY(game->getDisplay()->getDimensions().Y() - point.Y());

	/*point *= -1;

	point += 1.0f;*/

	Vec2d pos = mPosition + mMenuPosition;
	return (point.X() >= pos.X() &&
			point.Y() >= pos.Y() &&
			point.X() <= pos.X() + getWidth() &&
			point.Y() <= pos.Y() + getHeight()
			);
}