
Alexander Martinez
Preguntabuenas tardes he tenido un error con mi código que es que cuando intento dibujar con el teclado en la consola me aparece "Uncaught ReferenceError: dibujarLinea is not defined at HTMLDocument.dibujarTeclado " y no se que hace para solucionarlo, le paso mi codigo.
documento html
<!DOCTYPE html>
<html lang=“en” dir=“ltr”>
<head>
<meta charset=“utf-8”>
<title>dibujando con flechas</title>
</head>
<body>
<canvas width=“300” height=“300” id=“area_de_dibujo”></canvas>
<p>mueve las flechas del teclado para dibujar</p>
<script src=“eventos.js”></script>
</body>
</html>
documento jarvacript
var teclas =
{
UP: 38,
DOWN: 40,
LEFT: 37,
RIGHT:39
};
document.addEventListener(“keyup”, dibujarTeclado);
var cuadrito = document.getElementById(“area_de_dibujo”);
var papel = cuadrito.getContext(“2d”);
var x = 150;
var y = 150;
dibujarlinea(“red”, 149, 149, 151, 151, papel);
function dibujarlinea(color,xinicial,yinicial,xfinal,yfinal, lienzo)
{
lienzo.beginPath();
lienzo.strokeStyle = color;
lienzo.lineWidth = 5 ;
lienzo.moveTo(xinicial,yinicial);
lienzo.lineTo(xfinal,yfinal);
lienzo.stroke();
lienzo.closePath();
}
function dibujarTeclado(evento)
{
var colorcito = “red”;
var movimiento = 10;
switch(evento.keyCode)
{
case teclas.UP:
dibujarLinea(colorcito, x, y, x, y - movimiento, papel);
y = y - movimiento;
break;
case teclas.DOWN:
dibujarLinea(colorcito, x, y, x, y + movimiento, papel);
y = y + movimiento;
break;
case teclas.LEFT:
dibujarLinea(colorcito, x, y, x - movimiento, y, papel);
x = x - movimiento;
break;
case teclas.RIGHT:
dibujarLinea(colorcito, x, y, x + movimiento, y, papel);
x = x + movimiento;
break;
}
}
por favor ayuda

Alexander Martinez
gracias por ayudarme

Etienne Santiago Samboni
¡Hola, Alexander!
Tu función
dibujarlinea
l
dibujarTeclado
dibujarLinea
L
debes escribirla con
l