Javascript Game Problem

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • für die faulen: -.-

    HTML-Quellcode

    1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    2. <html>
    3. <head>
    4. <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    5. <title>Pfeiltasten</title>
    6. </head>
    7. <body>
    8. <div style="background: transparent url(bunay.png) repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; left: 0px; top: 0px; position: absolute; height: 718px; width: 958px;">
    9. <img alt="Picture" src="right.png" style="margin: 304px 0 0 0px;" id="mann">
    10. <script type="text/javascript" language="JavaScript">
    11. var right = document.getElementById('mann').style.marginTop;
    12. right.replace("px", "");
    13. right = parseInt(right, 0);
    14. var left = document.getElementById('mann').style.marginLeft;
    15. left.replace("px", "");
    16. left = parseInt(left, 0);
    17. var top = document.getElementById('mann').style.marginTop;
    18. top.replace("px", "");
    19. top = parseInt(left, 0);
    20. var bottom = document.getElementById('mann').style.marginBottom;
    21. bottom.replace("px", "");
    22. bottom = parseInt(left, 0);
    23. var int_left = left / 16;
    24. var int_top = top / 16;
    25. function move(id, way)
    26. {
    27. if (way == 'Top')
    28. {
    29. if (int_top >= 3)
    30. {
    31. int_top--;
    32. var top = int_top * 16;
    33. } else
    34. {
    35. var top = 45;
    36. }
    37. var right = document.getElementById(id).style.marginRight;
    38. var left = document.getElementById(id).style.marginLeft;
    39. var bottom = document.getElementById(id).style.marginBottom;
    40. if (top <= 32 && left >= '512px' && left <= '512px')
    41. opener.window.location.href="wasser.htm";
    42. document.getElementById(id).src= 'top.png';
    43. }
    44. if (way == 'Bottom')
    45. {
    46. if (int_top <= 35)
    47. {
    48. int_top++;
    49. var top = int_top * 20;}
    50. else
    51. {
    52. var top = 32;
    53. }
    54. var right = document.getElementById(id).style.marginRight;
    55. var left = document.getElementById(id).style.marginLeft;
    56. var bottom = document.getElementById(id).style.marginBottom;
    57. if (top <= 384 && left >= '352px' && left <= '384px')
    58. document.getElementById(id).src= 'top.png';
    59. }
    60. if (way == 'Bottom')
    61. {
    62. if (int_top <= 20)
    63. {
    64. int_top++;
    65. var top = int_top * 16;}
    66. else
    67. {
    68. var top = 570;
    69. }
    70. var left = document.getElementById(id).style.marginLeft;
    71. var bottom = document.getElementById(id).style.marginBottom;
    72. var right = document.getElementById(id).style.marginRight;
    73. document.getElementById(id).src= 'bottom.gif';
    74. // alert(top+" jo o.o");
    75. }
    76. if (way == 'Left')
    77. {
    78. int_left--;
    79. if (int_left <= 0)
    80. int_left = 0;
    81. var left = int_left * 16;
    82. var right = document.getElementById(id).style.marginRight;
    83. var top = document.getElementById(id).style.marginTop;
    84. var bottom = document.getElementById(id).style.marginBottom;
    85. document.getElementById(id).src= 'left.png';
    86. // alert(left+" jo o.o");
    87. }
    88. if (way == 'Right')
    89. {
    90. if (int_left <= 52)
    91. {
    92. int_left++;
    93. var left = int_left * 16;
    94. } else
    95. {
    96. left = 848;
    97. }
    98. var right = document.getElementById(id).style.marginRight;
    99. var top = document.getElementById(id).style.marginTop;
    100. var bottom = document.getElementById(id).style.marginBottom;
    101. document.getElementById(id).src= 'right.png';
    102. // alert(left+" jo o.o");
    103. }
    104. document.getElementById(id).style.margin = top+' '+right+' '+bottom+' '+left+'';
    105. }
    106. function Explorer (Ereignis)
    107. {
    108. if (!Ereignis)
    109. Ereignis = window.event;
    110. Nummer = event.keyCode
    111. if (Nummer == 37)
    112. move('mann', 'Left');
    113. if (Nummer == 39)
    114. move('mann', 'Right');
    115. if (Nummer == 38)
    116. move('mann', 'Top');
    117. if (Nummer == 40)
    118. move('mann', 'Bottom');
    119. if (Nummer == 13)
    120. {
    121. var right = document.getElementById('mann').style.marginRight;
    122. var top = document.getElementById('mann').style.marginTop;
    123. var bottom = document.getElementById('mann').style.marginBottom;
    124. var left = document.getElementById('mann').style.marginLeft;
    125. if (left == '400px' && top == 320)
    126. alert('Möchtest du dein Item-Lager einsehen?');
    127. else
    128. window.status = top+'links';
    129. }
    130. }
    131. document.onkeypress = Explorer;
    132. function KeyCode (Result)
    133. {
    134. var right = document.getElementById('mann').style.marginRight;
    135. var top = document.getElementById('mann').style.marginTop;
    136. var bottom = document.getElementById('mann').style.marginBottom;
    137. var left = document.getElementById('mann').style.marginLeft;
    138. if (!Result)
    139. Result = window.event;
    140. if (Result.keyCode == 37)
    141. {
    142. move('mann', 'Left');
    143. }
    144. if (Result.keyCode == 39)
    145. {
    146. if (left == '112px' && top == '32px')
    147. {
    148. } else
    149. move('mann', 'Right');
    150. }
    151. if (Result.keyCode == 38)
    152. {
    153. move('mann', 'Top');
    154. }
    155. if (Result.keyCode == 40)
    156. {
    157. if (left >= '0px' && left <= '368px' && top == '384px')
    158. {
    159. document.getElementById('mann').src= 'bottom.gif';
    160. } else
    161. {
    162. move('mann', 'Bottom');
    163. }
    164. }
    165. if (Result.keyCode == 13)
    166. {
    167. if (left == '400px' && top == 320)
    168. alert('Möchtest du dien Lager einsehen?');
    169. else
    170. alert(top+' '+right+' '+bottom+' '+left);
    171. }
    172. }
    173. document.onkeypress = KeyCode;
    174. </script>
    175. </div>
    176. </body></html>
    Alles anzeigen