www.NewsDownload.co.uk Page 7
Overview
asteroids.sh
asteroids.htm
make.sh
point.java
rect.java
win32.java
winlisten.java
msgbox.java
sound.java
astroapp.java
classnumber.java
classtext.java
asteroids.java
astrorock.java
astroshot.java
astroufo.java
astroship.java
GNU License

Coding a Java Game

2012-03-18 18:30 By Jason Birch

Third in a series of how to code articles. Demonstrating coding an Asteroids Clone game with various technologies. This example using Java, implementing as an application for multiple platforms.

In this article I have converted my Asteroids Clone code into Java. I am now publishing the source code here under the GNU General Public License License as a series of articles describing how to write code using various technologies.

The code here can be freely distributed, but only on the condition that a credit to Jason Birch is maintained in the source code files and running application.

The source code is broken down into the classes which make the application, in the tabs on the left of this article. The tabs are placed in order from the simplest classes to the more complex classes last. There is a commentary accompanying each source code file explaining how the code operates.

Compiled class files and audio files can be downloaded here:
asteroids.class astroshot.class msgbox.class win32.class
astroapp.class astroufo.class point.class winlisten.class
astrorock.class classnumber.class rect.class astroship.class
classtext.class sound.class
Belt.au HyperSpace.au Shot.au UFO.au
Credit.au Rock.au Thrust.au UFOShot.au

To play, click on the game to set focus for the keyboard.
The keys to play are: Cursor left - Rotate left, Cursor Right - Rotate right, Cursor up Fire, Cursor down - Thrust, ' ' Hyperspace, 'F2' Start new game.

APPLET TAG


OBJECT TAG
No Java 2 SDK, Standard Edition v 1.6.0 support for APPLET

EMBED TAG
No Java 2 SDK, Standard Edition support for APPLET

Required Environment
To run a Java application, the Java Runtime Envionment (JRE) is required, which can be downloaded from java.com.
To develop Java applications, the Java Development Kit (JDK) is required, which can be downloaded from java.com.

Writing Code
Any text editor can be used to create and edit Java source code.

Compiling Code
Java code is compiled in an operating system command line console using the javac compiler, see tab for the file make.sh for an example of a generic compile command.

Distributing Application
Java can be run on many operating systems. A big advantage of Java is that the compiled classes from an environment, can be distributed to any environment, without needing to be compiled specifically for the environment.
The application .class files and supporting application files are copied into a directory on the target system. The target system can also be a web server.

Running Application
To run the application, the application class name is used as an argument to the java command line application. See the tab file asteroids.sh for an example of the command.
An application can also be run in a web browser. There are three ways to do this by using one of the following TAGS: APPLET, EMBED, OBJECT. See the tab file asteroids.htm for an example of these HTML TAGS.

Loading...