Game Dev

Throw a Projectile (shuriken) Using Atan2 in Java

by: Matt Hofstetter | March 12 , 2011 | Java Games

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 | Java Games

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 | Java Games

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 | Java Games

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 | Java Games

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

Fire a Projectile (arrow) Using Atan2, AS2

by: Matt Hofstetter | March 11 , 2011 | Flash Games

In the example above, we move the arrows using Math.cos and Math.sin, just like when we moved the ball in Rotate and Move an Object Using Sine/Cosin, AS2. The difference is that instead of using the LEFT and RIGHT arrow keys to change the angle of the object, we will be calculating the angle using the… view article

«StartPrev12NextEnd»