Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am making a game in java that sort of moves like flappy bird. In this code so

ID: 3774970 • Letter: I

Question

I am making a game in java that sort of moves like flappy bird. In this code so far there is a moving background with a picture of trump in the middle. I would like for you to make another class that will make bird go up if you press w and move down if you press s. This project requires 2 classes that's why. I am also using EZ java with images that i took online.

public class flappy {

   public static void main(String[] args) {

       // Setup EZ graphics system.

       EZ.initialize(1000,500); // PIXEL picture element

      

       EZImage sky1 = EZ.addImage("skyrepeat.jpg", 500,255);

       EZImage sky2 = EZ.addImage("skyrepeat.jpg", 1500, 255);

      

  

       EZImage[] trumpPictures = new EZImage[1];

       for (int i=0; i < 1; i++){

           trumpPictures[i]= EZ.addImage("bird.png", 500, i*100+250);//i starts at 0. use 50 to determine the first vertical position

       } //variable is no longer in scope

      

              

       while (true) {

           for (int i = 0; i < 1; i++){

          

           sky1.moveForward(-1);

           sky2.moveForward(-1);

          

  

          

           if (sky1.getXCenter() < -500) {

                   sky1.moveForward(2000);

           }

           if (sky2.getXCenter() < -500) {

                   sky2.moveForward(2000);

           }

  

      

           EZ.refreshScreen();

       }

   }

   }}

Explanation / Answer

program import java.awt.Font;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import acm.graphics.GLabel;
import acm.program.GraphicsProgram;
import javax.imageio.ImageIO;
import acm.util.MediaTools;
public class FlappyBird extends GraphicsProgram
{
public Background background;
public UpTube uptube;
public DownTube downtube;
public Bird bird;
public static final int APPLICATION_WIDTH = 882;
public static final int APPLICATION_HEIGHT = 772;
public void run()
{
addKeyListeners();
background = new Background();
add(background);
uptube = new UpTube();
add(uptube);
downtube = new DownTube();
add(downtube);
bird = new Bird();
add(bird);
public void jump()
{
for(int i =0;i<5;i++)
{
bird.move(3,-7);
pause(100);
}
for(int i =0;i<15;i++)
{
bird.move(5, -4);
pause(100);
}
for(int i =0;i<15;i++)
{
bird.move(7,0);
pause(100);
}
for(int i =0;i<15;i++)
{
bird.move(5,7);
pause(100);
}
for(int i =0;i<15;i++)
{
bird.move(3,-7);
pause(100);
}
}
public void keyPressed(KeyEvent e)
{
if(e.getKeyCode() == KeyEvent.VK_SPACE)
{
jump();
}