no se llama la función desde la declaración switch
Publicado por VORZAM (3 intervenciones) el 28/07/2019 16:14:57
He estado probando a llamar la función desde la declaración switch, pero solo funciona cuando pongo el código de la función directamente en la declaración.
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
var x = 0;var y = 0;var player = document.getElementById('jugador');
var geny = 0var genx = 0var ramx = 0var ramy = 0var enm = 0var mov = 6function gen_ran(){
ramy = Math.round(Math.random()*(6-1)+1)
ramx = Math.round(Math.random()*(6-1)+1)
switch (ramy){
case 1: geny = 0break;
case 2: geny = 50break;
case 3: geny = 100break;
case 4: geny = 150break;
case 5: geny = 200break;
case 6: geny = 250break;
}switch (ramx){
case 1: genx = 0break;
case 2: genx = 50break;
case 3: genx = 100break;
case 4: genx = 150break;
case 5: genx = 200break;
case 6: genx = 250break;
}}switch(enm){
case 0:gen_ran();
$("#pantalla").prepend('<div class="enemigo" id="enm1"></div>')
$("#enm1").css("margin-top",geny)
$("#enm1").css("margin-left",genx)
break;
}function rigth(){
if(x < 250){
x += 50;
player.style.left = x+'px';
mov++
};};function left(){
if(x > 0){
x -= 50;
player.style.left = x+'px';
mov++
};};function up(){
if(y > 0){
y -= 50;
player.style.top = y+'px';
mov++
};};function down(){
if(y < 250){
y += 50;
player.style.top = y+'px';
mov++
};};Valora esta pregunta


0


