Example #1
0
void Gameplay::draw(Drawable* drawable, GLint pixelSize) {
    Vec2d* drawCoords = drawable->getCoords()->applyScale(pixelSize);
    glPushMatrix();
    glTranslatef(drawCoords->getX(), drawCoords->getY(), 0);
    for (Segment* segment : *drawable->getMesh()) {
        Vec2d* relativeOffset = segment->getRelativeCoord()->getInverse();
        glTranslatef(relativeOffset->getX() * pixelSize, relativeOffset->getY() * pixelSize, 0);
        glColor3fv(segment->getColour()->getColour3fv());
        Primitive::drawSquare(pixelSize);
    }
    glPopMatrix();
}
Example #2
0
bool World::collidesWithQuads(vector<Quad*>* quads) {
    for (auto quad : *quads) {
        for (int i = 0; i < quad->getVertexCount(); i++) {
            Vec2d* vertex = quad->getVertices()[i];
            if (vertex->getY() < 0 || vertex->getY() > bounds->getY() || vertex->getX() < 0 || vertex->getX() > bounds->getX()) {
                cout << "Collision with world " << vertex->toString() << endl;
                return true;
            }
        }
    }
    return false;
}