Original Post
Hi, I am currently trying to make a dancemat game for a cellphone. The basics of the game is that I will have numbers, from 0-9, fall down randomly from the top of the screen. And when those numbers hit a certain area of the screen, you are supposed to press the correct number on your keypad. I have made a Number Class like this
public class Number{
private int yPos;
private int xPos;
private int number;
private TangoCanvas parent;
/** Creates a new instance of Number */
public Number(int width) {
yPos=0;
Random r = new java.util.Random();
number = r.nextInt(9);
xPos=r.nextInt(width);
}
public void nextYpos(int deltaY){
yPos = yPos+deltaY;
}
int getY() {
return yPos;
}
}
The number class is supposed to make objects and assign numbers to the objects. and also tell it to scroll down, with the nextYpos() method The Second Class is Numbers, which is supposed to put a lot of Number() in a Vector
public class Numbers{
Vector myNumbers;
int width;
int height;
/** Creates a new instance of Numbers */
public Numbers() {
myNumbers = new Vector();
myNumbers.addElement(new Number(120));
myNumbers.addElement(new Number(120));
myNumbers.addElement(new Number(120));
}
/**
Uppdaterar spelbrädan, samt kollar om någon siffra har trillat utanför skärmen, och tar bort den.
*/
private void upDateAndTest(){
for (int i = 0; i < myNumbers.size(); i++) {
Number n =(Number)myNumbers.elementAt(i);
n.nextYpos(1);
if (n.getY()>height) {
myNumbers.removeElementAt(i);
}
}
}
/**
Kollar om det finns siffror i området man kan trycka på
*/
public boolean testIfNumberInArea(){
return true;
}
And then I also have a Gamecanvas, which is supposed to show the whole thing.. or at least get the objects to scroll down on the screen. My question is how? I know some Java, but I haven't made a game in java before.. So I don't know how to procede from here.. Can anyone lend a hand?