3D maze Picture help (not urgant)

how can I make this look 3D?

Page 1 of 1

2 Replies - 1879 Views - Last Post: 18 March 2009 - 09:11 PM Rate Topic: -----

#1 virgul  Icon User is offline

  • D.I.C Regular

Reputation: 44
  • View blog
  • Posts: 269
  • Joined: 18-March 09

3D maze Picture help (not urgant)

Posted 18 March 2009 - 08:41 PM

just because I want to make sure not to get into trouble in class I am going to say this,
Mr. Twiet, I finish this code on my own, im just asking for help with pictures in Applets because i want to be able to use them as well

now with that out of the way:

So my assignment was to make a 3D maze, I have finished this (below), i was just wondering if someone could help me with making walls, with pictures or whatever, also to make it look 3D.

The program is due tomorrow, but I really just want this for myself, seeing as its interesting and i haven't worked with 3d arrays until this point.

anyway here is the code

(this is the main)
public class MazeSearch3D4
{
	public static void main(String[] args)
	{
		Maze3D labyrinth = new Maze3D();
	  
		System.out.println (labyrinth);

		if (labyrinth.traverse (0, 0, 0))
		   System.out.println ("The maze was successfully solved!");
		else
		   System.out.println ("There is no possible path.");

		System.out.println (labyrinth);
   }
}



(this is the actual program :D )

//********************************************************************
//  Maze.java	   Author: Lewis/Loftus/Cocking
//
//  Represents a maze of characters. The goal is to get from the
//  top left corner to the bottom right, following a path of 1s.
//********************************************************************

public class Maze3D
{
   private final int TRIED = 3;
   private final int PATH = 7;

   private int[][][] grid = {
	{ { 1, 1, 1, 0, 0 }, { 0, 0, 1, 0, 0 }, { 0, 1, 1, 1, 0 },
	{ 0, 1, 0, 0, 0 }, { 0, 1, 1, 0, 0 } },
	{ { 0, 1, 0, 0, 0 }, { 0, 1, 1, 0, 0 }, { 1, 1, 1, 1, 0 },
	{ 1, 1, 0, 1, 1 }, { 1, 0, 0, 0, 1 } },
	{ { 1, 1, 1, 0, 0 }, { 0, 0, 1, 0, 0 }, { 0, 0, 0, 1, 0 },
	{ 0, 1, 1, 1, 1 }, { 0, 1, 0, 0, 0 } },
	{ { 0, 0, 0, 0, 0 }, { 0, 1, 1, 0, 0 }, { 0, 1, 0, 1, 1 },
	{ 0, 0, 0, 0, 1 }, { 0, 1, 1, 0, 0 } },
	{ { 0, 0, 1, 1, 0 }, { 0, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0 },
	{ 0, 0, 1, 1, 1 }, { 0, 0, 1, 0, 1 } }};

   //-----------------------------------------------------------------
   //  Tries to recursively follow the maze. Inserts special
   //  characters for locations that have been tried and that
   //  eventually become part of the solution.
   //-----------------------------------------------------------------
   public boolean traverse (int x, int y, int z)
   {
	  boolean done = false;
	  
	  if (valid (x, y, z))
	  {
		  
		 grid[x][y][z] = TRIED;  // this cell has been tried

		 if (x == grid.length-1 && y == grid[0].length-1 
			 && z == grid[0][0].length-1)
			done = true;  // the maze is solved
		 else
		 {
			done = traverse (x+1, y, z);	 // down
			if (!done)
			   done = traverse (x, y+1, z);  // right
			if (!done)
			   done = traverse (x-1, y, z);  // up
			if (!done)
			   done = traverse (x, y-1, z);  // left
			if (!done)
			   done = traverse (x, y, z+1);  // left
			if (!done)
			   done = traverse (x, y, z-1);  // left
		 }
		

		 if (done)  // this location is part of the final path
			grid[x][y][z] = PATH;
	  
	}
	  
	  return done;
   }
   
   //-----------------------------------------------------------------
   //  Determines if a specific location is valid.
   //-----------------------------------------------------------------
   private boolean valid (int x, int y, int z)
   {
	  boolean result = false;
 
	  // check if cell is in the bounds of the matrix
	  if (x >= 0 && x < grid.length &&
		  y >= 0 && y < grid[x].length)

		 //  check if cell is not blocked and not previously tried
		 if (grid[x][y][z] == 1)
			result = true;

	  return result;
   }

   //-----------------------------------------------------------------
   //  Returns the maze as a string.
   //-----------------------------------------------------------------
   public String toString ()
   {
	  String result = "\n";

	  for (int x=0; x < grid.length; x++)
	  {
		 for (int y=0; y < grid[x].length; y++)
		 {
			 for (int z = 0; z < grid[x][y].length; z++)
			 {
				 if(grid[x][y][z]==3)
					grid[x][y][z]=1;
				 result += grid[x][y][z] + "";//+"  ("+grid.length+")  ";
			 }
			 result += "\n";
		 }
		 result += "\n";
	  }
	  
	  return result;
   }
}



so what my question is, just to be clear, is how can I make this look 3D?

thanks!

This post has been edited by virgul: 18 March 2009 - 08:42 PM


Is This A Good Question/Topic? 0
  • +

Replies To: 3D maze Picture help (not urgant)

#2 Daegan  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 67
  • Joined: 17-March 09

Re: 3D maze Picture help (not urgant)

Posted 18 March 2009 - 09:02 PM

Are we to understand that you intend to represent a character array that's written as a command-line program as a 3d maze that is game-like in nature?
Was This Post Helpful? 0
  • +
  • -

#3 virgul  Icon User is offline

  • D.I.C Regular

Reputation: 44
  • View blog
  • Posts: 269
  • Joined: 18-March 09

Re: 3D maze Picture help (not urgant)

Posted 18 March 2009 - 09:11 PM

ooo, sorry, i forgot. That is just the program that i need to turn in.

My question is how do i make the answer, the output from the command-line into a visual product.

Sorry, i didnt really word that correctly, I do understand how to go from where i am right now to an Applet, but most everything will be inside of a cube, if say a 0 = wall, 1 = open path, and 7 = correct path.



and no, this really doesnt need to be game-like in nature, just look cool. I am, at this point, really just doing this for education, not for a grade


EDIT:

I think i just figured out how i could do this, but one question i have is what tells me which layer i am on (the x,y,or z) its the z right?

This post has been edited by virgul: 18 March 2009 - 09:17 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1