1 /**
2 The base class for all elements that appear in the game.
3 @author <a href="mailto:matthewcasperson@gmail.com">Matthew Casperson</a>
4 @class
5 */
6 function VisualGameObject()
7 {
8 /**
9 The image that will be displayed by this object
10 @type Image
11 */
12 this.image = null;
13
14 /**
15 Draws this element to the back buffer
16 @param dt Time in seconds since the last frame
17 @param context The context to draw to
18 @param xScroll The global scrolling value of the x axis
19 @param yScroll The global scrolling value of the y axis
20 */
21 this.draw = function(/**Number*/ dt, /**CanvasRenderingContext2D*/ context, /**Number*/ xScroll, /**Number*/ yScroll)
22 {
23 context.drawImage(this.image, this.x - xScroll, this.y - yScroll);
24 }
25
26 /**
27 Initialises this object
28 @param image The image to be displayed
29 @param x The position on the X axis
30 @param y The position on the Y axis
31 @param z The depth
32 */
33 this.startupVisualGameObject = function(/**Image*/ image, /**Number*/ x, /**Number*/ y, /**Number*/ z)
34 {
35 this.startupGameObject(x, y, z);
36 this.image = image;
37 return this;
38 }
39
40 /**
41 Clean this object up
42 */
43 this.shutdownVisualGameObject = function()
44 {
45 this.shutdownGameObject();
46 this.image = null;
47 }
48
49 this.collisionArea = function()
50 {
51 return new Rectangle().startupRectangle(this.x, this.y, this.image.width, this.image.height);
52 }
53 }
54 VisualGameObject.prototype = new GameObject;
Top