Program: IV B. Tech.
CSE
Course : Introduction to Game Programming
Module : I
Chapter : 1
Dr. P E S N Krishna Prasad
Associate Professor
Department of CSE
GITAM Institute of Technology (GIT)
Visakhapatnam – 530045
Email: kponneka@gitam.edu
Contents
1. Why Java for Games Programming?
2. Java Is Too Slow for Games Programming
3. Java Has Memory Leaks
4. Java is Too High-level
5. Java isn't Supported on Games Consoles so Why Bother?
6. No One Uses Java to Write Real Games
7. Freeware/Shareware Games
Department of CSE, GIT - ECS442 - Game Programming
Why Java for GamesProgramming?
Advantages of Java:
➢ Object Orientation (OOPs), High Level Programming
➢ Cross-Platform Support
➢ Code Reuse
➢ Ease of Development,
➢ Tool Availability
➢ Reliability and Stability
➢ Good Documentation
➢ Support from Sun Microsystems
➢ Low Development Costs,
➢ Ability to use the Legacy Code (e.g. C, C++)
➢ Increased Programmer Productivity.
Note: Java is roughly the same speed as C++.
Memory leaks can be avoided with good programming and techniques.
Java offers more direct access to graphics hardware and external devices.
Department of CSE, GIT - ECS442 - Game Programming
Java Is Too Slow for Games Programming
Java is slow compared to C and C++, the dominant languages for games programming
Swing is Slow:
✓Most games don’t require complex GUIs
✓Full-screen game play with mouse and keyboard controls is the norm.
✓GUI elements - such as menu bars, button, and text fields aren’t needed
✓Mouse and keyboard processing is dealt with by the AWT.
Note:
❖The latest versions of Java offer an efficient full-screen mode by suspending the normal
windowing environment.
❖Typically, a large part of the graphics rendering of a game is handled by hardware or software
outside of Java.
❖For example, Java 3D passes its rendering tasks down to OpenGL or DirectX, which may emulate
hardware capabilities such as bump mapping.
❖Often the performance bottleneck in network games is the network and not the Java language.
Department of CSE, GIT - ECS442 - Game Programming
Java Has Memory Leaks
❑C/C++ programmers refer to memory leaks in Java:
➢Its very difficult to understand how Java works
➢Java doesn’t offer pointer arithmetic
➢Typical C-style memory leaks, such as out-of-bounds array accesses, are caught by the
Java compiler
❑Another Memory Complaint is Garbage Collector:
✓Java garbage collector is executing at poorly timed intervals,
✓Causes the application to halt for seconds as the collector sweeps and cleans.
❑JVM comes with different garbage collectors:
✓collect in various ways and can be selected and fine-tuned from the command-line.
✓Information on the performance of the chosen collector can be gathered and
analyzed.
Department of CSE, GIT - ECS442 - Game Programming
Java is Too High-level
❑The complaint is the age-old one of abstraction versus speed and control.
✓Java’s use of classes, objects, and inheritance add too much overhead without
enough coding benefit.
✓Java’s machine independence means that low-level, fast operations,
e.g., direct Video RAM I/O are impossible.
❑ The major benefit of reusing and extending Java’s large class library, includes:
❖ high-speed I/O,
❖advanced 2D and 3D graphics
❖ many networking techniques
❖ from lowly sockets to distributed agents
❖Object-oriented design, which makes complex, large and real-time systems
❖ more manageable during development, implementation and maintenance
Department of CSE, GIT - ECS442 - Game Programming
Java is Too High-level
J2SE 1.4 introduced a full-screen exclusive mode (FSEM):
➢which suspends the normal windowing environment
➢allows an application to access the underlying graphics hardware more directly.
➢permits techniques: page flipping, and provides control over the screen’s
resolution and image depth.
Note:
❖The principal of FSEM is to speed up graphics-intensive applications, such as
games.
❖Java games requiring these types of devices can utilize the Java Native
Interface (JNI) to link to C or C++ and, therefore, to the hardware.
❖The gaming community used to think that C and C++ were too high-level for
fast, efficient games programming when compared to assembly language
Department of CSE, GIT - ECS442 - Game Programming
Java Application Installation Is a Nightmare
✓The naysayers claim that the user needs to be a Java expert to install and execute a
Java application.
✓The most game players want to point and click on a few dialog boxes to get a game up
and running.
❑Some of the key points:
❖ Java (JRE) has to be on the machine before the application will run.
❖ Code bloat since even small programs require a 15 MB JRE. Downloading can be slow.
❖ Frequently changing JVMs make it hard to write code that will work for every possible
version of Java.
❖ Nonstandard components are often required—e.g., Java 3D, causing even more installation
problems.
❖It’s impossible to compile the application for a specific platform.
❖The .jar extension is commonly hijacked by other software (by compression programs) at
execution time.
❖The JRE is slower to start up compared to a native compiled application.
Department of CSE, GIT - ECS442 - Game Programming
Java isn't Supported on Games Consoles.
❑Video Gaming is a Multi billion-dollor industry that placing huge revenue in the current
market.
❑ The majority coming from three consoles: Sony Playstation (PS2), Microsoft’s Xbox, and
Nintendo’s GameCube. Sony is the Dominant console maker.
❑ Java isn’t available in the gaming consoles like Sony and Windows in early 2004
The Phantom console from Infinium Labs was announced at JavaOne in 2004, It’s essentially
a PC running an embedded Windows XP installation, with an nVidia graphics card, a hard
drive, and a broadband connection
➢Java gaming, the Phantom will come with a complete JRE. It was demoed during
Electronic Entertainment Exposition (E3) in 2004, show running Law and Order: Dead on
the Money (which uses Java 3D).
➢Die-hard programmers may point out that it’s possible to get Java running on a PS2 with
the support of open source tool Kaffe, non-Sun JVM, on top of PlayStation Linux.
➢ RenderWare and Gamebyro have the track record of best selling games and can port
games across the consoles such as PS2, Xbox, GameCube and PCs.
Department of CSE, GIT - ECS442 - Game Programming
No One Uses Java to Write Real Games
✓Puzzle Pirates by Three Rings (http://www.puzzlepirates.com/)
✓Chrome by Techland (http://www.chromethegame.com/en/show.php)
✓Law and Order II by Legacy Interactive. (http://www.lawandordergame.com/index2.htm)
✓Kingdom of Wars by Abandoned Castle Studios (http://www.abandonedcastle.com/)
✓Alien Flux by Puppy Games (http://www.puppygames.net/info.php?game=Alien_Flux)
✓War! Age of Imperialism by Eagle Games(http://www.eaglegames.net/products/WAR_AOI/wai.shtml)
✓Runescape by Jagex (http://www.runescape.com)
✓Star Wars Galaxies by LucasArts (http://www.lucasarts.com/products/galaxies/)
✓IL-2 Sturmovik by Ubi-Soft (http://www.il2sturmovik.com/)
✓Pernica by Starfire Research (http://www.starfireresearch.com/pernica/pernica.html)
✓Cosm by Navtools, Inc. (http://www.cosm-game.com/)
✓C&C Attack Copter by Electronic Arts (http://www.eagames.com/free/home.jsp)
✓Roboforge by Liquid Edge Games (http://www.roboforge.com)
✓Galactic Village by Galactic Village Games (http://www.galactic-village.com
✓Wurm Online by Mojang Specifications (http://www.wurmonline.com/)
✓Jellyvision (http://www.jellyvision.com/)
✓Vampire the Masquerade: Redemption (2000) by Nihilistic software (http://www.nihilistic.com/)
✓Tom Clancy’s Politika (1997) by Red Storm Entertainment (http://www.redstorm.com/)
Note: The main source for java games link: http://www.java.com/en/games/
Department of CSE, GIT - ECS442 - Game Programming
Freeware/Shareware Games
➢The recent version of java speed has improved and APIs crucial to gaming—such as
graphics and audio—are of a high quality. Numerous websites uses Java Games:
➢Java Games Factory (JGF) (http://grexengine.com/sections/externalgames/)
➢ArcadePod.com (http://www.arcadepod.com/java/)
➢Java 4 Fun (http://www.java4fun.com/java.html)
➢jars.com (http://www.jars.com)
➢Java Shareware (http://www.javashareware.com/)
➢Java Games Central (http://www.mnsi.net/~rkerr/)
❑Some freeware/shareware games are:
➢Super Elvis; also known as Hallucinogenesis
➢http://www.puppygames.net/downloads/hallucinogenesis/hallucinogenesis.jnlp)
➢FlyingGuns (http://www.flyingguns.com/)
➢Cosmic Trip (http://www.mycgiserver.com/~movegaga/cosmictrip.html)
➢Squareheads (http://home.halden.net/tombr/squareheads/squareheads.html)
➢Escape (http://javaisdoomed.sourceforge.net/)
➢CazaPool3D (http://membres.lycos.fr/franckcalzada/Billard3D/Pool.html)
➢SourceForge (http://sourceforge.net/search/)
➢FreshMeat.com (http://freshmeat.net/)
➢Code Beach (http://www.codebeach.com)
➢Programmers Heaven (http://www.programmersheaven.com/zone13/)
➢The “Your Games Here” Java Games Forum (http://www.javagaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Announcements)
Department of CSE, GIT - ECS442 - Game Programming