Super Pong Andrew S. Dunsmore CSC436 August 2004 Presentation Overview Rules of the Game The Design Modules of the program Technologies Used Program Demonstration Lessons Learned, Final Thoughts, Future Considerations, & Questions What is Super Pong? Based on the (ancient) game, Pong Video ping pong Players move paddle to intercept ping (ball) If the ping is missed, opponent scores a point Includes numerous userspecified options Player 1: 0 Player 2: 2 What Options Are Available? Colors can be changed Sounds can be turned on, off, or changed Multiple boards are possible Number of Players One Player against the computer Two Player Hot Seat on the same computer Two computers connected over the Internet How Should We Implement This? Modular Design Components broken into modules based on the functionality that they provide Key Modules Game Loop/Control Module Physics Module AI Module Input & Menu Modules Video/Graphics Module Audio/Sound Module Why use a Modular Design? Negatives are minimized – modules have high cohesion & low coupling Advantages Big problems are divided into several smaller problems Implementation can be in stages Troubleshooting and debugging is limited to individual modules Future changes or additions are easy Modules can be reused in the future Incremental nature responsible for 95% of progress The Game Loop/Control Module Broken into six areas Controls the program’s flow & calls the other modules Once a called module completes, focus returns to this module Physics Module Maintains positions and velocities of objects in the game world Determines results of positions & velocities of objects based on Physics Model selected by the user Currently not implemented as a separate module from the control module AI Module Used only for one-player games Calculates ping’s future location based on information from Physics Module Paddle 2 then moved to the calculated location Reductions in accuracy Calculations only made every x frames Calculated location multiplied by +/- y Computer’s paddle can only move at a fixed speed Input & Menu Modules Two separate modules –the same purpose (collect user inputs) but different behaviors Input Module receives Menu Module – subkeyboard inputs from the module of input module user Uses input module to Inputs can activate the move through the menu menu, move the paddles, and to make menu etc. selections Inputs are received in Menu selections are used real-time and acted upon to change the game to change the game environment (color, environment sound, board, etc.) DirectX – Why & How SDK designed by Microsoft to make video game design in Windows easier Before DirectX, designers wrote drivers for every video/sound/network/etc. card Now, all DirectX supported cards can be accessed in the same way DirectX – What it is The Operating System is the software that is most intimate with the hardware DirectX is more intimate with the hardware Windows doesn’t care about many advanced features of modern hardware DirectX polls hardware for its full capabilities Video/Graphics Module Implemented with the DirectDraw API Utilizes a back buffer to avoid a flashing screen Responsible for drawing all text and game objects to the screen Game objects are drawn by dynamically creating single-colored bitmaps and blitting them to the back buffer GDI text is drawn by DirectDraw through a DirectX compatible Device Context (slow to draw but fast to code) Audio/Sound Module Implemented by DirectSound and DirectMusic Responsibilities Initializing the sound card and determining its capabilities Loading music (midi) and sound effects (wave) Playing the sounds Music and sounds are loaded from embedded resources If something goes wrong, program continues, but sound is marked as unplayable Network Module Not yet implemented Utilized DirectPlay Responsibilities Set up an asynchronous peer-to-peer connection Communicate ping and paddle positions Ensure frame synchronization and “wing it” if necessary MAYBE – Provide an IM-like environment for user-touser communication Time for the Demonstration Did you bring earplugs? Lessons Learned Good references are worth their weight in gold Start with small goals, then build on them It’s easier to work with well-documented code Having a plan before starting to code helps (sometimes) The Future of Super Pong Add Multi-Player Add a Game Server Improve graphics Improve the menu’s graphics Fix the (small) hole in the special board detection algorithm Design an app to make custom boards Questions? www.geocities.com/godlike499/index.html