예제 #1
0
void Robot::move(Direction dir) {
    turn(dir);

    left_motor_forward();
    right_motor_forward();


    for (uint16_t i = 0; i < STEPS::CELL; i++) {
        if (readings.is_wall_front_close) {
            return;
        }
        if (readings.is_wall_left_close) {
            step_left(STEPS::DELAY / 2);
        } else if (readings.is_wall_right_close) {
            step_right(STEPS::DELAY / 2);
        }
        step_motors(STEPS::DELAY);
    }
}
예제 #2
0
파일: fdf.c 프로젝트: acazuc/42_fdf
static void		do_move(t_world *world)
{
	if (world->rotate_up)
		rotate_up(world);
	if (world->rotate_down)
		rotate_down(world);
	if (world->rotate_left)
		rotate_left(world);
	if (world->rotate_right)
		rotate_right(world);
	if (world->move_down)
		world->position->y -= 1;
	if (world->move_up)
		world->position->y += 1;
	if (world->move_forward)
		step_forward(world);
	if (world->move_left)
		step_left(world);
	if (world->move_backward)
		step_backward(world);
	if (world->move_right)
		step_right(world);
}