Beginning Java 2D Game Programming Part 1
I will be starting a Java programming tutorial showing you how you can create a 2D game using Java. The game we will be creating is Asteroids.
I am assuming in this tutorial that you have had some experience with programming.
You first will need Java 1.5 and Eclipse installed. See my first posts for installation instructions.
Create a project in your eclipse called Asteroids.
The first class we will create will be called Application and this class will be the class that you will use to create your game.
public class Application
{
public static void main(String[] args)
{
AsteroidGame game=new AsteroidGame();
game.createGame();
}//end main method
}//end application class
The word public means that any class has access to the class or methods. There is no security in place. If you use this class and something is public, then your other class can access it and change it. If the method or class is private, then nobody outside the class can access it. If the class is protected, then only classes, subclasses and members of other classes in the same package can access it. You usually will be setting a method or class as either private or public. Usually all variables in the class will be set to private. You want the user to access the variables by calling a method, which is set to public, in case you need to do some functionality before setting the variable. Every Java class has to have a main method when creating an application. This main method will be the first method that will be called and the only thing it does is creates the Asteroid Game object that will run the game.
Go To Part 2

0 comments:
Post a Comment