SO - 14451073
by Arun P Johny
JavaScript
function gameObject(){
this.o={};
}
gameObject.prototype = {
setimage:function(i){
this.o.img=i;
},
setDimensions:function(w,h){
this.o.width=w;
this.o.height=h;
},
setPosition:function(x,y){
this.o.x=x;
this.o.y=y;
},
create:function(){
var el=document.createElement("div");
el.className="object "+this.o.cname;
el.style.width=width*this.o.w;
e.style.height=height*this.o.h;
el.style.position="absolute";
el.style.top=height*this.o.y;
el.style.left=width*this.o.x;
map.appendChild(el);
},
setClass:function(c){
this.o.cname=c;
}
}
var d = new gameObject();
alert(d.setimage)