Presentation on theme: "Intro to Game Development An introduction to Swing, Java2D, JOGL, and game design Created by: Dennis Lawter and Dustin Scott."— Presentation transcript:
Intro to Game Development An introduction to Swing, Java2D, JOGL, and game design Created by: Dennis Lawter and Dustin Scott
Game Theory Logic AI, Game Objects Timer The Game Loop Controller Java AWT listeners Visuals & Audio Java2D vs. OpenGL, Java Sound vs. OpenAL
Logic GameObject – Inheritence! Player Affected by the controller Enemy Affected by AI Ground Serves as an obstacle or boundary Projectile Bullets for doing damage NPC (Non Playable Character) Allows greater interactivity AI, dialogs, quests, and plot progression
Timer The Game Loop Slowdown The game and graphics are affected equally by the timer. Frame-skip The graphics update as fast as possible, while the objects update on a timer. Updating objects The game loop calls each object’s update() method. We assume this is called 60 times per second. We can start a count off this timer to pause events (slowing animation or shooting rate). Each object can reassess its situation and act accordingly. Simple objects may do nothing, such as a ground block.
Timer Physics Collision A collision layer must be made. It can be either a bounding box, a number of smaller geographic shapes, or a pixel-by-pixel mask. A mask is a matrix of Boolean values to determine the solid pixels the object occupies. We will define collision as two objects moving into a state wherein they share at least one pixel in their collision layer. Intersection If we have boxes, we can compare their x, y, width, and height to determine if they are colliding. If we have a mask, we can shift one mask to match its position in the graphics and apply the bitwise AND function to the matrix. Snapping When stopping an object’s motion against a wall, we must move them into contact with the wall, rather than simply disallowing them to move.
Controller There are a number of ways to interpret a button press Pressed down event Activated only at the instant the button is pressed Held down repeating event A Boolean holds this value so that we may check it during update. Released event Activated only on the release of a button. This is useful for quick press events. Compare this to the actions of clicking a link. Typing event Should we implement our own display for text, such as a chat window, we would have to check for focus on the chat window and add text if necessary.
Graphics Java2D We draw everything within a JPanel (Swing component). We override the paint method, with a Graphics parameter. The Graphics2D class (casted from Graphics) allows us to draw a number of shapes and objects. We may draw lines, Strings, and Images. JOGL Similar to the previous methodology. A GLCanvas is made in place of a JPanel. A GLEventListener is overridden to handle the drawing. GLAutoDrawable is used rather than Graphics.
OpenGL vs. DirectX vs. Java2D OpenGL – Stands for Open Graphics Library. It is an API primarily designed as an abstraction for graphical processing. It is primarily used cross-platform 3D graphics. DirectX – Microsoft’s API for abstraction for hardware access. It includes almost all Utilities necessary for game development. Java2D – Java’s prepackaged graphics library. Using the CPU for graphic processing, it does not standup to the other APIs due to the inability to utilize specialized hardware.
Java2D Useful for simple, quick or low graphics intensity applications. Cross-platform Built-in to java Quickly overwhelmed in graphics intensive applications due to its shared CPU usage.
Setting up JOGL in Eclipse JOGL will require system libraries to execute properly. Eclipse must be setup to use JOGL, and must be reconfigured if the drive letter changes, unless the configurations are hard-coded.