Exemplo n.º 1
0
 void callbacks_t::display_cb(void)
 {
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
   
   test->set_text_line(30);
   b2Vec2 old_center = settings.view_center;
   settings.hz = settings_hz;
   
   test->step(&settings);
   
   if (old_center.x != settings.view_center.x || old_center.y != settings.view_center.y)
     {
 resize_cb(width, height);
     }
   
   test->draw_title(5, 15, entry->name);
   
   glutSwapBuffers();
   
   if (test_selection != test_index)
     {
 test_index = test_selection;
 delete test;
 entry = cs251::sim;
 test = entry->create_fcn();
 view_zoom = 1.0f;
 settings.view_center.Set(0.0f, 20.0f);
     resize_cb(width, height);
     }
 }
Exemplo n.º 2
0
 void callbacks_t::restart_cb(int)
 {
   delete test;
   entry = cs251::sim;
   test = entry->create_fcn();
   resize_cb(width, height);
 }
Exemplo n.º 3
0
 void callbacks_t::restart_cb(int)
 {
   delete test;
   entry = cs251::sim;
   test = entry->create_fcn();
   test->m_world->SetContactListener(test);
   resize_cb(width, height);
 }
Exemplo n.º 4
0
 void callbacks_t::restart_cb(int)
 {
  //! Creates a new test pointer after deleting the previous one.
  //! Resizes the window frame to original size.
   delete test;
   entry = cs296::sim;
   test = entry->create_fcn();
   resize_cb(width, height);
 }
Exemplo n.º 5
0
  void callbacks_t::keyboard_cb(unsigned char key, int x, int y)
  {
    //! What are these?
    B2_NOT_USED(x);
    B2_NOT_USED(y);
    
    switch (key)
    {
    case 27:
      exit(0);
      break;
      
      //! Press 'z' to zoom out.
    case 'z':
      view_zoom = b2Min(1.1f * view_zoom, 20.0f);
      resize_cb(width, height);
      break;
      
    //! Press 'x' to zoom in.
    case 'x':
      view_zoom = b2Max(0.9f * view_zoom, 0.02f);
      resize_cb(width, height);
      break;
      
    //! Press 'r' to reset.
    case 'r':
      delete test;
      test = entry->create_fcn();
      break;
      
      //! Press 'p' to pause.
    case 'p':
      settings.pause = !settings.pause;
      break;
      
      //! The default case. Why is this needed?
    default:
      if (test)
	{
	  test->keyboard(key);
	}
    }
  }
Exemplo n.º 6
0
  void callbacks_t::keyboard_special_cb(int key, int x, int y)
  {
  //! This is function which pan window in desired way using arrow keys.
    B2_NOT_USED(x);
    B2_NOT_USED(y);

    switch (key)
    {
    case GLUT_ACTIVE_SHIFT:

      //! Press left to pan left.
    case GLUT_KEY_LEFT:
      settings.view_center.x -= 0.5f;
      resize_cb(width, height);
      break;

    //! Press right to pan right.
    case GLUT_KEY_RIGHT:
      settings.view_center.x += 0.5f;
      resize_cb(width, height);
      break;

    //! Press down to pan down.
    case GLUT_KEY_DOWN:
      settings.view_center.y -= 0.5f;
      resize_cb(width, height);
      break;

    //! Press up to pan up.
    case GLUT_KEY_UP:
      settings.view_center.y += 0.5f;
      resize_cb(width, height);
      break;

    //! Press home to reset the view.
    case GLUT_KEY_HOME:
      view_zoom = 1.0f;
      settings.view_center.Set(0.0f, 20.0f);
      callbacks_t::resize_cb(width, height);
      break;
    }
  }
Exemplo n.º 7
0
 void callbacks_t::mouse_motion_cb(int32 x, int32 y)
 {
   b2Vec2 p = convert_screen_to_world(x, y);
   test->mouse_move(p);
   
   if (r_mouse_down)
     {
 b2Vec2 diff = p - lastp;
 settings.view_center.x -= diff.x;
 settings.view_center.y -= diff.y;
 resize_cb(width, height);
 lastp = convert_screen_to_world(x, y);
     }
 }
Exemplo n.º 8
0
  void callbacks_t::keyboard_cb(unsigned char key, int x, int y)
  {
    //! What are these?
    B2_NOT_USED(x);
    B2_NOT_USED(y);
    
    switch (key)
    {
    case 27:
      exit(0);
      break;
      
      //! Press 'z' to zoom out.
    case 'z':
      view_zoom = b2Min(1.1f * view_zoom, 20.0f);
      resize_cb(width, height);
      break;
      
    //! Press 'x' to zoom in.
    case 'x':
      //(sim->create_fcn())->launch();
      view_zoom = b2Max(0.9f * view_zoom, 0.02f);
      resize_cb(width, height);
      break;
      
    //! Press 'r' to reset.
    case 'r':
      delete test;
      test = entry->create_fcn();
      break;
      
      //! Press 'p' to pause.
    case 'p':
      settings.pause = !settings.pause;
      break;

    case 'w':
      (test)->launch();
      break;

    /*case 's':
      (test)->delaunch();
      break;*/

    case '8':
      (test)->launch2();
      break;

    /*case '2':
      (test)->delaunch2();
      break;*/

    /*case 'n':
      (test)->ball();
      break;*/

    /*case 'm':
      (test)->createball();
      break;*/

    case 'a':
      (test)->flipperleft();
      break;

    case 'd':
      (test)->flipperright();
      //(test)->flipperwheelright();
      break;

    case '4':
      (test)->flipperwheelleft();
      break;

    case '6':
      (test)->flipperwheelright();
      break;
      
      //! The default case. Why is this needed?
    default:
      if (test)
  {
    test->keyboard(key);
  }
    }
  }
Exemplo n.º 9
0
 void callbacks_t::x2_cb(int)
 {
   //! Zoom_in button
   view_zoom = b2Max(0.9f * view_zoom, 0.02f);
   resize_cb(width, height);
 }
Exemplo n.º 10
0
 void callbacks_t::x1_cb(int)
 {
   //! Zoom_out button
   view_zoom = b2Min(1.1f * view_zoom, 20.0f);
   resize_cb(width, height);
 }