Example #1
0
static gint key_press_3D(guint keyval, gchar *commit_str, gchar *preedit_str)
{
  switch (keyval)
    {
    case GDK_Left: viewing_direction=TURN_LEFT(viewing_direction);
      gc_sound_play_ogg ("sounds/grow.wav", NULL);
      break;
    case GDK_Right: viewing_direction=TURN_RIGHT(viewing_direction);
      gc_sound_play_ogg ("sounds/grow.wav", NULL);
      break;
    case GDK_Up: one_step(viewing_direction);
      break;
    case GDK_Down:
      viewing_direction=TURN_RIGHT(viewing_direction);
      viewing_direction=TURN_RIGHT(viewing_direction);
      gc_sound_play_ogg ("sounds/grow.wav", NULL);
      break;
    case GDK_2:
    case GDK_space:
      /* Display a warning that you can't move there */
      g_object_set (warning_item, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);
      twoDdisplay();
      return TRUE;
    case GDK_E: case GDK_e: eye_pos_y+=0.1; if (eye_pos_y>0.9) eye_pos_y=0.9; break;
    case GDK_X: case GDK_x: eye_pos_y-=0.1; if (eye_pos_y<-0.9) eye_pos_y=-0.9; break;
    case GDK_D: case GDK_d: eye_pos_x+=0.1; if (eye_pos_x>0.9) eye_pos_x=0.9; break;
    case GDK_S: case GDK_s: eye_pos_x-=0.1; if (eye_pos_x<-0.9) eye_pos_x=-0.9; break;
    case GDK_Y: case GDK_y: case GDK_Z: case GDK_z: eye_pos_z+=0.1; break;
    case GDK_R: case GDK_r: eye_pos_z-=0.1; if (eye_pos_z<-0.9) eye_pos_z=-0.9; break;
    default: return FALSE;
    }
  update_tux(viewing_direction);
  draw3D();
  return TRUE;
}
Example #2
0
static gint key_press_2D_relative(guint keyval, gchar *commit_str, gchar *preedit_str)
{
  guint richting=0;

  switch (keyval)
    {
    case GDK_Left: viewing_direction=TURN_LEFT(viewing_direction);
      gc_sound_play_ogg ("sounds/grow.wav", NULL);
      update_tux(viewing_direction);
      return TRUE;
      break;
    case GDK_Right: viewing_direction=TURN_RIGHT(viewing_direction);
      gc_sound_play_ogg ("sounds/grow.wav", NULL);
      update_tux(viewing_direction);
      return TRUE;
      break;
    case GDK_Up: one_step(viewing_direction);
      break;
    case GDK_Down:
      gc_sound_play_ogg ("sounds/grow.wav", NULL);
      viewing_direction=TURN_RIGHT(viewing_direction);
      viewing_direction=TURN_RIGHT(viewing_direction);
      update_tux(viewing_direction);
      break;
    default: return FALSE;
    }

  richting=viewing_direction;

  /* run until we come to a fork, (make sure to stop on next level!) */
  while (run_fast && (richting=available_direction(richting)) && !gamewon)
    {
      one_step(richting);
      viewing_direction=richting;
    }

  return TRUE;
}
Example #3
0
// This is a blocking function that repeatedly takes a single step and then
// delays for step_delay_us microseconds.  When it finishes, the stepper motor
// coils will continued to be energized according to the final step so that
// the stepper motor maintains its position and holding torque.  The maximum
// time per step possible with this function is 65.535 ms.
void multistep(int steps, unsigned int step_delay_us)
{
	unsigned char dir = 1;
	if (steps < 0)
	{
		dir = 0;
		steps = -steps;
	}

	while (steps--)
	{
		one_step(dir);
		delay_us(step_delay_us);
	}
}
//Moves the motor a certain amount of steps with a certain amount of microseconds in between each step. 
// 200 microseconds at a maximum speed otherwise the stepper motor doesn't have enough time to step
void Actuator::steps(int steps, int micro, bool state){
  //decide direction
  directions(state);
 for(int i = 0 ; i <= steps ; i++){
  one_step(micro);
  //if debug is enables this will print out how many steps the motor has taken.
  if(state == BACKWARD){
    count++;
  }
  else{
    if(state == FORWARD){
      count--;
    }
  } 
 } 
}
Example #5
0
void run()
{
	long t, export=1;
	
	FILE *f_hi, *f_st;
	
	f_hi = fopen("hi.dat","w");	
	
	for (t=0; t<num_of_iteration; t++){
		export_conf(t,export);
		write_hi(f_hi,t);
		progress_bar(t);
        //printf("prova_run\n");
		one_step();
	}

	fclose(f_hi);
}
void pbf_dam_sim::simulateOneStep()
{
	//simulatee.external.body_force

	cudaGraphicsMapResources(1, &cu_res);
#ifndef NDEBUG
	gpuErrchk(cudaPeekAtLastError());
	gpuErrchk(cudaDeviceSynchronize());
#endif
	size_t pos_size;
	cudaGraphicsResourceGetMappedPointer((void**)&simulatee.phase.x, &pos_size, cu_res);
#ifndef NDEBUG
	gpuErrchk(cudaPeekAtLastError());
	gpuErrchk(cudaDeviceSynchronize());
#endif
	one_step(simulatee, buffer, domain, 3);
	cudaGraphicsUnmapResources(1, &cu_res);
	simulatee.phase.x = NULL;
}
Example #7
0
int main( void )
{
	int step;
	char space[MAX][MAX];
	char class = '0';

	/*初始化随机数发生器、space数组、spoce结构体*/
	srand((unsigned)time(0));
	point spore = {MAX/2 - 1, MAX/2 - 1};
	memset( space, ' ', sizeof(space) );
	space[spore.x][spore.y]= class;
	class++;

	/*每个标号每一次随机扩展一格。
	 *执行100步。			*/
	for(step = 0; step < MAX_STEP; step++) {

		spore = make_point( spore, one_step() );

		space[spore.x][spore.y]= class;
		switch(class) {
		case '9': class = 'A'; break;
		case 'Z': class = 'a'; break;
		case 'z': class = '0'; break;
		default : class++;
		}
	}

	/*最后一步用'*'号标明*/
	space[spore.x][spore.y]= '*';
	/*打印整个space数组,显示到屏幕上*/
	printf_space( &space[0] );

	/*打印出总共执行的步数step*/
	printf("Used %d steps.\n", step);
	return 0;
}
Example #8
0
static gint key_press(guint keyval, gchar *commit_str, gchar *preedit_str)
{
  guint richting=0;

  if(board_paused)
    return FALSE;

  if (threeDactive) return key_press_3D(keyval, commit_str, preedit_str);

  if (modeRelative) return key_press_2D_relative(keyval, commit_str, preedit_str);

  switch (keyval)
    {
    case GDK_Left:
      /* When In 3D Mode, can't move tux in the 2D mode */
      if(!modeIs2D || mapActive)
	return TRUE;

      richting=WEST;
      break;
    case GDK_Right:
      /* When In 3D Mode, can't move tux in the 2D mode */
      if(!modeIs2D || mapActive)
	return TRUE;

      richting=EAST;
      break;
    case GDK_Up:
      /* When In 3D Mode, can't move tux in the 2D mode */
      if(!modeIs2D || mapActive)
	return TRUE;

      richting=NORTH;
      break;
    case GDK_Down:
      /* When In 3D Mode, can't move tux in the 2D mode */
      if(!modeIs2D || mapActive)
	return TRUE;

      richting=SOUTH;
      break;
    case GDK_3:
    case GDK_space:
      if(modeIsInvisible) {
	gc_sound_play_ogg ("sounds/flip.wav", NULL);
	if(mapActive) {
	  g_object_set (wallgroup, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
	  /* Hide the warning */
	  g_object_set (warning_item, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
	  mapActive = FALSE;
	} else {
	  g_object_set (wallgroup, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);
	  /* Display a warning that you can't move there */
	  g_object_set (warning_item, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);
	  mapActive = TRUE;
	}
      }

      /* switch to 3D only if allowed in the mode */
      if(!modeIs2D)
	threeDdisplay();
      return TRUE;
    default: return FALSE;
    }
  if (Maze[position[ind][0]][position[ind][1]]&richting)
    {
      gc_sound_play_ogg ("sounds/brick.wav", NULL);
      return TRUE;
    }
  one_step(richting);
  viewing_direction=richting;

  /* run until we come to a fork, (make sure to stop on next level!) */
  while (run_fast && (richting=available_direction(richting)) && !gamewon)
    {
      one_step(richting);
      viewing_direction=richting;
    }
  return TRUE;
}
Example #9
0
int main(int argc, char* argv[])
{
    freopen("input.txt", "r", stdin);

    int N, M, S, T;
    int i, j, ret;
    scanf("%d %d %d", &N, &M, &S);
    //printf("%d %d %d\n", N, M, S);
    memset(map[0], '4', N+2);
    map[0][N+2] = '\0';
    for (i = 1; i <= M; i++) {
        map[i][0] = '4';
        scanf("%s", &map[i][1]);
        map[i][N+1] = '4';
    }
    memset(map[M+1], '4', N+2);
    map[M+1][N+2] = '\0';

    for (i = 0; i < M+2; i++) {
        // printf("%s\n", map[i]);
    }
    for (i = 1; i <= M; i++) {
        for (j = 1; j <= N; j++) {
            if (map[i][j] == '1') {
                x = i;
                y = j;
            }
        }
    }
    // printf("x=%d, y=%d\n", x, y);
    
    for (i = 0; i < S; i++) {
        flag2 = 0;
        memcpy(tmap, map, MAXM*MAXN);
        for (j = 0; j < M+2; j++) {
            // printf("%s\n", tmap[j]);
        }
        tx = x;
        ty = y;

        scanf("%d", &T);
        // printf("%d ", T);
        scanf("%s", cmd);
        // printf("%s\n", cmd);

        for (j = 0; j < T; j++) {
            ret = one_step(cmd[j]);
            if (ret == 0) {
                break;
            }
        }

        if (ret == 0) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }

    return 0;
}
Example #10
0
 static void invoke(i_type li, i_type si, os_type lo_c, o_type lo,  o_type so, o_type offset, ArgsTuple const & args ) {
  const int dP = boost::is_base_of<typename boost::tuples::element<N,ArgsTuple>::type, range >::type::value ;
  one_step(li[N], si[N],lo[N],so[N], offset[N] ,boost::tuples::get<N>(args));
  lo_c[P] = lo[N];
  slice_calc<Rank_in,Rank_out,N+1,P+dP,c-1, BoundCheck>::invoke(li,si,lo_c,lo,so, offset, args);
 }