Java Games

Java Games, Double Buffer, J2SE Games

Throw a Projectile (shuriken) Using Atan2 in Java

by: Matt Hofstetter | March 12 , 2011 | views: 539

In this tutorial we will start with the double buffer from Double Buffer Animation with Java, and just the mouseListener from Create an Expolsion in Java. But before we deal with the main class, let's take a look at the Shuriken class that will control our shurikens. import java.lang.Math; public… view article

Create an Explosion in Java

by: Matt Hofstetter | March 12 , 2011 | views: 574

In this tutorial we will create an explosion by loading a series of frames and creating a class that plays them as an animation. To learn how we created the explosion frames for this tutorial check out Explosions in Studio Max Part 1. Explosion.java import java.awt.*; public class Explosion{ … view article

Detect a Collision in Java (Pythagorean Distance Formula)

by: Matt Hofstetter | March 12 , 2011 | views: 342

In this tutorial we will introduce a simple technique for detecting a collision between two objects. When the distance between two objects is less than their combined radii they are touching. We can calculate the distance between two objects using the Pythagorean Distance Formula. Ball.java import… view article

Java, Move an Object Using the Arrow Keys (KeyListener)

by: Matt Hofstetter | March 12 , 2011 | views: 1866

The first thing we will do in this tutorial is get our ball data into it's own class (unlike the previous article). public class Ball { private int px; private int py; private int speed; private int width; public Ball(int px, int py, int speed) { this.px = px; … view article

Double Buffer Animation with Java

by: Matt Hofstetter | March 11 , 2011 | views: 446

In this tutorial we will create a double buffer in Java and then test it by animating a bouncing ball, like the example above. So what exactly is a double buffer? When displaying images on the screen in Java, be it an animation or game, writing each image to the screen, one after the other, produces… view article