Web Hosting Tomcat, Java, JSP, Servlets, J2EE, PHP, MySQL

Cheap web hosting provider

30
Sep

Figure 2-2 Rectangle boogie This boogie action is

Figure 2-2 Rectangle boogie This boogie action is implemented with a simple state machine in updateRectangle(). The rectangle has four states of motion up, down, left, and right and when a threshold is crossed, the rectangle enters the next state. We ll use state machines again for defining the behavior of alien ships in your first game. Let s jump right into the code, shown in Listing 2-2. Try to pick out all the places where this applet is different from its predecessor. Listing 2-2 Broadway.java import java.applet.*; import java.awt.*; public class Broadway extends Applet implements Runnable { Thread animation; int locx,locy; // location of rectangle int width, height; // dimensions of rectangle static final byte UP = 0; // direction of motion static final byte DOWN = 1; static final byte LEFT = 2; static final byte RIGHT = 3; byte state; // state the rect is in // length of pausing interval static final int REFRESH_RATE = 100; // in ms // applet methods: public void init() { System.out.println(”>> init <<"); setBackground(Color.black); locx = 80; // parameters of center rect locy = 100; width = 110; height = 90; state = UP; }
Note: If you are looking for cheap and inexpensive provider to host and run your tomcat application check Actions tomcat hosting services

Comments are closed.

Home | About Us | Compare Plans | Standard Hosting | Business Hosting | Java Tomcat Hosting | Support | FAQ | Order Now!

Powered by Omnicus java hosting services. All rights reserved.
Entries (RSS) and Comments (RSS).