1 /**
  2     A test class to demonstrate the use of the VisualGameObject class
  3     @author <a href="mailto:matthewcasperson@gmail.com">Matthew Casperson</a>
  4     @class
  5 */
  6 function Bounce()
  7 {
  8 	/** The movement direction  in the x axis
  9         @type Number
 10     */
 11 	this.xDirection = 1;
 12 	/** The movement direction  in the x axis
 13         @type Number
 14     */
 15 	this.yDirection = 1;
 16 	/** The movement speed
 17         @type Number
 18     */
 19 	this.speed = 10;
 20 	
 21 	/**
 22         Initialises this object
 23         @return A reference to the initialised object
 24     */
 25 	this.startupBounce = function(image)
 26 	{
 27 		this.startupVisualGameObject(image, 0, 0, 0);
 28 		return this;
 29 	}
 30 	
 31 	/**
 32         Updates the object
 33         @param dt The time since the last frame in seconds
 34         @param context The drawing context 
 35         @param xScroll The global scrolling value of the x axis  
 36         @param yScroll The global scrolling value of the y axis 
 37     */
 38 	this.update = function (/**Number*/ dt, /**CanvasRenderingContext2D*/context, /**Number*/ xScroll, /**Number*/ yScroll)
 39 	{
 40 		this.x += dt * this.speed * this.xDirection;
 41 		this.y += dt * this.speed * this.yDirection;
 42 		
 43 		if (this.x >= 450)
 44 		{
 45 			this.x = 450;
 46 			this.xDirection = -1;
 47 		}
 48 		else if (this.x <= 0)
 49 		{
 50 			this.x = 0;
 51 			this.xDirection = 1;
 52 		}
 53 		
 54 		if (this.y >= 250)
 55 		{
 56 			this.y = 250;
 57 			this.yDirection = -1;
 58 		}
 59 		else if (this.y <= 0)
 60 		{
 61 			this.y = 0;
 62 			this.yDirection = 1;
 63 		}
 64 	}
 65 }
 66 Bounce.prototype = new VisualGameObject;