Esempio n. 1
0
static void update(sprite_t *s)
{
	mech_sprite_t *ms = (mech_sprite_t *)s;
	float x, y;
	
	if (s->vel.x < 0 && s->state == DRACO_GLIDE) {
		/* if going into wrong direction, activate
		 * forward flapping for a while 
		 */
		s->state = DRACO_RIGHT;
		s->flags &= ~SPRITE_PAUSED;
		sprite_alarm(40,s,msg_deactivate());
	}
	x = 0;
	y = 0;
	switch (s->state) {
	case DRACO_UP:
		/* flapping when not paused takes care of this:
		 * y = -0.03;
		 */
		break;
	case DRACO_DOWN:
		y = 0.02;
		break;
	case DRACO_RIGHT:
		x = 0.02;
		break;
	default:
		break;
	}
	ms->lin_impulse.x += x;
	ms->lin_impulse.y += y;
	mech_update(ms);
}
Esempio n. 2
0
static void collide(struct sprite *s, 
		    struct sprite *other_sprite, 
		    int x, int y)
{
	if (s->state == DRACO_GLIDE) {
		/* going down */
		if (s->vel.y > -1) {
			s->state = DRACO_UP;
			sprite_alarm(30,s,msg_deactivate());
		} else {
			/* going up */
			if (s->vel.y < 0) {
				s->state = DRACO_DOWN;
				sprite_alarm(20,s,msg_deactivate());
			}
			/* otherwise just flap */
		}
		s->flags &= ~SPRITE_PAUSED;
	}
}
Esempio n. 3
0
static void update(sprite_t *s)
{
	float v[2],x,pull[2];
	mech_sprite_t *ms = (mech_sprite_t *)s;

	sprite_get_vel(s,v);
	if (!(s->state & PLANE_CRASHING))
	{
		if (s->state & PLANE_ACCELERATING)
		{
			vset(pull,mech_heading(ms));
			vrot(pull,-16); /* maybe the angle should depend on up/down */
			vmadd(ms->lin_impulse,engine_strength,pull);
		}
		if (s->state & PLANE_UP)
			ms->air_rotate = -turn_amount;
		else if (s->state & PLANE_DOWN)
			ms->air_rotate = turn_amount;
		else
			ms->air_rotate = 0;

		if (ms->damage >= hitpoints)
		{
			s->state |= PLANE_CRASHING;
			if (!(s->owner->schrodinger)){
				sprite_set_animation(s,crashing[s->owner->id_in_team]);
			}else{
				sprite_set_animation(s,crashing[MAXPLAYERINTEAMS]);
			}

			s->owner->lastEnnemi->points+=crash_point;
			create_effect(&fire,s->x,s->y);
			sprite_alarm(7000,s,SIGNAL_KILL,0);
		}
	}
	mech_update(ms);
}