Exemple #1
0
void ObjectManager::create_ships(PlayerState& player_state)
{
    for (int i = 1; i <= NUM_OF_POSSIBLE_PLAYERS; i++) {
        if (player_state.energy_max(i)) {

            std::string name = "Player " + std::to_string(i);

            int s = player_state.score(i);
            int e = player_state.energy_max(i);
            player_state.set_energy(i, e);  // reset energy to max

            ObjIndex player_index = Object::parse_player_index(i);
            sdlc::Surface& gfx = obj[player_index];
            sdlc::Surface& hit_gfx = obj_hit[player_index];

            auto w1 = create_main_weapon(i, player_state);
            auto w2 = create_extra_weapon(i, player_state);

            KeySet keyset(i);   // For now we don't set custom keys

            auto new_ship = std::make_shared<Ship>(name, e, s, gfx, hit_gfx, w1, w2, keyset);

            new_ship->set_locked_to_screen(false);
            new_ship->set_x((float)(213 * i - new_ship->width()));
            new_ship->set_y(480);
            new_ship->set_vel(0, -200.0f);
            queue.push_back(new_ship);
        }
    }
}
Exemple #2
0
void UlzrakInterceptor::calculate()
{
	STACKTRACE;
	double fracDone;
	if ((!zoomActive) && (!zoomSequenceInitiated))
		spriteShift = 0;
	if (zoomActive) {
		mass = this->specialZoomMass;
		if (zoomReversed)
			this->zoomVel = (-1) * unit_vector(this->angle) * this->specialZoomSpeedAddition;
		else
			this->zoomVel = unit_vector(this->angle) * this->specialZoomSpeedAddition;
		if (this->specialZoomSpeedIsAdditive)
			set_vel ( this->normalVel + this->zoomVel );
		else
			set_vel ( this->zoomVel );
		this->damage_factor = this->specialCollisionDamage;
		this->zoomCounter += frame_time;
		this->DrawZoomLines();
		spriteShift = 3;
		if (zoomCounter>=this->specialZoomTime) {
			UnZoom();
		}
	}
	else if (zoomCounter >= this->specialActivationTime) {

		play_sound2((this->data->sampleSpecial[1]));
		this->zoomActive = true;
		this->zoomReversed = false;
		this->zoomSequenceInitiated = false;
		this->zoomCounter = 0;
								 //storing away the normal Velocity
		this->normalVel = this->vel;
		this->zoomVel = unit_vector(this->angle) * this->specialZoomSpeedAddition;
		this->inflictDamageCounter = 0;
	}
	else if (zoomSequenceInitiated) {
		zoomCounter += frame_time;
		fracDone = (double)zoomCounter / (double)this->specialActivationTime;
		spriteShift = (int)((fracDone * 3.0) + 0.5);
	}
	sprite_index_override = get_index(this->angle) + 64 * spriteShift;
	sprite_index = sprite_index_override;
	Ship::calculate();
	sprite_index = sprite_index_override;
}
Exemple #3
0
void UlzrakInterceptor::UnZoom(void)
{
	STACKTRACE;
	//message.print(1000,1,"unzoom");
	this->zoomActive = false;
	this->zoomSequenceInitiated = false;
	if (this->specialZeroBaseVelocityAfterZoom!=0) {
		this->normalVel = Vector2(0,0);
		set_vel ( Vector2(0,0) );
	}
	if (this->specialZoomVelocityBecomesBaseVelocityDirection!=0) {
		this->normalVel = unit_vector(this->zoomVel) * this->speed_max;
		if (this->zoomReversed) this->normalVel = -this->normalVel;
		//message.print(1000,10, "normalVel override");
	}
	set_vel ( this->normalVel );
	this->spriteShift = 0;
	this->zoomCounter = 0;
	this->zoomReversed = false;
	this->mass = this->shipMass;
	this->damage_factor = 0;
}
Exemple #4
0
void YuryulRam::calculate(void)
{
	STACKTRACE;
	// changed GEO
	if (!(creator && creator->exists()) ) {
		creator = 0;
		state = 0;
		return;
	}
	this->changeDirection(creator->angle + this->angleOffset);
	this->pos = creator->pos;
	set_vel(creator->vel);
	pos = normalize(pos + rotate(relativePosition, -PI/2+creator->get_angle()));
	Missile::calculate();
}
/**
 * Callback for the input from the controller
 */
void controller_cb(const sensor_msgs::Joy::ConstPtr& MSG) {
    received_joy = true;
    update_vel(vel, MSG->buttons);
    set_vel(MSG->buttons[R_TRIGGER], MSG->buttons[L_TRIGGER], MSG->axes[HOR_AXES]);
}