// Screen
function screen() {
  var type, name, description, background, bbackground, width, height, viswidth, visheight, elem
  this.type="screen"
}

screen.prototype.create=function() {
  document.body.style.background=style_bg_img(this.bbackground)
  this.elem=document.createElement("div")
  this.elem.style.background=style_bg_img(this.background)
  this.elem.id="gamebox"
  this.elem.style.width=(this.viswidth)+"px"
  this.elem.style.height=(this.visheight)+"px"
  this.elem.style.marginLeft=(-this.viswidth/2)+"px"
  this.elem.style.marginTop=(-this.visheight/2)+"px"
  document.body.appendChild(this.elem)
  characters_container=document.createElement("div")
  characters_container.id="characters"
  this.elem.appendChild(characters_container)
}

screen.prototype.add=function(obj) {
  eval(obj.type+"s_container").appendChild(obj.elem)
  if (obj.type=="character") give_life(obj)
}

screen.prototype.remove=function() {
  document.body.style.background=""
  document.body.removeChild(this.elem)
}

// Character
function character() {
  var type, name, description, src, width, height, dirs, elem, posX, posY
  this.type="character"
  this.dirs=new Array(8)
  this.posX=0
  this.posY=0
}

character.prototype.dir=function(dir,row,stand,walk,run) {
this.dirs[dir]=new Array()
this.dirs[dir][0]=row
this.dirs[dir][1]=stand
this.dirs[dir][2]=walk
this.dirs[dir][3]=run
}

character.prototype.create=function() {
  this.elem=document.createElement("div")
  this.elem=document.createElement("div")
  this.elem.style.background="url("+this.src+")"
  this.elem.style.width=(this.width)+"px"
  this.elem.style.height=(this.height)+"px"
}

character.prototype.remove=function() {
  characters_container.removeChild(this.elem)
}