Presentation is loading. Please wait.

Presentation is loading. Please wait.

1/4/2014 Ove Näslund Java Gaming An overview. 2 1/4/2014 Ove Näslund 2 Content Demos Some game types Java as Game language Game building issues API:s.

Similar presentations


Presentation on theme: "1/4/2014 Ove Näslund Java Gaming An overview. 2 1/4/2014 Ove Näslund 2 Content Demos Some game types Java as Game language Game building issues API:s."— Presentation transcript:

1 1/4/2014 Ove Näslund Java Gaming An overview

2 2 1/4/2014 Ove Näslund 2 Content Demos Some game types Java as Game language Game building issues API:s for 2D game development API:s for 3D game development API:s for Mobile game development Example of game engines Installation

3 3 1/4/2014 Ove Näslund 3 Some other reading….

4 4 1/4/2014 Ove Näslund 4 Some game types Arcade games 2D Games 2D Side scroller Isometric tile games 3D games FPS – First Person Shooter 3D Mazes Network games

5 5 1/4/2014 Ove Näslund 5 Why not Java? To slow? Java isnt slow anymore! Most of a graphic Game is handled by HW Memory problems? Avoiding/ensuring GC is about programming style To high level? C/C++ was that too!! High level OO helps design of complex games Many new API:s for game support Jni

6 6 1/4/2014 Ove Näslund 6 Why not Java? Installation nightmare Code bloat of JVM – well most games today are > 100MB Slow startup – Yes, but is a small part of game time! Installation – Java Webstart & Install4j Support Sun is more active to add API:s for games Game consoles doesnt support Java! (80% market) But, modern mobile phones support Java!

7 7 1/4/2014 Ove Näslund 7 Game Framework Game loop Sprites, Animated sprites e.g explosions Collision detection Pausing, exit Image repository (loading and sharing) Model repository Sound player & repository – (Midi, mp3 clips) Object manager – control the GC Input handling – mouse, keyboard, game pad etc Boards e.g. High score list

8 8 1/4/2014 Ove Näslund 8 Its all about time Update of screen No flicker No stops – hack in viewing Same update speed on all HW Update of game state More important than update of screen

9 9 1/4/2014 Ove Näslund 9 Time Control Keeping constant time FPS – Frames Per Second UPS – Updates Per Second Normally 70-80 FPS Upper bound is the monitor refresh rate (70-90 Hz)

10 10 1/4/2014 Ove Näslund 10 Measuring Time Resolution of time – OS dependent System.currentTimeMillis() – resolution 1-60 ms System.nanoTime() Java 5 – resolution 1-6 ms Java.util.concurrent.TimeUnit Java 5 – ns resolution J3DTimer Java3D – resolution 200-900 ns Other timers javax.swing.Timer and java.utility.Timer – uses System.currentTimeMillis() and is hard to control Timer in Java Media Framework JMF Game engines

11 11 1/4/2014 Ove Näslund 11 Sleeping Better Sleeping The Thread.sleep() accuracy is OS dependent (10%- 20% error for a 1 ms sleep time) Oversleep must be handled

12 12 1/4/2014 Ove Näslund 12 A game loop Update game state Render game state End loop Time calculations Finished? Sleep? Sleep & calc over sleep late? Update game state Yes No Yes No

