VIEWS: 60 PAGES: 5 POSTED ON: 11/29/2009
1-1 JAVA ARCADE Final Report Submitted to The Faculty of Operation Catapult LXIII Rose-Hulman Institute of Technology Terre Haute, Indiana By Group 1 Alex Packard R.J. Erffmeyer Jeff Snider Jason Hudson Northview High School Brazil, Indiana Lemont High School Lemont, Illinois Dublin Coffman High School Dublin, Ohio Rockville High School Rockville, Indiana June 30, 2005 1-2 Introduction In our project, we created many different games and incorporated them into an Arcade application. We put Java to use, creating a simple arcade interface and implementing relatively complex code variations in the games. The games we made with Java were paint, UFO Hunt, Pong, and Fireworks. The Java programming language uses an object oriented system. It is quickly becoming the easiest to use and most popular used coding language. Java can use simple instructions or complex ideas and simulations. Nearly all modern digital or electronic gadgets implement at least one line of code. Because of it’s easy to learn, difficult to master format, Java is the best language to make intermediate applications. Java’s object oriented programming deals with using a method to tell an object to do an action. Java uses classes. Take “cat” for example. Cat would be the class, a “Siamese cat” would be an instance of the class and subsequently would be the defined object. Using the method “meow”, Java would tell the “Siamese cat” to “meow”. We used several different classes to implement games and menus into the Java Arcade. Methods I. Introduction To start our project, we had a brainstorming session which came up with several ideas on what to do it on. The main idea we had was a simplified action / adventure game based off of GTA II. However, we soon found out that this idea wasn’t feasible in the three weeks we had. We eventually switched to our second idea of making a library of arcade games. This way, we could add more difficult games as our programming experience increased. We started learning how to program by changing and customizing the code of already existing programs. Each of these programs we changed taught us valuable programming skills. We learned basics such as printing text, if/then statements, and loops. We then moved onto more advanced concepts such as drawing polygons and lines, arrays, objects and classes, and how to program event handlers such as listening for mouse movement and action. Our instruction culminated with making a clickable tic tac toe board from scratch. After we finished this we were knowledgeable enough to start our project. The first task of our project was coding a menu window which would open up to different games when clicked. After this was completed we split our group up into different teams and starting coding each of the games. One team worked on paint, while the other team worked on the fireworks display and the UFO shoot game. The whole group then worked together to make the last game, Crazy Pong. II. Fireworks The first game we made for the arcade was the Fireworks program. This program displayed a fireworks show on different parts of the screen depending on where the mouse was clicked. To do this, we used a specific event handler called Mouse Listener which found the coordinates to display the fireworks show. Two other random coordinates were picked and the lines were displayed within a loop to create the effect of lines radiating from the point where the mouse clicked. 1-3 III. Mario Paint The next game we worked on was a paint program. This multi feature program had several buttons which allows the user to select different characters and different sized pens to make designs on a white canvas. This program used several buttons, and a layout called a Flow layout to position the buttons across the screen. An action listener was implemented on each of the buttons to decide what to do when they were pressed. On each of the buttons was a picture of a popular video game character. By selecting a character, you can paint pictures using images of the characters. Features such as an eraser and a reset button, which cleared the canvas, were later added. IV. UFO Hunt Our next game was UFO Hunt which was based off of the classic skeet game. This game displayed a UFO flying around the screen. Boundary detection was made for the top, bottom, left and right portions of the screen. The program used several if/ then statements to check to when the UFO was approaching a wall, when to change directions, and how to move the UFO according to which direction it was moving. A mouse motion listener was used for the aiming reticle. The reticle then followed the mouse, allowing the player to shoot down the UFO. Another if / then statement was then used to check if the range of x, y values inside the aimer matched the range of x, y values of the UFO. If this check turned out true, a small fireworks show was displayed. This fireworks display used a simplified version of the loop from the fireworks demo. We added a scoring feature and a difficulty setting in an entirely different frame. Creating the two frames that were able to pass values to each other was challenging, but necessary for UFO Hunt. One point was give to the player if they shot the UFO on the easy difficulty, ten points for the intermediate difficulty, and one thousand points for hardest difficulty. V. Crazy Pong Crazy Pong was similar to UFO Hunt. Much of the code from UFO Hunt was used to create Crazy Pong. The bouncing is the same except that the left and right boundaries were taken out. The paddles used a feature new to us called the Key Listener. The Key Listeners listened to the up and down keys and moved the paddles when the keys were pressed. A series of if / then statements check to see if the ball is touching the paddles. If the ball did touch the paddle, it would bounce off and go the other direction. To make the game more interesting, the ball was made to bounce at random angles. Scoring was a feature that took some time to complete. As simple as it might sound, it required lots of unexpected coding to perfect. Also, when the score reaches 5, it displays a win message and resets the scores to 0. Results After much hard work and concentration, we attained the results we wanted with our programs. The main menu works flawlessly. Games can be selected by both clicking their corresponding buttons and also by typing in their hot key. Another feature added to the menu was a music button. This allows the player to listen to classic gaming music while they play our arcade. 1-4 I. Fireworks The fireworks program dazzles users with its brilliant display. When the user clicks a spot on the screen, a fireworks display radiates from the clicked point. The fireworks display is constantly repainted, so even after the user clicks the animation is still going. Although it slows down occasionally, we felt that its stunning graphics offsets this downfall. II. Mario Paint The paint program turned out to be a great success for our arcade. It is a simple, yet fun application. The painting aspect works well and the character painting brings a new twist. With the exception of the eluding “Phantom Button” (a button that appears with no reasonable explanation), the buttons function just as they should. Despite some very minor and hardly noticeable glitches, we believe this is a great program. III. UFO Hunt UFO Hunt is also a great, entertaining program with only a few glitches. This program entertains the player with a randomly moving UFO as the target. The difficulty level can be adjusted for players with different skills. Points are awarded according to the difficulty when the UFO is shot. The only minor flaw is that the reticle isn’t always repainted properly. This results in extra pictures of the reticle appearing on the screen. IV. Crazy Pong Crazy Pong was perhaps our greatest achievement. Taking the techniques we had learned over the course of the three weeks, we were able to put together a fun, working pong game. The bounces of the ball are somewhat random, adding an element of anticipation to the game. The hit detection has been tweaked enough to simulate reality. The only major bug in the game, a hit detection error, was fixed near the end of project. The program keeps score for each of the players and then displays which player won after that player got scored five times. Analysis At the beginning of this project, none of us had a lot of experience using the Java language. We started out small by changing pre-made programs and moved on to creating our own simple programs. Eventually we were able to create a small library of games from scratch. Along the way we learned how to use more advanced Java techniques that we used to make the arcade. Considering our lack of expertise at the start of the project, we think that we have advanced our knowledge of the subject considerably and created a good program. Discussion We learned several invaluable programming skills while working on our project. This will most definitely help us at both our high school and also college. Most engineering and science degrees require programming knowledge, and working on our project will give us an advantage. If we continue on to study Computer Science or Software Engineering, the software we design might possibly help society. For example, many different kinds of medical equipment require programming. Testing and manufacturing pharmaceuticals also requires programmers to 1-5 program the robots in the assembly line. Finally, by developing internet and telecommunication applications, programmers help people around the world to communicate and understand each other better.