Ejemplo n.º 1
0
void RectangleSDL::draw(Box2D & area, Color::enColor color, SDL_Surface *screen) {
	GLfloat c = 0.5;

	glBegin(GL_LINE_LOOP);
		glColor3f(c, c, c);

		glVertex2i(area.getLeftSide(), area.getTopSide());

		glVertex2i(area.getRightSide(), area.getTopSide());

		glVertex2i(area.getRightSide(), area.getBottomSide());

		glVertex2i(area.getLeftSide(), area.getBottomSide());
	glEnd();

	/*
	SDL_Color c = Color::getColor(color);

	boxRGBA(screen, area.getLeftSide(), area.getTopSide(), area.getRightSide(), area.getBottomSide(), c.r, c. g, c. b, 255);
	*/
}
Ejemplo n.º 2
0
/*
 * Gera n objetos aleatórios
 */
void QtSDL::generateObjects(int n) {
	int x, y, size;
	bool horizontal;
	bool vertical;
	int speed;

	objects->clear();

	Box2D limits = getRoot()->getArea();

	for (int i=0; i < n; i++) {
		x = randomNumber(limits.getLeftSide() + 5, limits.getRightSide() - 5);
		y = randomNumber(limits.getTopSide() + 5, limits.getBottomSide() - 5);

		size = randomNumber(2, 6);
		horizontal = randomBool();
		vertical = randomBool();
		speed = randomNumber(1, 2);

		objects->push_back(new RectangleSDL(Color::Blue, x, y, size, horizontal, vertical, speed));
	}
}