SO - 14451073

by Arun P Johny

JavaScript

function gameObject(){
            this.o={};
            this.setimage=function(i){
                this.o.img=i;
            };
            this.setDimensions=function(w,h){
                this.o.width=w;
                this.o.height=h;
            };
            this.setPosition=function(x,y){
                this.o.x=x;
                this.o.y=y;
            };
            this.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);
            };
            this.setClass=function(c){
                this.o.cname=c;
            };
        }

var d = new gameObject();
alert(d.setimage)