Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

356
Vistas
¿Cómo hacer que el personaje salte pero solo hasta cierta altura y luego vuelva a bajar al nivel del suelo?

Actualmente estoy tratando de trabajar en un pequeño proyecto para mi módulo de programación y todavía soy un principiante ya que es solo el primer semestre. Quiero hacer que mi personaje salte cuando presiono la tecla de flecha hacia arriba, pero solo hasta cierta altura y luego vuelva a bajar, no sé cómo hacerlo, por ahora, cuando presiono la tecla de flecha, el personaje sigue subiendo si lo mantengo presionado y de lo contrario se detiene en el aire. este es el enlace para mi código en el editor en línea ya que no puedo publicar todo el código aquí GP 3A . La parte de abajo es donde estoy teniendo problemas.

 if (isLeft == true) { gameChar_x -= 5 } if (isRight == true) { gameChar_x += 5 } if (isJumping == true) { gameChar_y -= 5 } // if (gameChar_y == gameChar_y - 5) // { // gameChar_y += 5 // } // if (isPlummeting == true) // { // gameChar_y += 10 // } } function keyPressed() { // if statements to control the animation of the character when // keys are pressed. //open up the console to see how these work // console.log("keyPressed: " + key); // console.log("keyPressed: " + keyCode); if (keyCode == 37) { isLeft = true } else if (keyCode == 39) { isRight = true } else if (keyCode == 38) { isJumping = true } } function keyReleased() { // if statements to control the animation of the character when // keys are released. // console.log("keyReleased: " + key); // console.log("keyReleased: " + keyCode); if (keyCode == 37) { isLeft = false } else if (keyCode == 39) { isRight = false } else if (keyCode == 38) { isJumping = false } }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

var jumping = false; var gravity = 1; var rectangle = { x: 20, y: 0, vx: 10, // X velocity vy: 5, // Y velocity velocity = acceleration size: 80 }; var ground = { x: 0, y: 600-rectangle.size, width: 600 }; function setup() { createCanvas(600, 600); } function draw () { background('#000000'); // The Rectangle fill('red'); rect(rectangle.x, rectangle.y, rectangle.size); // Physics rectangle.y += rectangle.vy; // contantly add y velocity rectangle.vy += gravity; // constantly add gravity to Y // Ground check if (rectangle.y > ground.y - 0 && rectangle.x <= ground.width) { rectangle.y = ground.y - 0; rectangle.vy = 0; jumping = false; } // Right if (keyIsDown(RIGHT_ARROW)) { rectangle.x += rectangle.vx; } // Left if (keyIsDown(LEFT_ARROW)) { rectangle.x -= rectangle.vx; } } // THE JUMP function keyPressed() { if (jumping === false && keyCode === UP_ARROW) { rectangle.vy -= 10; jumping = true; console.log(jumping); } }
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda