diff options
Diffstat (limited to 'static/tests/canvas2/jsplatformer5_files/VisualGameObject.js')
| -rw-r--r-- | static/tests/canvas2/jsplatformer5_files/VisualGameObject.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/static/tests/canvas2/jsplatformer5_files/VisualGameObject.js b/static/tests/canvas2/jsplatformer5_files/VisualGameObject.js new file mode 100644 index 0000000..3f3329a --- /dev/null +++ b/static/tests/canvas2/jsplatformer5_files/VisualGameObject.js @@ -0,0 +1,49 @@ +/** + The base class for all elements that appear in the game. + @author <a href="mailto:matthewcasperson@gmail.com">Matthew Casperson</a> + @class +*/ +function VisualGameObject() +{ + /** + The image that will be displayed by this object + @type Image + */ + this.image = null; + + /** + Draws this element to the back buffer + @param dt Time in seconds since the last frame + @param context The context to draw to + @param xScroll The global scrolling value of the x axis + @param yScroll The global scrolling value of the y axis + */ + this.draw = function(/**Number*/ dt, /**CanvasRenderingContext2D*/ context, /**Number*/ xScroll, /**Number*/ +yScroll) + { + context.drawImage(this.image, this.x - xScroll, this.y - yScroll); + } + + /** + Initialises this object + @param image The image to be displayed + @param x The position on the X axis + @param y The position on the Y axis + @param z The depth + */ + this.startupVisualGameObject = function(/**Image*/ image, /**Number*/ x, /**Number*/ y, /**Number*/ z) + { + this.startupGameObject(x, y, z); + this.image = image; + return this; + } + + /** + Clean this object up + */ + this.shutdownVisualGameObject = function() + { + this.shutdownGameObject(); + } +} +VisualGameObject.prototype = new GameObject; |
