Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function LovelockSticker()
- {
- var ctx = null;
- var canvas = null;
- var width = 375;
- var height = 210;
- this.background = null;
- this.habboLeft = null;
- this.habboLeft_x = 120;
- this.habboLeft_y = 0;
- this.habboRight = null;
- this.habboRight_x = 255;
- this.habboRight_y = 0;
- this.setCanvasById = function(selector)
- {
- canvas = document.getElementById(selector);
- ctx = canvas.getContext('2d');
- canvas.width = width;
- canvas.height = height;
- this.update();
- }
- this.setBackground = function(src)
- {
- this.background = getImage(src);
- this.update();
- }
- this.setHabboLeft = function(src)
- {
- var callback = this.update;
- this.habboLeft = getImage(src, callback);
- }
- this.setHabboRight = function(src)
- {
- this.habboRight = getImage(src);
- this.update();
- }
- this.update = function()
- {
- console.log('lovelock updating...', this.background, this.habboLeft);
- if(this.background != null) {
- console.log('lovelock debug 0');
- ctx.drawImage(this.background,0,0);
- }
- if(this.habboLeft != null) {
- console.log('lovelock debug 1');
- ctx.drawImage(this.habboLeft, this.habboLeft_x, this.habboLeft_y);
- }
- if(this.habboRight != null) {
- console.log('lovelock debug 1');
- ctx.drawImage(this.habboRight, this.habboRight_x, this.habboRight_y);
- }
- }
- var getImage = function(src, callback)
- {
- var img = new Image;
- if(typeof callback == 'function')
- {
- img.onload = callback;
- }
- img.src = src;
- return img;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement