Arcade Village, Free online java arcade games

Kickboxing and Sprites

2010-09-03::Site life

New game on Arcade Village, Kickboxing.


This game doesnīt pretend to be a new standard. Itīs a good way to spend a good time, two people fighting on one keyboard.

I continue to study Eclipse, the java image management and the Sprites in java games.
In a game, an image is often reproduced in 4 directions. The directions that can use the player.
For Kickboxing, there are only two directions, left and right, but I created the routines for making all the images.

Sprites are loaded in memory at the beginning of the game.
Every position of the player is in a file which contains only the left image.

Sprites is kept in BufferedImage java object.

For the miror image, I use a affine transformation and the result is the following one:

The left image is in a BufferedImage object called bimg.
r is a rectangle object containing the image

I create a new image of the same size:
img = new BufferedImage (r.width, r.height, BufferedImage. TYPE_INT_ARGB);

// g the graphic object allowing to draw on the image
g = ( Graphics2D)img.createGraphics();

// I use a affine transform object
at = new AffineTransform ();

// I indicate to this object that points x will see each other attributed a factor of -1
at.setToScale (-1.0,1.0);

// I translate toward the right to correct the x points with are now negatives
at.translate (r.width, 0);

Then I draw the original image in the new image by using this transformation
g.drawImage (bimg, at, null);

Now in img, there is an miror image of bimg, the original image.

By loading just one image for the boxer, I have now two images.

The next time, we will see the rotations of 90° degres to the left and to the right.

Comments

No comment