I want to make a Java program that opens a window, and draws a person moving around on a background, controlled by the person, but I am yet to learn how to open an independent window, or how to draw on that window. Can I get some help with this? I have started with the codeacademy tutorials, but they, so far, have not yielded results. What I do know, is that I need to import a swing class, but I know nothing from there.
In the end, I would like my main class to look something like this:
Code:
My other classes will look like this:
Code:
and same for x[/code]
In the end, I would like my main class to look something like this:
Code:
//Header{
newWindow mainWindow = new Window;
newPerson player = new Player;
boolean win = false;
While (win == false) {
/*
I want to read keys here, if anyone knows how to do that.
*/
Case (keyPressed) {
case = 'up'{player.moveV(1);} /break
case = 'down'{player.moveV(-1);} /break
case = 'left' {player.moveH(-1)};} /break
case = 'right' {player.moveH(1)};} /break
}
}
}
My other classes will look like this:
Code:
class newPerson{
public int moveH(int locationY, int move){
//erase prevous location;
locationY+move=locationY
//draw person @ (locationX, locationY)
return locationY
}
}
and same for x[/code]