Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

357
Visualizações
¿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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda