Exemple #1
0
CONTROL_CALLBACK_FUNC(testroute_turn_callback, cmd, ev) {
	if (ev == E_FINISHED) {
		head_direction = get_next_direction(cmd, head_direction);
		control_clear_distance();
	}
	
}
// Checks if the box next to pos in direction dir free is.
// If so, returns dir. If not, the next possible direction is returned.
// When no more directions are left (i.e. after move_right), move_none is returned
movement playfield::check_legal( int* pos, movement dir)
{
    int      myPos[2];

    myPos[0] = pos[0];
    myPos[1] = pos[1];
    myPos[directions[dir]] += signs[dir];

    int atpos = field[ myPos[horizontal] + myPos[vertical]*maxX ];

    while ((atpos != spc && atpos != dot && atpos != bdt && atpos != fruit_icon) && dir != move_none)
      dir = get_next_direction(dir);

    return dir;
}