コード例 #1
0
ファイル: draco.c プロジェクト: uekstrom/airstrike
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);
}
コード例 #2
0
static void update(sprite_t *s)
{
  float n[2] = {0,1};
  mech_boundary((mech_sprite_t *)s);
  ((mech_sprite_t *)s)->lin_impulse[1] += 2;
  mech_turn_to((mech_sprite_t *)s,n,1);
  mech_update((mech_sprite_t *)s);
}
コード例 #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);
}