JavaScript - Problema con el movimiento de

 
Vista:

Problema con el movimiento de

Publicado por kevin gonzalez (1 intervención) el 30/09/2011 00:42:43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title> Juego </title>
    <script type = "text/JavaScript">
      var anchPant;
      var x;
      var y;
      var dir; //1: derecha, -1: izquierda
      var tempMovi;
      var tempMoviSaltar;
      var temNube;
	  var temBala;
      var vida;
      var vidapjp = 100;
 
      function inicializacion() {
        anchPant = document.body.offsetWidth/2;
        x = 0;
        y = 75;
        dir = 1;
        tempMovi = 24;
        tempMoviSaltar = 24;
        temNube = -200;
		temBala = 5900;
	    vidapjp;
        setTimeout("movimientoNube()",10)
      }
 
      document.onkeydown = function() {
        if(window.event.keyCode == 39) {
          if(tempMovi == 24) {
            document.getElementById('personaje').src="imagenes/personajeDer1.png";
            dir = 1;
            tempMovi = 0;
            movimientoAvanzar();
          }
        }
        if(window.event.keyCode == 37) {
          if(tempMovi == 24) {
            document.getElementById('personaje').src="imagenes/personajeIzq1.png";
            dir = -1;
            tempMovi = 0;
            movimientoRetroceder();
          }
        }
 
        if(window.event.keyCode == 32) {
          if(tempMoviSaltar == 24) {
            tempMoviSaltar = 0;
            movimientoSaltar();
          }
        }
      }
 
      document.onkeyup = function() {
        if(window.event.keyCode == 39)
          document.getElementById('personaje').src="imagenes/personajeDer1.png";
 
        if(window.event.keyCode == 37)
          document.getElementById('personaje').src="imagenes/personajeIzq1.png";
      }
 
      function movimientoAvanzar() {
        if(tempMovi < 24 && (x + 5) < 7900) {
          x = x + 15;
          document.getElementById('personaje').style.left = x;
        }
        if(x > anchPant)
          self.scroll(x - anchPant, 1);
        tempMovi++;
        if(tempMovi < 24)
          setTimeout("movimientoAvanzar()", 10);
      }
 
      function movimientoRetroceder() {
        if(tempMovi < 24  && (x - 5) > 0) {
          x = x - 15;
          document.getElementById('personaje').style.left = x;
        }
        if(x > anchPant)
          self.scroll(x - anchPant, 1);
        tempMovi++;
        if(tempMovi < 24)
          setTimeout("movimientoRetroceder()", 10);
      }
 
      function movimientoSaltar() {
        if(tempMoviSaltar < 12) {
          y = y + 20;
 
          document.getElementById('personaje').style.bottom = y;
        }
        else {
          y = y - 20;
          document.getElementById('personaje').style.bottom = y;
        }
        if(dir == 1 && (x + 60) < 7900) {
          x = x + 50;
          document.getElementById('personaje').src="imagenes/personajeSalDer1.png";
          document.getElementById('personaje').style.left = x;
        }
        else {
          if((x - 10) > 0) {
            x = x - 50;
            document.getElementById('personaje').src="imagenes/personajeSalIzq1.png";
            document.getElementById('personaje').style.left = x;
          }
        }
        if(x > anchPant)
          self.scroll(x - anchPant, 1);
        tempMoviSaltar++;
        if(tempMoviSaltar < 24)
          setTimeout("movimientoSaltar()", 15);
        else {
          if(dir == 1)
            document.getElementById('personaje').src="imagenes/personajeDer1.png";
          else
            document.getElementById('personaje').src="imagenes/personajeIzq1.png";
        }
      }
 
      function movimientoNube() {
        temNube = temNube + 1;
		temBala = tembala + 1;
		if(vidapjp < 1){
	  document.getElementById('personaje').src="imagenes/personajeMuerto.png";
	  tempMovi=500000
	  tempMoviSaltar=500000}
		document.getElementById('vida').innerHTML = vidapjp;
        document.getElementById('nume').style.left = temNube;
 
        setTimeout("movimientoNube()", 10);
      }
    </script>
  </head>
  <body style="background: #006cff; background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0.4, #006cff),color-stop(0.7, #18437d));background-image: -moz-linear-gradient(center bottom,#006cff 40%,#18437d 70%);overflow: hidden; margin: 0;" onload="inicializacion();">
    <img alt="sol" src="imagenes/sol.png" style="position: fixed; top: 10px; right: 10px;">
 
   <img alt="Nube" src="imagenes/nube.png" style="position: absolute; top: 20px; left: -200px;" id="nume">
    <img alt="Bala" src="imagenes/baladeprueba.png" style="position: absolute; top: 15 px; left: 5900px;" id="bala">
 
    <img alt="arboles" src="imagenes/arbol.png" style="position: absolute; bottom: 20px; left: 2000px;">
    <img alt="arboles" src="imagenes/arbol.png" style="position: absolute; bottom: 20px; left: 2500px;">
    <img alt="arboles" src="imagenes/arbol.png" style="position: absolute; bottom: 20px; left: 3000px;">
    <img alt="arboles" src="imagenes/arbol.png" style="position: absolute; bottom: 20px; left: 3500px;">
    <img alt="arboles" src="imagenes/arbol.png" style="position: absolute; bottom: 20px; left: 4000px;">
    <img alt="arboles" src="imagenes/arbol.png" style="position: absolute; bottom: 20px; left: 4500px;">
    <img alt="arboles" src="imagenes/arbol.png" style="position: absolute; bottom: 20px; left: 5000px;">
    <img alt="arboles" src="imagenes/arbol.png" style="position: absolute; bottom: 20px; left: 5500px;">
    <img alt="arboles" src="imagenes/arbol.png" style="position: absolute; bottom: 20px; left: 6000px;">
    <img alt="arboles" src="imagenes/arbol.png" style="position: absolute; bottom: 20px; left: 6500px;">
    <img alt="arboles" src="imagenes/arbol.png" style="position: absolute; bottom: 20px; left: 7000px;">
 
    <img alt="casa" src="imagenes/casa.png" style="position: absolute; bottom: 50px; left: 100px;" width="1500px">
 
    <img alt="personaje" src="imagenes/personajeDer1.png" style="position: absolute; bottom: 75px; left: 0;" id="personaje">
 
    <img alt="pizo" src="imagenes/suelo.png" style="position: absolute; bottom: 0; left: 0;">
    <img alt="pizo" src="imagenes/suelo.png" style="position: absolute; bottom: 0; left: 1000px;">
    <img alt="pizo" src="imagenes/suelo.png" style="position: absolute; bottom: 0; left: 2000px;">
    <img alt="pizo" src="imagenes/suelo.png" style="position: absolute; bottom: 0; left: 3000px;">
    <img alt="pizo" src="imagenes/suelo.png" style="position: absolute; bottom: 0; left: 4000px;">
    <img alt="pizo" src="imagenes/suelo.png" style="position: absolute; bottom: 0; left: 5000px;">
    <img alt="pizo" src="imagenes/suelo.png" style="position: absolute; bottom: 0; left: 6000px;">
    <img alt="pizo" src="imagenes/suelo.png" style="position: absolute; bottom: 0; left: 7000px;">
	<img alt="elmalodisparargif" src="imagenes/elmalogif.gif" style="position: absolute; bottom: 65px; left: 6000px;">
 
	<div style="position: fixed; top: 30px; left: 30px; z-index: 999; font-family: 'tahoma'; font-size: 22px; color: #777777; font-weight: 700;">
		Vida: <div id="vida" style="display: inline;"> 100 </div>
	</div>
 
  </body>
</html>

ese es el codigo de mi juego en html5 y javascript,
funciona bien solo en google Chrome (firefox funciona muy mal, opera mas o menos, pero tiene errores) en internet explorer y Netscape Navegator no se.

bueno si quieren probarlo entren a http://todoacercadelestudio.site90.net/juego.html

Mi problema esque la nube no se mueve, y la bala tampoco se mueve, (luego de que la bala se mueva correctamente le pondre para que haga daño al personaje)
me dicen porque la nube y la bala no se mueven?
entren a http://todoacercadelestudio.site90.net/juego.html para ver como funciona el juego.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder