Java Gaming - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Java Gaming

Description:

Free 3D game engines. Jake2 (Quake2) - http://bytonic.de/html/jake2.html ... Sun Project Darkstar MMORGP (Massive Multiplayer Online Roleplaying Game Platform) ... – PowerPoint PPT presentation

Number of Views:175
Avg rating:3.0/5.0
Slides: 31
Provided by: ovens
Category:
Tags: arcade | free | games | gaming | java | online

less

Transcript and Presenter's Notes

Title: Java Gaming


1
Java Gaming
  • An overview

2
Content
  • Demos
  • Some game types
  • Java as Game language
  • Game building issues
  • APIs for 2D game development
  • APIs for 3D game development
  • APIs for Mobile game development
  • Example of game engines
  • Installation

3
Some other reading.
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
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 APIs for game support
  • Jni

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 APIs for games
  • Game consoles doesnt support Java! (80 market)
  • But, modern mobile phones support Java!

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
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
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
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
Sleeping Better
  • Sleeping
  • The Thread.sleep() accuracy is OS dependent
    (10-20 error for a 1 ms sleep time)
  • Oversleep must be handled

12
A game loop
Finished?
Yes
End loop
No
Update game state
Render game state
Time calculations
Sleep?
No
Yes
Sleep calc over sleep
late?
No
Yes
Update game state
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 the period excess - sleepTime // store
excess time value overSleepTime 0L
if (noDelays 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 period skips gameUpdate() //
update state but don't render
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
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
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
A path finding
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
Some 3D Game effects algorithms
  • Particle systems
  • Flocking
  • Growing trees
  • Level of detail

20
Desktop APIs 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
Some Free Game Engines
  • Free 2D game engines
  • Meat Fighter - http//meatfighter.com
  • GAGE - http//java.dnsalias.com
  • GTGE - http//goldenstudios.or.id/products/GTGE
  • Free 3D game engines
  • Jake2 (Quake2) - http//bytonic.de/html/jake2.html
  • JGE - https//jge.dev.java.net
  • JME - http//www.jmonkeyengine.com/

22
JME Game picture
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
(No Transcript)
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
Mobile APIs 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
Network games topology
Ring
Star
host1
host1
Server
host5
host2
host5
host2
host4
host3
host4
host3
host1
host5
host2
All-to-all Peer-to-Peer
host4
host3
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
Java networking APIs
  • Plain sockets UDP/ TCP,
  • Java Secure Sockets Extension - SSL TLS
  • IP multicasting P2P JXTA www.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
Packaging and Distribution
  • Java WebStart
  • Install4J
Write a Comment
User Comments (0)
About PowerShow.com