Fixing errors in maze gamex - Spencer ITS

kingfishblacksmithMobile - Wireless

Dec 14, 2013 (3 years and 7 months ago)

136 views

Fixing errors in maze game


Add to strings.xml

<string name="levelSelect">Select Maze</string>


Add to Maze.java after “
private static final long serialVersionUID = 1L;


public static final int UP = 0, DOWN = 1, RIGHT = 2, LEFT = 3;


Add to Maze.java
after “
private boolean gameComplete;”


public

int

getMazeWidth() {



return

sizeX
;


}


public

int

getMazeHeight() {



return

sizeY
;


}


Add to Maze.java at the end before the last }


public

boolean

isGameComplete() {



return

gameComplete
;


}


public

void

setStartPosition(
int

x,
int

y) {



currentX

= x;



currentY

= y;


}


public

int

getFinalX() {



return

finalX
;


}


public

int

getFinalY() {



return

finalY
;


}


public

void

setFinalPosition(
int

x,
int

y) {



finalX

= x;



finalY

= y;


}


public

int

getCurrentX() {



return

currentX
;


}


public

int

getCurrentY() {



return

currentY
;


}


public

boolean
[][] getHorizontalLines() {



return

horizontalLines
;


}


public

void

setHorizontalLines(
boolean
[][] lines) {



horizontalLines

= lines;



sizeX

=
horizo
ntalLines
[0].
length
;


}


public

boolean
[][] getVerticalLines() {



return

verticalLines
;


}


public

void

setVerticalLines(
boolean
[][] lines) {



verticalLines

= lines;



sizeY

=
verticalLines
.
length
;


}


Right
-
click the project and click Properties. Click

Java Compiler

and set the Compiler compliance
settings to 1.6.



You should have 5 source files: Game.java, GameView.java, Maze.java, MazeCreator.java, Menu.java


Game.java should have the following code at the top:

package

whateveryounamedyourpackage;


import

android.app.Activity;

import

android.content.Intent;

import

android.os.Bundle;


GameView.java should have the following code at the top:

package

whateveryounamedyourpackage;


import

android.app.Activity;

import

android.app.AlertDialog;

import

android.content.Context;

import

android.graphics.Canvas;

import

android.graphics.Paint;

import

android.view.KeyEvent;

import

android.view.LayoutInflater;

import

android.view.View;


Maze.java should have the following code at the top:

package

whateveryounam
edyourpackage;


import

java.io.Serializable;


MazeCreator.java should have the following code at the top:

package

whateveryounamedyourpackage;


Menu.java should have the following code at the top:

package

whateveryounamedyourpackage;


import

android.app.Activity;

import

android.app.AlertDialog;

import

android.content.DialogInterface;

import

android.content.Intent;

import

android.os.Bundle;

import

android.view.View;

import

android.view.View.OnClickListener;

import

android.widget.*;