Beispiel #1
0
void threeD(int obj[8][4], int opt)
{
	switch(opt)
	{
		case 1:{	cout<<"Enter translation factor in x,y,z direction\n";
					int tx,ty,tz;
					cin>>tx>>ty>>tz;
					threeDtrans(obj,tx,ty,tz);			// Translation
					threeDdisplay(obj);
					/*char ch;
					if(getch()=='p')
						prtscr("3D-1.bmp");*/
					break;
				}

		case 2:{	cout<<"Enter scaling factor in x,y,z direction\n";
					int sx,sy,sz;
					cin>>sx>>sy>>sz;
					threeDscale(obj,sx,sy,sz);			// Scaling
					threeDdisplay(obj);
					/*char ch;
					if(getch()=='p')
						prtscr("3D-2.bmp");*/
					break;
				}

		case 3:{	cout<<"Enter angle of rotation\n";
					double r,theta;
					cin>>theta;
					r = theta*3.14/180.0;
					threeDrotate(obj,r);	// Rotation
					threeDdisplay(obj);
					/*char ch;
					if(getch()=='p')
						prtscr("3D-3.bmp");*/
					break;
				}

		case 4:{	cout<<"Enter shearing factors in xy-direction\n";
					int sx,sy;
					cin>>sx>>sy;
					threeDshearXY(obj,sx,sy);				// Shearing
					threeDdisplay(obj);
					/*char ch;
					if(getch()=='p')
						prtscr("3D-4.bmp");*/
					break;
				}

		case 5:{
					threeDreflect(obj);				// Reflection
					threeDdisplay(obj);
					/*char ch;
					if(getch()=='p')
						prtscr("3D-5.bmp");*/
				}
	}
}
Beispiel #2
0
/*
 * Repeat let the user get a help map in 3D mode
 *
 */
static void repeat () {
  if(modeIsInvisible) {
    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;
    }
  }

  if(modeIs2D)
    return;

  if(threeDactive) {
    RsvgHandle *svg_handle;
    svg_handle = gc_rsvg_load("maze/maze-3d-bubble.svg");
    if(svg_handle) {
      gc_bar_set_repeat_icon(svg_handle);
      g_object_unref(svg_handle);
    }
    twoDdisplay();
    /* Display a warning that you can't move there */
    g_object_set (warning_item, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);

  } else {

    RsvgHandle *svg_handle;
    svg_handle = gc_rsvg_load("maze/maze-2d-bubble.svg");
    if(svg_handle) {
      gc_bar_set_repeat_icon(svg_handle);
      g_object_unref(svg_handle);
    }
    g_object_set (warning_item, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
    threeDdisplay();
  }

}
Beispiel #3
0
/* =====================================================================
 * set initial values for the next level
 * =====================================================================*/
static void maze_next_level() {
  GdkPixbuf *pixmap = NULL;

  maze_destroy_all_items();
  gc_bar_set_level(gcomprisBoard);
  setlevelproperties();

  mapActive = FALSE;

  ind = 0;
  gamewon = FALSE;
  initMaze();
  generateMaze((g_random_int()%breedte),(g_random_int()%hoogte));
  removeSet();
  /* Try the next level */
  maze_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas));
  draw_background(wallgroup);

  if(modeIsInvisible) {
    g_object_set (wallgroup, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
  }

  /* make a new group for the items */
  begin=g_random_int()%hoogte;
  end=g_random_int()%hoogte;

  /* Draw the tux */
  RsvgHandle *svg_handle = gc_rsvg_load("maze/tux_top_south.svg");
  tuxitem = goo_canvas_svg_new (tuxgroup, svg_handle,
				NULL);
  g_object_unref (svg_handle);

  goo_canvas_item_translate(tuxgroup,
			    cellsize*(0)-breedte + board_border_x,
			    cellsize*(begin)-hoogte + board_border_y);

  g_signal_connect(tuxitem,
		   "button_press_event",
		   (GCallback) tux_event, NULL);

  if(run_fast_possible) {
	  /* Load the tux shoes */
	  svg_handle = gc_rsvg_load("maze/tux_shoes_top_south.svgz");
	  tuxshoes = goo_canvas_svg_new (tuxgroup, svg_handle,
					"pointer-events", GOO_CANVAS_EVENTS_NONE, NULL);
	  g_object_unref (svg_handle);

	  /* Load fast-mode switch button */
	  svg_handle = gc_rsvg_load("maze/fast-mode-button.svgz");
	  fast_mode_button = goo_canvas_svg_new (boardRootItem, svg_handle,
					NULL);
	  g_object_unref (svg_handle);
	  goo_canvas_item_translate(fast_mode_button, 10, 10);
	  g_signal_connect(fast_mode_button,
			   "button_press_event",
			   (GCallback) on_fast_mode_button_press, NULL);
	  gc_item_focus_init(fast_mode_button, NULL);
  }

  /* Draw the target */
  pixmap = gc_pixmap_load("maze/door.png");
  if(pixmap)
    {
      draw_image(mazegroup,breedte-1,end,pixmap);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
      gdk_pixbuf_unref(pixmap);
#else
      g_object_unref(pixmap);
#endif
    }

  position[ind][0]=0;
  position[ind][1]=begin;
  Maze[0][begin]=Maze[0][begin]+SET;
  viewing_direction=EAST;
  threeDactive=FALSE;

  if(run_fast_possible) {
	  // run_fast-mode should be initialized at every level, whether TRUE or FALSE
	  if (gcomprisBoard->level < 14) set_run_fast(FALSE);
	  if (gcomprisBoard->level >= 14) set_run_fast(TRUE);
  }

  update_tux(viewing_direction);

  if(!modeIs2D)
    threeDdisplay();

}
Beispiel #4
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;
}