1 / 34

Games Programming with Java

Games Programming with Java 240-492, Special Topics in Comp. Eng. II Semester 1, 2002-2003 Objective to motivate this course by giving some background on games programming in Java 1. Motivation and Background Overview 1. The Games Market 2. Wrong Ideas about Java for Games

Télécharger la présentation

Games Programming with Java

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Games Programming with Java 240-492, Special Topics in Comp. Eng. IISemester 1, 2002-2003 • Objective • to motivate this course by giving some background on games programming in Java 1. Motivation and Background

  2. Overview 1. The Games Market 2. Wrong Ideas about Java for Games 3. Some Commercial Games Using Java 4. Why use Java for Games? 5. Java Compared to C continued

  3. 6. Evaluating Java for Game Development 7. The Java Games Profile 8. Game Engines

  4. 1. The Games Market • US video game sales increased by 43% from $6.6 billion in 2000, to $9.4 billion in 2001. • “Grand Theft Auto 3” for the Playstation 2 sold 2 million units between October 2001 and January 2002. • The online gaming market will probably be worth $1.1 billion by 2003.

  5. 1.1. Game Types These types are used at http://www.arcadepod.com/java/ for available Java Games (~700) • 3D Games • Multi-Player • Action • Fighting, Scroller, Shooting • Classic • Arkanoid, Asteroids, Invaders, Lander, MineSweeper, Pacman, Pinball, Pipeline, Pong, Tetris, Worms • Adventure continued

  6. Indoor Sports • Billiards, Bowling, Darts • Board • Backgammon, Battleship, Checker, Chess, Connect 4, Crosswords, Go, Mahjong, Othello, Tic Tac Toe, Yahtzee • Outdoor Sports • Baseball, Basketball, Football, Golf, Hockey, Racing, Soccer, Tennis, Water Sports, Winter Sports, Street Sports continued

  7. I’ve excluded the General and Miscellaneous subcategories • Card • Solitaire, Spade • Mind • Concentration, Mazes, Puzzle, Strategy, Trivia • Casino • Baccarat, BlackJack, Craps, Poker, Roulette, Slots • Educational

  8. 1.2. Which Games to Build? • You should read: How do I Make Games? A Path to Game DevelopmentGeoff Howlandhttp://www.lupinegames.com/articles/ path_to_dev.html continued

  9. He identifies four games that programmers should implement in order to learn games techniques: • Tetris, Breakout, Pacman, and a side scroller such as Super Mario Brothers • I have included links to examples of these games with source code in: /Java Games/Background/learnGames.txt continued

  10. In this part of the course, we will be learning techniques based around: • an arcade-style game (“Alien Attack”) • an isometric arcade-style game (“Alien Tiles”) • a networked Chat system • a networked Tic-Tac-Toe • So looking at these other games would be very useful to you.

  11. 2. Wrong Ideas about Java for Games • No one writes seriousgames in Java. • The Java platform is too big/slow for games. • Sun isn’t doing anything about the games market.

  12. 3. Some Commercial Games Using Java • Vampire – scripted in Java • Shadow Watch – pure Java • Who Wants to be a Millionaire and You Don’t Know Jack – all logic in Java • Majestic – back-end is pure Java continued

  13. Star Wars Galaxies – scripted in Java • Skies of ArcadiaandDaytona USA • Sega Dreamcast games containing a JVM • Jamid (a Quake clone) andF1 Gran Prix– both use Java3D continued

  14. RoboForge • robot fighting tournament game • almost pure Java • received an “Excellent 87%” rating from PC Gamer Magazine

  15. 4. Why use Java for Games? • The usual reasons: • cross platform support, code reuse, ease of development, availability of tools • Less well known reasons: • efficient implementations for small devices • developer interest • platform maturity

  16. 5. Java Compared to C • Common wrong ideas: • C is compiled, Java is interpreted • build-time compilers produce faster programs • C is faster then Java • Java programs require no porting • A correct idea: • Java programs are faster to write and less buggy than equivalent C programs

  17. 5.1. C is compiled, Java interpreted is false • Both C and modern Java Virtual Machines (JVMs) compile code. • C compiles at build-time. • The JVM compiles at run-time.

  18. 5.2. Build-time Compilers Produce Faster Programs is false • Run-time compilers can optimize much better then build-time compilers • they know the actual hardware being used • they know how the code is being used/executed • they can perform “dangerous” optimizations because they can recover

  19. 5.3. C is Faster than Java is false • C is faster at some things • array access • Java is faster at some things • much faster memory allocation • better recursion and inlining • Over-all performance is roughly equivalent

  20. 5.4. Java Programs Require No Porting is false • Pure Java programs will run on any JVM, but may need ‘tweaking’ to improve system specific performance. • 85% - 90% of a game will probably require no changes • Still a big winner over trying to port C/C++ programs.

  21. 5.5. Java Programs are Faster to Write and Less Buggy is true • Many C/C++ programmers who have moved to Java have reported 2 to 10 times productivity increase. • The design of Java prevents whole classes of “late detection” bugs • no uninitialized variables • no wild pointers • no array over-runs or under-runs

  22. 6. Evaluating Java for Game Development • “Evaluating Java for Game Development”Jacob MarnerUniv. of Copenhagen, DenmarkMarch 2002 • a 320 page report (90 page text, the rest code) • http://www.rolemaker.dk/articles/ evaljava/ • I have also placed it in • Java Games/Background/ JavaForGames.pdf

  23. Main Conclusions • Java is a bit slower than C++ for executing games (1.2 - 1.5 times slower) • but the slowdown depends on the coding style, the JVM version, the application • real limits are 3D hardware, networking • Productivity with Java is higher than with C++ • about 1.3 times better in some studies continued

  24. Java is a good choice for simpler games • e.g. 2D, smaller, less complex graphics • Java combined with C++ is a good choice for more complex games • Java can use C++ / C via its Java Native Interface (JNI) • C++ is suited to low-level functionality, Java is better for the top level continued

  25. Java games can be speeded up by using JNI to directly access DirectX, OpenGL, Windows SDK, etc. • Java has not been ported to any of the popular game consoles yet • console games make up ~70% of the market • PC games are most of the rest • at JavaOne 2001, Sony and Sun announced that they would port a JVM to the PlayStation 2

  26. 7. The Java Games Profile • The Java Games Profile is a gaming API being developed at the moment • aimed at game consoles and PCs • target consoles will have 32-64 MB of RAM, fast 3D graphics hardware, large hard disk space • based on the Java Micro Edition • partners include Sony, Sega, Sun, GameSpy continued

  27. started June 2001; still under development • some details at http://jcp.org/jsr/detail/134.jsp • also known as Java Specification Request 134 (JSR-134)

  28. Specification Scope • Areas being considered: • 3D Modeling and Rendering • 3D Physics Modeling • 3D Character Animation • 2D Rendering • Game Marshalling and Networking • Streaming Media, Sound • Game Controllers • Hardware Access

  29. Where the Java Games Profile Fits

  30. Technolgies Old and New • Existing Technologies used: • Java 2D, Java 3D, JMF, AWT, I/O, networking • JDK 1.4. features for hardware • screen management, timer API • VolatileImage for storing images directly to graphics card memory continued

  31. New Technologies: • Physics Modeling • Character Animation • appearance, behaviour, realistic animation • Game Marshalling and Networking • find/join an online game; data communication • Game Controllers • e.g. joysticks, steering wheels, light guns, dance pads

  32. 8. Game Engines • A game engine is set of libraries/packages/ classes which support various games functionality • the programmer does not have to build a game from nothing • e.g. sprite control, playing area management, background generation, physics continued

  33. We will create a simple Sprite class later in the course. What is a Sprite? • A sprite is a (moving) graphical object visible on the screen • it is aware of collisions, mouse/keyboard interactions, edges of the playing area • it can be told what direction to move in and how fast to travel • it has a z-level, which dictates its drawing order on screen

  34. Free Game Engines • A lot of free game engines have been developed in Java. See: • Java Games/Background/gameEngines.txt • pointers to game engine sites • Java Games/Background/sourceForge.txt • pointers to game and game engines maintained at the SourceForge Web site • SourceForge maintains lots of different software projects, not just Java games.

More Related