Пример #1
0
void physicsactor_update(physicsactor_t *pa, const obstaclemap_t *obstaclemap)
{
    int i;
    float dt = timer_get_delta();
    const obstacle_t *at_U;

    /* getting hit & winning pose */
    if(pa->state == PAS_GETTINGHIT) {
        input_ignore(pa->input);
        pa->facing_right = pa->xsp < 0.0f;
    }
    else if(pa->winning_pose) {
        /* brake on level clear */
        const float thr = 60.0f;

        for(i=0; i<IB_MAX; i++)
            input_simulate_button_up(pa->input, (inputbutton_t)i);

        pa->gsp = clip(pa->gsp, -1.8f * pa->topspeed, 1.8f * pa->topspeed);
        if(pa->state == PAS_ROLLING)
            pa->state = PAS_BRAKING;

        if(pa->gsp > thr)
            input_simulate_button_down(pa->input, IB_LEFT);
        else if(pa->gsp < -thr)
            input_simulate_button_down(pa->input, IB_RIGHT);
        else
            input_ignore(pa->input);
    }
    else
        input_restore(pa->input);

    /* horizontal control lock timer */
    if(pa->horizontal_control_lock_timer > 0.0f) {
        pa->horizontal_control_lock_timer = max(0.0f, pa->horizontal_control_lock_timer - dt);
        input_simulate_button_up(pa->input, IB_LEFT);
        input_simulate_button_up(pa->input, IB_RIGHT);
        pa->facing_right = pa->gsp > EPSILON;
    }

    /* don't bother jumping */
    at_U = sensor_check(sensor_U(pa), pa->position, pa->movmode, obstaclemap);
    if(at_U != NULL && obstacle_is_solid(at_U))
        input_simulate_button_up(pa->input, IB_FIRE1);

    /* face left/right */
    if((pa->gsp > EPSILON || pa->in_the_air) && input_button_down(pa->input, IB_RIGHT))
        pa->facing_right = TRUE;
    else if((pa->gsp < -EPSILON || pa->in_the_air) && input_button_down(pa->input, IB_LEFT))
        pa->facing_right = FALSE;

    /* get to the real physics... */
    run_simulation(pa, obstaclemap);

    /* reset input */
    for(i=0; i<IB_MAX; i++)
        input_simulate_button_up(pa->input, (inputbutton_t)i);
}
Пример #2
0
void sms_light_phaser_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	switch (id)
	{
	case TIMER_LPHASER:
		sensor_check();
		break;
	default:
		assert_always(FALSE, "Unknown id in sms_light_phaser_device::device_timer");
	}
}