O
Onideus Mad Hatter
Well in theory it was a good idea:
http://www.backwater-productions.net/_test_platform/game/index.html
Press "4" to move left, press "6" to move right.
The question remains though...is there some way of limiting
onkeypress? Cause if you hold the key down, boy that's just all
shades of unhappy right there.
: char_l_img = 1;
: char_r_img = 1;
: start_pos = 300;
: nav4 = window.Event ? true : false;
:
: function move_left()
: {
: start_pos = start_pos - 5;
: char_l_img++;
: if ( start_pos == 25 ) { start_pos = 30; }
: if ( char_l_img == 5 )
: {
: char_l_img = "1";
: window.clearInterval(farfoos);
: }
: document.getElementById("char_div").style.left = start_pos + "px";
: document.getElementById("char_img").src = "l" + char_l_img + ".gif";
: }
:
: function move_right()
: {
: start_pos = start_pos + 5;
: char_r_img++;
: if ( start_pos == 500 ) { start_pos = 495; }
: if ( char_r_img == 5 )
: {
: char_r_img = "1";
: window.clearInterval(farfoos);
: }
: document.getElementById("char_div").style.left = start_pos + "px";
: document.getElementById("char_img").src = "r" + char_r_img + ".gif";
: }
:
: function move(e)
: {
: if (nav4) { whichCode = e.which; }
: else { whichCode = event.keyCode; }
: if( String.fromCharCode(whichCode) == 4 && char_l_img == 1 ) { farfoos = window.setInterval('move_left()', 35); }
: if( String.fromCharCode(whichCode) == 6 && char_r_img == 1 ) { farfoos = window.setInterval('move_right()', 35);}
: }
:
: document.onkeypress = move;
:
: document.write("<div id='char_div' style='position:absolute; z-index:0; left:" + start_pos + "px; top:150px; width:32px height:64px'><img id='char_img' src='r1.gif'></div>");
I tried that && char_l_img == 1 thing, but that didn't seem to cut it.
Is there some way to detect when a key is NOT being pushed?
Hrmmm...I'm at a loss on this one at the moment, I think maybe I need
to get some sleep. -_-
I might need to rethink the whole way it actually functions...maybe do
it in PHP...hrmmm...wonder if PHP has an onkeypress equivalent...
http://www.backwater-productions.net/_test_platform/game/index.html
Press "4" to move left, press "6" to move right.
The question remains though...is there some way of limiting
onkeypress? Cause if you hold the key down, boy that's just all
shades of unhappy right there.
: char_l_img = 1;
: char_r_img = 1;
: start_pos = 300;
: nav4 = window.Event ? true : false;
:
: function move_left()
: {
: start_pos = start_pos - 5;
: char_l_img++;
: if ( start_pos == 25 ) { start_pos = 30; }
: if ( char_l_img == 5 )
: {
: char_l_img = "1";
: window.clearInterval(farfoos);
: }
: document.getElementById("char_div").style.left = start_pos + "px";
: document.getElementById("char_img").src = "l" + char_l_img + ".gif";
: }
:
: function move_right()
: {
: start_pos = start_pos + 5;
: char_r_img++;
: if ( start_pos == 500 ) { start_pos = 495; }
: if ( char_r_img == 5 )
: {
: char_r_img = "1";
: window.clearInterval(farfoos);
: }
: document.getElementById("char_div").style.left = start_pos + "px";
: document.getElementById("char_img").src = "r" + char_r_img + ".gif";
: }
:
: function move(e)
: {
: if (nav4) { whichCode = e.which; }
: else { whichCode = event.keyCode; }
: if( String.fromCharCode(whichCode) == 4 && char_l_img == 1 ) { farfoos = window.setInterval('move_left()', 35); }
: if( String.fromCharCode(whichCode) == 6 && char_r_img == 1 ) { farfoos = window.setInterval('move_right()', 35);}
: }
:
: document.onkeypress = move;
:
: document.write("<div id='char_div' style='position:absolute; z-index:0; left:" + start_pos + "px; top:150px; width:32px height:64px'><img id='char_img' src='r1.gif'></div>");
I tried that && char_l_img == 1 thing, but that didn't seem to cut it.
Is there some way to detect when a key is NOT being pushed?
Hrmmm...I'm at a loss on this one at the moment, I think maybe I need
to get some sleep. -_-
I might need to rethink the whole way it actually functions...maybe do
it in PHP...hrmmm...wonder if PHP has an onkeypress equivalent...