HTML and CSS Reference
In-Depth Information
document
.
onkeydown
=
function
function
(
e
){
e
=
e
?
e
:
window
.
event
;
keyPressList
[
e
.
keyCode
]
=
true
true
;
}
document
.
onkeyup
=
function
function
(
e
){
//document.body.onkeyup=function(e){
e
=
e
?
e
:
window
.
event
;
keyPressList
[
e
.
keyCode
]
=
false
false
;
};
//key presses
var
var
keyPressList
=
[];
//images
var
var
tileSheet
=
new
new
Image
();
tileSheet
.
src
=
"scrolling_tiles.png"
;
//mapdata
var
var
world
=
{};
//camera
var
var
camera
=
{}
//key presses
var
var
keyPressList
=
{};
function
function
init
() {
world
.
cols
=
15
;
world
.
rows
=
15
;
world
.
tileWidth
=
32
;
world
.
tileHeight
=
32
;
world
.
height
=
world
.
rows
*
world
.
tileHeight
;
world
.
width
=
world
.
cols
*
world
.
tileWidth
;
camera
.
height
=
theCanvas
.
height
;
camera
.
width
=
theCanvas
.
width
;
camera
.
rows
=
camera
.
height
/
world
.
tileHeight
;
camera
.
cols
=
camera
.
width
/
world
.
tileWidth
;
camera
.
dx
=
0
;
camera
.
dy
=
0
;
camera
.
x
=
0
;
camera
.
y
=
0
;