@@ -1421,14 +1421,14 @@ nos encontramos.
14211421
14221422hint}}
14231423
1424- ### A bouncing ball
1424+ ### Un balón botador
14251425
14261426{{index [ animation, "bouncing ball"] , "requestAnimationFrame function", bouncing}}
14271427
1428- Use the ` requestAnimationFrame ` technique that we saw in [ Chapter
1429- ?] ( dom#animationFrame ) and [ Chapter ?] ( game#runAnimation ) to draw a
1430- ((box )) with a bouncing ((ball )) in it. The ball moves at a constant
1431- ((speed )) and bounces off the box's sides when it hits them .
1428+ Usar la técnica de ` requestAnimationFrame ` que vimos en el [ Capítulo
1429+ ?] ( dom#animationFrame ) y [ Chapter ?] ( game#runAnimation ) para dibujar una
1430+ ((caja )) con un ((balón )) botando en el. El balón se mueve a una
1431+ ((velocidad )) constante y bota fuera de la caja cuando golpea un borde de la caja .
14321432
14331433{{if interactive
14341434
@@ -1448,7 +1448,7 @@ Use the `requestAnimationFrame` technique that we saw in [Chapter
14481448 requestAnimationFrame(frame);
14491449
14501450 function updateAnimation(step) {
1451- // Your code here .
1451+ // Tu código va aquí .
14521452 }
14531453</script>
14541454```
@@ -1459,26 +1459,27 @@ if}}
14591459
14601460{{index "strokeRect method", animation, "arc method"}}
14611461
1462- A ((box )) is easy to draw with ` strokeRect ` . Define a binding that
1463- holds its size or define two bindings if your box's width and height
1464- differ. To create a round ((ball )), start a path and call `arc(x, y,
1465- radius, 0, 7)`, which creates an arc going from zero to more than a
1466- whole circle. Then fill the path .
1462+ Una ((caja )) es fácil de dibujar con ` strokeRect ` . Define los bordes
1463+ para su tamaño o define dos bordes si el ancho y largo de la caja
1464+ son distintos. Para crear el ((balón )), empieza una ruta y llama
1465+ ` arc(x, y, radius, 0, 7)` , que crea un arco desde cero hasta algo
1466+ más de un círculo entero. Entonces rellena la ruta .
14671467
14681468{{index "collision detection", "Vec class"}}
14691469
1470- To model the ball's position and ((speed)), you can use the ` Vec `
1471- class from [ Chapter ?] ( game#vector ) [ (which is available on this
1472- page)] {if interactive}. Give it a starting speed, preferably one that
1473- is not purely vertical or horizontal, and for every ((frame)) multiply
1474- that speed by the amount of time that elapsed. When the ball gets
1475- too close to a vertical wall, invert the x component in its speed.
1476- Likewise, invert the y component when it hits a horizontal wall.
1470+ Para modelar la posición y ((velocidad)), puedes usar la clase ` Vec `
1471+ del [ Capítulo ?] ( game#vector ) [ (que está disponible en está página
1472+ )] {if interactive}. Dada una velocidad inicial, preferentemente uno
1473+ que no es puramente vertical o horizontal, y para cada ((frame))
1474+ multiplica esa velocidad por el monto de tiempo que transcurra.
1475+ Cuando el balón esté cerca de un muro vertical, invierte el componente x
1476+ en su velocidad. De manera similar, invierte el componente y cuando
1477+ golpee un muro horizontal.
14771478
14781479{{index "clearRect method", clearing}}
14791480
1480- After finding the ball's new position and speed, use ` clearRect ` to
1481- delete the scene and redraw it using the new position .
1481+ Después de encontrar la nueva posición y velocidad del balón, usa
1482+ ` clearRect ` para borrar la escena y redibujarla usando la nueva posición .
14821483
14831484hint}}
14841485
0 commit comments