Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Quantum Avenger An Application of Object Oriented Design Principles in Game Development Andres Calderon Jaramillo - Dr. Hong K. Sung (Faculty Advisor)

Similar presentations


Presentation on theme: "The Quantum Avenger An Application of Object Oriented Design Principles in Game Development Andres Calderon Jaramillo - Dr. Hong K. Sung (Faculty Advisor)"— Presentation transcript:

1 The Quantum Avenger An Application of Object Oriented Design Principles in Game Development Andres Calderon Jaramillo - Dr. Hong K. Sung (Faculty Advisor) This project was developed as the final assignment for an undergraduate course in Object Oriented Programming at the University of Central Oklahoma. Students were instructed to design an animated game and implement it in the Java programming language. There were two primary constraints: first, at least two design patterns were to be used; second, the game design needed to follow a generalized data-animator-renderer framework provided by the instructor. BACKGROUND 1 [1] “2-Dimensional Elastic Collisions Without Trigonometry.” http://www.imada.sdu.dk/~rolf/Edu/DM815/E10/2dcollisions.pdf. Accessed: March 15, 2014. Game development is an area in which object-oriented programming principles can be applied quite naturally. Game entities can be readily represented as objects, and relationships between entities can be modeled using associations, inheritance, polymorphism, and design patterns. A game, The Quantum Avenger, was designed to meet the assignment's requirements. In essence, the game consists of a number of objects that can be shot by a ship controlled by the player through the keyboard. Some of the basic rules include: The player selects among three levels of difficulty. At the beginning of a session, there is a fixed number of spherical objects on the screen. These objects may be electrically charged and must interact with each other accordingly: positive spheres are red, negative spheres are blue, and neutral spheres are white. The player provides acceleration and direction to the ship (an equilateral triangle) using the keyboard. There are some restrictions on the ship’s velocity to prevent it from speeding out of control. The player makes the ship fire missiles using the keyboard in order to destroy spherical objects. The ship may be electrically charged (as indicated by the color of the tip). It can affect the motion of spherical objects. Spherical objects do not exert action-at-a- distance forces on the ship. Every collision of the ship with an spherical object decreases the ship’s health. The player wins when all objects have been destroyed. The player loses when the ship’s health reaches zero. METHODS 2 REFERENCES 4 Design Patterns At least two design patterns were used in this project: Strategy pattern: This pattern is used to make the different game screens (main menu, game area, losing screen, winning screen, etc.) interchangeable while allowing each one to encapsulate specific behaviors: In another scenario, this pattern is used to centrally handle some events generated within each game screen: Observer pattern: In one scenario, this pattern is used to notify the main data structure of the disappearance of an object from the screen (a spherical object being destroyed or a missile crossing the boundaries of the game area): CONCLUSION 3 A satisfactory solution to the final assignment was provided. It successfully illustrated the application of object-oriented design principles to the development of a game that used non-trivial simulations of physical phenomena. Basic Framework The framework provided by the instructor gave students a general starting point for the game design. There were three components used in this framework: Data structure (GameData in figure): an object that stores the entities in the game. Animator: an object that uses a separate thread to periodically update the state of the game entities. Renderer (GamePanel in figure): an object that displays the game entities in their current state. Collision Detection Collisions between spherical objects are detected using their radii. More formally, two spherical objects have collided if and only if the distance between their centers is less than or equal to the sum of their radii. In order to detect a collision between the ship and a spherical object, the boundary of the ship is approximated using a circle. Its center is the circumcenter of the triangle. The radius is calculated as follows: Using this circle, collisions are detected in the same manner as with spherical objects. Collisions with walls and missiles are detected in a similar fashion. Collision Handling Collisions between spherical objects must be handled using the laws of physics, including the conservation of momentum. Collisions are assumed to be elastic. The method used to calculate the speed and direction of each object after the collision is explained in detail in [1]. Actions at a Distance Because the ship and the spherical objects may be electrically charged, their interactions must be simulated. A formula analogous to Coulomb’s Law is used to calculate the force between two charged bodies: The acceleration and velocity are calculated from this force using methods from classical mechanics. Spherical Object (Negative) Spherical Object (Positive) Spherical Object (Neutral) Ship (Blue tip - negative) Missile Animator GamePanel GameData High-Level Framework’s UML Class Diagram Circumcircle Incircle Collision Approximation Circle Object for which force is being calculated JPanel IntroductionPanel GamePanel ResultScreen Main GameFigure Particle FreeParticle Missile > Disappearable > Disappearable > DisappearanceListener > DisappearanceListener GameData 1..* DisappearanceEvent JPanel GamePanel ResultScreen > Screen > Screen > ScreenListener > ScreenListener Main ScreenEvent IntroductionPanel Circumcenter


Download ppt "The Quantum Avenger An Application of Object Oriented Design Principles in Game Development Andres Calderon Jaramillo - Dr. Hong K. Sung (Faculty Advisor)"

Similar presentations


Ads by Google