bfsog
05-31-2004, 01:57 PM
I'm trying to create a game, which reacts on user keypresses. So far, when the user presses a, the man arms himself with a weapon, and h to hide the weapon, and f to fire.
What i'm after is for the user to press d or u (down or up) and for the image to move down or up.
ive tried...
function showText(e) {
if (e.keyCode) keycode=e.keyCode;
else keycode=e.which;
ch = String.fromCharCode(keycode);
all = ch;
if (all == 'a') {
document.images[0].src='manfire.gif';}
if (all == 'd') {
document.getElementById("man").style.top -= 15;}
if (all == 'f') {
document.images[0].src='manfiring.gif';}
if (all == 'h') {
document.images[0].src='man.gif';}
if (all == 'u') {
document.getElementById("man").style.top += 15;}
to no avail, he wont go up nor down.
I'll attach the whole file
thanks in advance
What i'm after is for the user to press d or u (down or up) and for the image to move down or up.
ive tried...
function showText(e) {
if (e.keyCode) keycode=e.keyCode;
else keycode=e.which;
ch = String.fromCharCode(keycode);
all = ch;
if (all == 'a') {
document.images[0].src='manfire.gif';}
if (all == 'd') {
document.getElementById("man").style.top -= 15;}
if (all == 'f') {
document.images[0].src='manfiring.gif';}
if (all == 'h') {
document.images[0].src='man.gif';}
if (all == 'u') {
document.getElementById("man").style.top += 15;}
to no avail, he wont go up nor down.
I'll attach the whole file
thanks in advance