【正文】
xtends MIDlet { private final MazeCanvas canvas3D。 //Construct the midlet public Maze3DMIDlet() { error = makeImage(/)。 } public void startApp() 開始畫面 主程序 屏幕繪圖 顯示 win 顯示 lost 顯示歷史記分表 開始 屏幕角色 控制鼠標(biāo)找尋出口 初始化參數(shù) 死 胡同 時(shí) 顯示 END 時(shí) 圖 本程序的主流程圖 本科課程設(shè)計(jì)論文 5 { Displayable current = (this).getCurrent()。 } else { Alert splashScreen = new Alert(Maze3D, null, splash, )。 } (this).setCurrent(current)。 } // starts a new ga,e void newGame() { ()。 (this).setCurrent(menuList)。 (this).setCurrent( new Graphics3DProperties(g3d, this))。 (this).setCurrent(canvas3D)。 try { image = (filename)。 一直以來,從沒是有試著完整的做一個(gè) 課程設(shè)計(jì) ,總是做一些小功能的實(shí)現(xiàn)。這個(gè)時(shí)候我是非??释粋€(gè)團(tuán)隊(duì)的,起碼大家一起想會(huì)周到一些。 import .*。 // amount to advance at each step private final static float STEP = 。 // player39。 // flags whether we are looking the game from the top private boolean topView = false。 // stores how long has taken to run thorugh the maze private volatile long duration = 0。 // the world of the application private World world。 // simple rectangular mesh used to locate the player private Mesh locationSquare = null。 private Maze maze = new Maze(10, MAZE_SIDE_LENGTH, WALL_HEIGHT)。 } // (Re)Starts the game void start() { playing = true。 } // stops/pauses the game void stop() { duration = () gameStart。 // informs the MIDLet since this can be switched internally ()。 // sets the actual active camera if (topView) { (topCamera)。 // get a Graphics3D instance g3d = ()。 (camera)。 // set the perspective (, w / h, , )。 (0f, 0f,MAZE_SIDE_LENGTH)。 Image backgroundImage = (/)。 createFloor()。 setView()。 setupCamera()。 Appearance endMarkAppearance = new Appearance()。 (markCompositeMode)。 if (startMarkTextureImage != null) { startMarkTexture = new Texture2D( new Image2D(, startMarkTextureImage))。 (0, startMarkTexture)。 // the texture is not repeated (, )。 } // create the start mesh Plane startMarkPlane = ()。 (startMarkMesh)。 // is not pickable either (false)。 float[] trans = new float[4]。 (2, 8000, new float[]{trans[0], trans[1] + WALL_HEIGHT / 4, trans[2]})。 (anim)。 // define the location and size of the floor Transform floorTransform = new Transform()。 // The floor needs that perspective correction is enabled PolygonMode floorPolygonMode = new PolygonMode()。 Image floorTextureImage = (/)。 (, )。 (0, floorAppearance)。 (, , , )。 Image locationSquareImage = (/)。 (, )。 (0, locationSquareAppearance)。 } private void setUpMaze() { // the walls need perspection correction enabled PolygonMode wallPolygonMode = new PolygonMode()。 ()。 if (wallTextureImage != null) { Texture2D wallTexture = null。 (, )。 while (()) { Mesh wallMesh = ((Plane) ()).createMesh()。 float z = locationz + stepz。 // inverse the point of view to detect if it is moving // bacwards if (!forward) { (180, 0f, 1f, 0f)。 if (distance = ) { return false。 boolean moved = false。 if (selected instanceof Mesh) { transparentMesh = ((Mesh) selected)。 LEFT_PRESSED) != 0) { // move to the left angley += ANGLE_STEP。 moved = true。 stepz = STEP * (float) ((angley))。 UP_PRESSED) != 0) { // move forward, but first check if it is allowed if (canMove(stepx, stepz, true)) { locationx = stepx。 DOWN_PRESSED) != 0) { // move backwards, but first check if it is allowed if (canMove(stepx, stepz, false)) { locationx += stepx。amp。 transparentMesh = null。 } } // sets the camera location private void setupCamera() { 本科課程設(shè)計(jì)論文 23 (angley, 0f, 1f, 0f)。 if (finished) { duration = () gameStart。 } // draw time on the top right ((), getWidth(), 0, | )。 bound = true。 } } } public void run() { Graphics g = getGraphics()。 本科課程設(shè)計(jì)論文 25 // draw the 3d part draw3D(g)。 // flush to the screen flushGraphics()。 } } catch (Exception e) { // ignore. Not much to but we want to keep the loop running } } } }