71 lines
2.1 KiB
JavaScript
71 lines
2.1 KiB
JavaScript
|
// Screen
|
||
|
function screen() {
|
||
|
var type, name, description, background, bbackground, width, height, viswidth, visheight, viselem, elem
|
||
|
this.type="screen"
|
||
|
}
|
||
|
|
||
|
screen.prototype.create=function() {
|
||
|
document.body.style.background=style_bg_img(this.bbackground)
|
||
|
this.viselem=document.createElement("div")
|
||
|
this.viselem.id="visgamebox"
|
||
|
if (this.viswidth>this.width) this.viswidth=this.width
|
||
|
if (this.visheight>this.height) this.visheight=this.height
|
||
|
this.viselem.style.width=(this.viswidth)+"px"
|
||
|
this.viselem.style.height=(this.visheight)+"px"
|
||
|
this.viselem.style.marginLeft=(-this.viswidth/2)+"px"
|
||
|
this.viselem.style.marginTop=(-this.visheight/2)+"px"
|
||
|
|
||
|
this.elem=document.createElement("div")
|
||
|
this.elem.style.background=style_bg_img(this.background)
|
||
|
this.elem.id="gamebox"
|
||
|
this.elem.style.width=(this.width)+"px"
|
||
|
this.elem.style.height=(this.height)+"px"
|
||
|
|
||
|
this.viselem.appendChild(this.elem)
|
||
|
document.body.appendChild(this.viselem)
|
||
|
|
||
|
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, visible, name, description, src, width, height, dirs, elem, posX, posY
|
||
|
this.type="character"
|
||
|
|
||
|
this.visible=false
|
||
|
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)
|
||
|
}
|