13 13 1/4/2014 Ove Näslund 13 while(running) { // Game loop gameUpdate(); gameRender(); // render the game to a buffer paintScreen(); // draw the buffer on-screen afterTime = J3DTimer.getValue(); timeDiff = afterTime - beforeTime; sleepTime = (period - timeDiff) - overSleepTime; if (sleepTime > 0) { // some time left in this cycle try { Thread.sleep(sleepTime/1000000L); // nano -> ms } catch(InterruptedException ex){} overSleepTime = (J3DTimer.getValue() - afterTime) - sleepTime; } else { // sleepTime = NO_DELAYS_PER_YIELD) { Thread.yield(); // give another thread a chance to run noDelays = 0; }} beforeTime = J3DTimer.getValue(); /* If frame animation is taking too long, update the game state without rendering it, to get the updates/sec nearer to the required FPS. */ int skips = 0; while((excess > period) && (skips < MAX_FRAME_SKIPS)) { excess -= period; skips++; gameUpdate(); // update state but don't render } }

14 14 1/4/2014 Ove Näslund 14 A little about Collision Detection Boundary check Complex figures are approximated Bit overlap One step-ahead In 3D its about vector mathematics Sphere plane collision Boundary box Ray tracing And time Dont forget large steps… Finally what to do Explode, Bounce, Stop, Penetrate..

15 15 1/4/2014 Ove Näslund 15 2D and Isometric Game issues Choice of view FSEM or Windows 2D v.s. Isometric Screen size and resolution Moving backgrounds Planning time for loading and GC Graphic and sound Background Event effects – sound synchronized Choice of input

16 16 1/4/2014 Ove Näslund 16 Some 2D and Isometric algorithms Collision detection Map creation Path finding A* - find the lowest cost way from A to B D* - dynamic A* Flocking

17 17 1/4/2014 Ove Näslund 17 A* path finding

18 18 1/4/2014 Ove Näslund 18 Some 3D Game issues Scene graph – the world Floor, boundaries, Sky Creating and loading models Combining 2D and 3D Sprites, menu's etc Viewer position and movement First person camera Hovering following camera Gravity – ground follower, flyer Picking Lightning Collision detection

19 19 1/4/2014 Ove Näslund 19 Some 3D Game effects & algorithms Particle systems Flocking Growing trees Level of detail

20 20 1/4/2014 Ove Näslund 20 Desktop API:s for game development Basics JDK Graphics FSEM, Java 2D, Java 3D, (JOGL, LWJGL, GL4Java) Sound JOAL / Sound 3D, JMF Control JInput Distribution Java WebStart, Install4j Other ODEJava

21 21 1/4/2014 Ove Näslund 21 Some Free Game Engines Free 2D game engines Meat Fighter - http://meatfighter.comhttp://meatfighter.com GAGE - http://java.dnsalias.comhttp://java.dnsalias.com GTGE - http://goldenstudios.or.id/products/GTGEhttp://goldenstudios.or.id/products/GTGE Free 3D game engines Jake2 (Quake2) - http://bytonic.de/html/jake2.html JGE - https://jge.dev.java.nethttps://jge.dev.java.net JME - http://www.jmonkeyengine.com/

22 22 1/4/2014 Ove Näslund 22 JME Game picture

23 23 1/4/2014 Ove Näslund 23 Building 3D worlds Design tools 3D Studio Max Maya - Autodesk Terragen Monkey World 3D Many more… Some file formats DXF - Autodesk VRML M3G – Mobile (JSR184) MD2 – QuakeII

24 24 1/4/2014 Ove Näslund 24

25 25 1/4/2014 Ove Näslund 25 Mobile Game issues Small memory Low processor speed Lack of floating point calc HW support Small screens Inconsistent capability between phones Configuration of screen, MIDP version, input etc Distribution of many configuration versions More…

26 26 1/4/2014 Ove Näslund 26 Mobile API:s for game development Basics MIDP1.0, MIDP2.0 - Java Game (JSR 134) Graphics Java Game (Sprites), Mobile Java 3D (JSR183), Java Bindings For OpenGL ES (JSR 239), Mascot Capsule Micro3D Engine Sound Java Game, Mobile Media API (JSR 135) Control Java Game Networking Threads Distribution

27 27 1/4/2014 Ove Näslund 27 Network games – topology host5 host4 host2 host1 host3 host5 host4 host2 host1 host3 Server host5 host4 host2 host1 host3 Ring All-to-all Peer-to-Peer Star

28 28 1/4/2014 Ove Näslund 28 Network games - issues Protocol - UDP, TCP, http, IP multicasting Game type Bandwidth, firewalls, robustness Fat client vs. fat server logic Security Transport Anonymous users More…

29 29 1/4/2014 Ove Näslund 29 Java networking API:s Plain sockets UDP/ TCP, Java Secure Sockets Extension - SSL TLS IP multicasting P2P – JXTA www.jxta.orgwww.jxta.org URL class J2EE – Servlets Applets (Multicast ?) RMI Service Architecture Jini WebServices e.g Axis Sun Project Darkstar MMORGP (Massive Multiplayer Online Roleplaying Game Platform)

30 30 1/4/2014 Ove Näslund 30 Packaging and Distribution Java WebStart Install4J


Download ppt "1/4/2014 Ove Näslund Java Gaming An overview. 2 1/4/2014 Ove Näslund 2 Content Demos Some game types Java as Game language Game building issues API:s."

Similar presentations


Ads by Google