omer boyaci. (c) 2010 pearson education, inc. all rights reserved. omer boyaci
TRANSCRIPT
COMPUTER GRAPHICS THROUGH GAME PROGRAMMING
Omer Boyaci
(C) 2010 Pearson Education, Inc. All rights reserved.
IMAGE LOADING, VISUAL EFFECTS AND ANIMATION
Omer Boyaci
(C) 2010 Pearson Education, Inc. All rights reserved.
private BufferedImage im;im = ImageIO.read( getClass().getResource("ball.gif"));
Image Loading
(C) 2010 Pearson Education, Inc. All rights reserved.
public BufferedImage loadImage(String fnm){/* Load the image from <fnm>, returning it as a BufferedImagewhich is compatible with the graphics device being used. Uses ImageIO. */
try {GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment( );GraphicsConfiguration gc =
ge.getDefaultScreenDevice( ).getDefaultConfiguration( );BufferedImage im = ImageIO.read(getClass( ).getResource(fnm));int transparency = im.getColorModel( ).getTransparency( );BufferedImage copy = gc.createCompatibleImage(
im.getWidth( ),im.getHeight( ),transparency );// create a graphics contextGraphics2D g2d = copy.createGraphics();// copy imageg2d.drawImage(im,0,0,null);g2d.dispose( );return copy;
}catch(IOException e) {
System.out.println("Load Image error for " + fnm + ":\n" + e);return null;
}} // end of loadImage( )
(C) 2010 Pearson Education, Inc. All rights reserved.
Image Names
(C) 2010 Pearson Education, Inc. All rights reserved.
You can load individual imagesimage stripsmultiple image files that represent an
animation sequence.
Animation
(C) 2010 Pearson Education, Inc. All rights reserved.
Animation Types
(C) 2010 Pearson Education, Inc. All rights reserved.
// imsInfo.txt images
o atomic.gif
o balls.jpg
o bee.gif
o cheese.gif
o eyeChart.gif
o house.gif
o pumpkin.png
o scooter.gif
o ufo.gif
o owl.png
n numbers*.gif 6
n figure*.gif 9
g fighter left.gif right.gif still.gif up.gif
s cars.gif 8
s cats.gif 6
s kaboom.gif 6
o basn6a08.png
o basn6a16.png
o <fnm>n <fnm*.ext> <number>s <fnm> <number>g <name> <fnm> [ <fnm> ]*
(C) 2010 Pearson Education, Inc. All rights reserved.
Strip file
(C) 2010 Pearson Education, Inc. All rights reserved.
Swing Timer
(C) 2010 Pearson Education, Inc. All rights reserved.
ImagePlayer
Java Games
Runescape
http://www.runescape.com/
Stellar Dawn
http://www.stellardawn.com/
Wakfu
http://www.wakfu.com/
Tribal Trouble 2
http://tribaltrouble2.com/
Pirate Galaxy http://us.pirategalaxy.net
Resistance Force http://www.resistanceforce.com/
Urban Galaxy http://www.urbangalaxyonline.com/
Poisenville http://www.poisonville.com/
Chrome http://www.techland.pl/?
id=produkty&produkt=179
Wurm http://wurmonline.com/
Cell Invaders - TowerDefense http://
www.krautsoft.vs241092.vserver.de/virchow/index.html
Wezzle
http://couchware.ca/www/wezzle/
CEPHEI - HOSTILE PLANET
http://jalex.se/Cephei/bin/game.html