Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
¿Cómo controlar las paletas en un juego de ping pong?

Estoy haciendo un juego de ping pong en html canvas, tengo 4 botones, 2 para que cada jugador controle las paletas, pero no sé cómo controlarlas. Agregando un detector de eventos "onclick" y cambiando la velocidad y, esto no funciona, supongamos que presioné el botón de abajo para el jugador 1

La paleta bajará, pero cuando se suelta el botón, la paleta continúa hasta que se presiona otro botón.

Deje que los botones de control sean

 const p1up = document.getElementById('p1up') const p1down = document.getElementById('p1down') const p2up = document.getElementById('p2up') const p2down = document.getElementById("p2down")

Y esta es la clase de pádel

 class paddle { constructor(x, y) { this.x = x this.y = y this.ysp = 0 } draw() { ctx.fillStyle = "#fff" ctx.beginPath() ctx.rect(this.x, this.y, 10, 80) ctx.fill() } update() { this.y += this.ysp } limit() { this.y = clamp(this.y, 0, area.height) } }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!