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

147
Views
Creé un juego de tirachinas usando matter.js. Necesita ayuda para rastrear la puntuación y el botón de reinicio

Creé un juego de tirachinas en matter.js donde creé una pelota que se usa como una honda y algunas pelotas objetivo en un suelo que debe empujarse. He adjuntado el código a continuación. Necesito ayuda en el seguimiento de la puntuación para que cada vez que el usuario empuje todas las bolas del suelo "¡Ganaste!" debe mostrarse el mensaje. También necesito ayuda para agregar el botón de reinicio. Enlace al juego en vivo

 let engine = Matter.Engine.create(); let render = Matter.Render.create({ element: document.body, engine: engine, options: { width: 1600, height: 800, wireframes: false } }); let ground = Matter.Bodies.rectangle(1200, 500, 300, 60, { isStatic: true }); let mouse = Matter.Mouse.create(render.canvas); let mouseConstraint = Matter.MouseConstraint.create(engine, { mouse: mouse, constraint: { render: {visible: false} } }); render.mouse = mouse; let ball = Matter.Bodies.circle(300, 600, 20); let sling = Matter.Constraint.create({ pointA: {x:300, y:600}, bodyB: ball, stiffness: 0.05 }) let stack = Matter.Composites.stack(1100, 270, 4, 4, 0, 0, function(x, y){ return Matter.Bodies.polygon(x, y, 8, 30); }); let firing = false; Matter.Events.on(mouseConstraint, 'enddrag', function(e){ if(e.body === ball) firing = true; }); Matter.Events.on(engine, 'afterUpdate', function(){ if(firing && Math.abs(ball.position.x-300)<200 && Math.abs(ball.position.y-600)<20){ ball = Matter.Bodies.circle(300, 600, 20); Matter.World.add(engine.world, ball); sling.bodyB = ball; firing = false; } }) Matter.World.add(engine.world, [stack, ground,ball, sling, mouseConstraint]); Matter.Engine.run(engine); Matter.Render.run(render);

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!