94 lines
2.9 KiB
JavaScript
94 lines
2.9 KiB
JavaScript
/*
|
|
Eon Aton: a RPG-like game system in JavaScript
|
|
Copyright (C) 2008-2009 Niels Serup
|
|
|
|
This file is part of Eon Aton.
|
|
|
|
Eon Aton is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
Eon Aton is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with Eon Aton. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/*
|
|
This file contains the different classes to be used with Eon Aton.
|
|
*/
|
|
// 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)
|
|
} |