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

333
Views
¿Cómo puedo hacer diferentes niveles para un juego? ¿Tendría que hacer clases diferentes?

Ya tengo un archivo sketch.js con algunos gameStates.

 var gameState = "wait";

Agregué declaraciones condicionales como:

 if(gameState == "wait"){ background(backgroundImg); textSize(50); fill("blue"); text("Project42 Own",250,400); startButton.visible = true; gun.visible = false; backBoard.visible = false; }

A continuación se muestra el código que tiene el nivel 1, espera, juega y finaliza el estado del juego:

 function draw() { if(gameState == "wait"){ background(backgroundImg); textSize(50); fill("blue"); text("Project42 Own",250,400); startButton.visible = true; gun.visible = false; backBoard.visible = false; } if(mousePressedOver(startButton)&& gameState == "wait"){ gunSound.play(); gunSound.setVolume(0) gameState = "play"; } if(gameState == "play"){ background("#BDA297") fill("red"); textSize(30); text("Score:" + score + " ",300,100); fill("green"); text("Life:" + life + " ",800,100) gun.y=mouseY startButton.visible = false; gun.visible = true; backBoard.visible = true; if(keyDown("SHIFT")){ shootBullets(); } if (frameCount % 80 === 0) { drawBlueBubble(); } if (frameCount % 100 === 0) { drawRedBubble(); } if(blueBubbleGroup.collide(bulletGroup)){ handleBubbleCollision(blueBubbleGroup); score +=5; } if(redBubbleGroup.collide(bulletGroup)){ handleBubbleCollision(redBubbleGroup); score += 10; } if (blueBubbleGroup.collide(backBoard)){ handleGameover(blueBubbleGroup); } if (redBubbleGroup.collide(backBoard)) { handleGameover(redBubbleGroup); } } if (life == 0) { gameState == "end" } if(gameState == "end"){ background(gameOverImg) redBubbleGroup.hideEverything() blueBubbleGroup.hideEverything(); } drawSprites(); }

Sin embargo, ahora quiero hacer el nivel 2 en el que habrá más obstáculos. Además, no soy un codificador profesional, así que sea claro en su respuesta.

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!