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

192
Views
¿Hay alguna forma de detectar colisiones entre la pelota y las líneas?

Actualmente estoy trabajando en una pequeña simulación de física y tuve algunos problemas para descubrir cómo hacer que la pelota choque con las plataformas. Aquí está mi código:

 var a, f = 0.95, s = 0, vx = 0, vy = 0, b = -0.6, m = 10, x = 200, y = 100; function setup() { createCanvas(400, 400); a = m * 0.1; } function draw() { background(100); line(0, 100, 200, 210); line(400, 100, 150, 320); //friction and acceleration stuff vx *= f; x += vx; vy += a; y += vy; //wall collisions if (y >= height - 12) { vy *= b; y = height - 12; } if (y < 12) { y = 12; } if (x > width - 12) { vx *= b; x = width - 12; } if (x < 12) { vx *= b; x = 12; } ellipse(x, y, 24); //snapping position to mouse if(mouseIsPressed) { s = (winMouseX - pwinMouseX)/4; x = mouseX; y = mouseY; vx += s; vy = 0; } }

<script src="https://cdn.jsdelivr.net/npm/p5@1.4.1/lib/p5.js"></script>

Mis principales problemas provienen de no saber cómo lidiar con las pendientes, por lo que si alguien tiene una idea, se lo agradecería mucho. ¡Gracias!

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!