Crenox

Beginning Java SE 6 Game Programming, Third Edition NOTES

Jan 22nd, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. Beginning Java SE 6 Game Programming, Third Edition NOTES:
  2.  
  3. There are two types of Java programs you can create:
  4. Java was originally developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform.
  5.  
  6. The original and reference implementation Java compilers, virtual machines, and class libraries were developed by Sun from 1991 and first released in 1995.
  7.  
  8. Java 2D is an API containing classes for advanced 2D graphics rendering and image manipulation, with support for vector (line-based) shapes, font-based text, image formats, and advanced RGBA color manipulation. This API works great for building 2D games with Java, and is what we will be using in this book. Among other things, we can perform transforms (rotation, translation, and scaling) on 2D images.
  9.  
  10. Java 3D is an API that allows rendering of 3D graphics in a Java application or web-based applet with high-level constructs for building 3D scenes. The websites are java3d.dev.java.net and www.java3d.org. This API works very well for building 3D games with Java.
  11.  
  12. The simplest way to create and run a Java program is with a text editor and the Java command-line tools javac.exe, java.exe, and appletviewer.exe.
  13.  
  14. An application and an applet.
  15.  
  16. An applet program extends a class called Applet, which means the applet will receive all of the features of the Applet class (which has the ability to run in a web browser). Essentially, all of the complexity of typing in your program with the web browser has been done for you through class inheritance (your program inherits the features of the Applet class).
  17.  
  18. JFrame makes it possible to do graphics in a Java application that is normally limited to just console output. JFrame provides a Graphics context as goes the Applet class, which can be used for drawing. The source code for a JFrame-based application is not any less code than an Applet project, but it foregoes the need of a web browser (or appletviewer), meaning we can run such a program with java.exe.
  19.  
  20. Let's go over what is in the JFrameDemo program:
  21. First, we need javax.swing, which owns the JFrame class, while java.awt makes the Graphics class available. The JFrameDemo class is the main class of the program, which extends JFrame, meaning that our class is a JFrame. There are some things that come with a JFrame class, such as the paint() method which renders the window when the program first starts up. We still need our main() function, and it has a single purpose: to launch the JFrame-powered class, JFrameDemo. The JFrameDemo() method is actually the constructor for the class, meaning it runs when the class is first created. Anything you want to happen when the window is first created and comes up, you could put in the constructor. So, we set the window title, the dimensions, and other useful properties.
  22.  
  23. Again, there are two different types of programs you can compile with Java: applications and applets. A Java application, the most common type of Java program, is a program compiled to run on a computer as a standalone application. A Java applet, on the other hand, is compiled specifically to run in a web browser. Java applications are usually written to run as server programs or just for one user, whereas applets run as client programs in a networked environment.
  24.  
  25. For example, Java Web Server (JWS) is a Java application that
  26. hosts web page files to a web browser (such as Internet Explorer or Mozilla
  27. Firefox), and it is comparable to Microsoft’s Internet Information Server (IIS)
  28. web server and the open-source Apache web server. But, Java applications are
  29. not solely devoted to services, as we can use the Swing library and the Abstract
  30. Windowing Toolkit (AWT) to bring up a graphical window for an application
  31. with all the same features as an applet window. Since applications are much
  32. easier to use, requiring fewer steps to compile and run, this is the approach we
  33. are taking in this new edition. The final game of Galactic War in the last chapter
  34. will support both.
Advertisement
Add Comment
Please, Sign In to add comment