User:Benjamin Gibson/Design Study

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
Line 11: Line 11:
  
 
== Terms ==
 
== Terms ==
*Collision detection: Collision detection is a term used in graphics applications when you are trying to find out if the graphical representation of two or more objects overlap, or "collide".
+
*Collision detection: Collision detection is a term used in graphics applications when you are trying to find out if the graphical representation of two or more objects overlap, or "collide". An example of this would be checking if a players avatar is touching a wall, if it is then you would want to stop them from moving through the wall.
An example of this would be checking if a players avatar is touching a wall, if it is then you would want to stop them from moving through the wall.
+
 
*Canvas: This is similar to JCanvas in swing, graphics are drawn on the canvas and then the canvas is drawn on the screen, for my purposes things won't get any more complex than this.
 
*Canvas: This is similar to JCanvas in swing, graphics are drawn on the canvas and then the canvas is drawn on the screen, for my purposes things won't get any more complex than this.
  

Revision as of 11:47, 19 September 2010

Navigation shortcuts: Wiki users:Benjamin Gibson


Contents

Problem overview

For my design study I have chosen to use a mobile graphics assignment (from cosc416). The goal of this assignment is to create a small pacman like game for mobile phones, using java ME. Java ME is a scaled down version of java, it works mostly like earlier versions of java.

I am designing code that will be able to be used to create very simple 2D games, I want a flexible code base that can be used to make several different types of games. In particular I want to be able to add new objects into the game easily (such as a new type of playable character, or add walls etc) and make it easy to change how the game is played (things like what does pushing the up button do).

Terms

  • Collision detection: Collision detection is a term used in graphics applications when you are trying to find out if the graphical representation of two or more objects overlap, or "collide". An example of this would be checking if a players avatar is touching a wall, if it is then you would want to stop them from moving through the wall.
  • Canvas: This is similar to JCanvas in swing, graphics are drawn on the canvas and then the canvas is drawn on the screen, for my purposes things won't get any more complex than this.


Initial Design

Design.jpg

The above diagram shows my initial design for the skeleton for the program, on top of this I have added code to actually create a game (such as code for a playable character) though I think it is worth describing just this much of the program first, as this is intended to be the core of the program which can be extended to create a variety of games. The above diagram is a simplified version of the UML diagram my code generated, I have left out all the detail of the classes aside from their names and most of the detail of their relationships, later i will include the full UML diagram, but for now this suits my purposes better for describing my system.

  • Midlet is just a main class that is necessary for java ME, this class can pretty much just be ignored.
  • MyCanvas is a canvas, as described above, this class is where the magic happens, it is created by Midlet and then runs the game, creating game objects and then constantly looping redrawing all the graphics and using the CollisionDetector to find collisions.
  • CollisionDectector is a singleton class which maintains a list of all collidable objects, when asked it will check all collidable objects against each other for collisions and construct a list of collision objects, one for each collision.
  • Collision represent the collision between two collidable objects, it simply takes the two objects that collided and stores them as fields, like a pair class would.
  • GameObject is an interface that represents an object that actually exists in game (such as a player, barrel, wall etc). Collidable, Movable and InputListener are all types of GameObjects, a GameObject will most likely inherit from one or more of these types.
  • Collidable is an abstract class that in its constructor adds itself to the CollisionDetector, this means that any object that extends Collidable will be added to the CollisionDectector upon creation. Collidable objects have an action method that is called when they collide with another object, this object is passed in as a parameter, in addition to this each collidable object has three boolean fields, lethal, killable and impassable, which are used to help the object understand how to react to the collidable object passed in as a parameter to action (for example if a killable object collides with a lethal object, the killable object should die).
  • Movable is a simple interface for GameObjects that can move.
  • InputListener is a simple interface for GameObjects that accept input from user (key presses).

UML Diagram

Design Description

Design Critique

Updates

Personal tools