Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Games Programming with Java 240-492, Special Topics in Comp. Eng. II Semester 1, 2002-2003 1. Motivation and Background Objective – to motivate this course by giving some background on games programming in Java 240-492 Java Games. Backgnd/1 1 Overview 1. 2. 3. 4. 5. The Games Market Wrong Ideas about Java for Games Some Commercial Games Using Java Why use Java for Games? Java Compared to C 240-492 Java Games. Backgnd/1 continued 2 6. 7. 8. Evaluating Java for Game Development The Java Games Profile Game Engines 240-492 Java Games. Backgnd/1 3 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. 240-492 Java Games. Backgnd/1 4 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 240-492 Java Games. Backgnd/1 continued 5 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 240-492 Java Games. Backgnd/1 continued 6 Card I’ve excluded the General and Miscellaneous subcategories – Solitaire, Spade Mind – Concentration, Mazes, Puzzle, Strategy, Trivia Casino – Baccarat, BlackJack, Craps, Poker, Roulette, Slots Educational 240-492 Java Games. Backgnd/1 7 1.2. Which Games to Build? You should read: How do I Make Games? A Path to Game Development Geoff Howland http://www.lupinegames.com/articles/ path_to_dev.html 240-492 Java Games. Backgnd/1 continued 8 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 240-492 Java Games. Backgnd/1 continued 9 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. 240-492 Java Games. Backgnd/1 10 2. Wrong Ideas about Java for Games No one writes serious games in Java. The Java platform is too big/slow for games. Sun isn’t doing anything about the games market. 240-492 Java Games. Backgnd/1 11 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 240-492 Java Games. Backgnd/1 continued 12 Star Wars Galaxies – scripted in Java Skies of Arcadia and Daytona USA – Sega Dreamcast games containing a JVM Jamid (a Quake clone) and F1 Gran Prix – both use Java3D 240-492 Java Games. Backgnd/1 continued 13 RoboForge – robot fighting tournament game – almost pure Java – received an “Excellent 87%” rating from PC Gamer Magazine 240-492 Java Games. Backgnd/1 14 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 240-492 Java Games. Backgnd/1 15 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 240-492 Java Games. Backgnd/1 16 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. 240-492 Java Games. Backgnd/1 17 5.2. Build-time Compilers Produce is false Faster Programs 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 240-492 Java Games. Backgnd/1 18 5.3. C is Faster than Java C is false 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 240-492 Java Games. Backgnd/1 19 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. 240-492 Java Games. Backgnd/1 20 5.5. Java Programs are Faster to is true Write and Less Buggy 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 240-492 Java Games. Backgnd/1 21 6. Evaluating Java for Game Development “Evaluating Java for Game Development” Jacob Marner Univ. of Copenhagen, Denmark March 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 240-492 Java Games. Backgnd/1 22 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 240-492 Java Games. Backgnd/1 continued 23 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 240-492 Java Games. Backgnd/1 continued 24 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 240-492 Java Games. Backgnd/1 25 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 240-492 Java Games. Backgnd/1 continued 26 – 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) 240-492 Java Games. Backgnd/1 27 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 240-492 Java Games. Backgnd/1 28 Where the Java Games Profile Fits 240-492 Java Games. Backgnd/1 29 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 240-492 Java Games. Backgnd/1 continued 30 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 240-492 Java Games. Backgnd/1 31 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 240-492 Java Games. Backgnd/1 continued 32 What is a Sprite? We will create a simple Sprite class later in the course. 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 240-492 Java Games. Backgnd/1 33 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. 240-492 Java Games. Backgnd/1 34