예제 #1
0
bool Game_Engine::Intersect(const Rocket &_Rocket, const double &dt) {
	//bool Intersect(const LightCycle &Cycle, const Wall &_Wall);
	Wall Rock(Segment2D <double>(_Rocket.Current_Point, _Rocket.Current_Point + dt*this->Constants->Rocket_Speed*Norm(_Rocket.Direction)), -1, -1);
	for (size_t i = 0; i < this->Current_Game.Players.size(); i++) {
		if (this->Current_Game.Players[i].Alive)
			if (Intersect(this->Current_Game.Players[i].MyCycle, Rock))
				return true;
	}
	for (size_t i = 0; i < this->Current_Game.Walls.size(); i++) {
		if (Intersect(Polygon_from_wall(this->Current_Game.Walls[i]), Polygon_from_wall(Rock)))
			return true;
	}
	return false;
}
예제 #2
0
//Generate the rocks
void RockGenerator::generate(const GroundPlane& ground) {
    int size = GroundPlane::GROUND_SCALE / ROCK_SIZE;
    int groundSize = GroundPlane::GROUND_SCALE / 2;

    for (int row = 0; row < size; row++) {
        for (int col = 0; col < size; col++) {
            if (rand() % ROCK_INVERSE_DENSITY == 0) {
                float scale = (rand() % (int)(ROCK_SCALE_MAX - ROCK_SCALE_MIN) + ROCK_SCALE_MIN)  / 100.0f;
                float x = row * ROCK_SIZE - groundSize + rand() % ROCK_SIZE;
                float y = col * ROCK_SIZE - groundSize + rand() % ROCK_SIZE;
                float angle = rand() % 360;

                auto density = makeDensity();
                rocks.push_back(Rock(draw_template_.mesh, glm::vec3(x, 0.0f, y), angle, ground, scale, density));
                density_levels.push_back(density);
            }
        }
    }
}