JAVA期中作业——弹球游戏 +砖块

package pinball;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Pinball {
    //Panel
    public  int  LENGTH=600;
    public  int  WIDTH1=600;
    public  int  START_X=100;
    public  int  START_Y=100;
    //Ball
    public int BALL_SIZE=30; 
    public int ball_x=LENGTH/2;
    public int ball_y=WIDTH1/2; 
    public int speed_x=11; 
    public int speed_y=7; 
    public int mouse_x=0; 
    public int mouse_y=0; 
    public int board1=WIDTH1/2;
    //Brick 
     public int B_LENGTH=30;
     public int B_WIDTH=100;
     public int B_LNUMBER=4;
     public int B_WNUMBER=5;
    
    MPanel mp = new MPanel();
    Timer t1;
    brick[][] lev1;
  
    public static void main(String[] args) {
        new Pinball().start();    
    }

  public void start(){
      MFrame jf=new MFrame();
      jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      jf.setVisible(true);
  }
class MFrame extends JFrame{   
     MFrame(){
     setTitle("弹球游戏 By Lucky");
     setSize(LENGTH+16,WIDTH1+30);
     setLocation(START_X,START_Y); 
   
     add(mp);
     t1 = new Timer(50, move);
      t1.start();
      addMouseMotionListener(mouse);
      lev1=new brick[B_LNUMBER][B_WNUMBER];
      int b_x_now=LENGTH/2,b_y_now=0;
      for(int m=0;m=LENGTH-BALL_SIZE-20))&&(ball_y>=board1-100)&&(ball_y<=board1))){
            speed_x=-speed_x;
        }
        else if((ball_x<=20)||(ball_x>=LENGTH-BALL_SIZE-20)){
            t1.stop();
        }
        
       else if((ball_y<=15)||(ball_y>=WIDTH1-BALL_SIZE)){
            speed_y=-speed_y;
        }
        for(int m=0;m=x-BALL_SIZE)&&(p_x<=x+B_LENGTH)&&(p_y>=y-BALL_SIZE)&&(p_y<=y+B_LENGTH)){
         visable=false;
         int m=((BALL_SIZE-x+p_x)<=(x-p_x))?BALL_SIZE-x+p_x:x-p_x;
         int n=((BALL_SIZE-y+p_y)<=(y-p_y))?BALL_SIZE-y+p_y:y-p_y;
         if(m<=n)
             pattern=1 ;
         else pattern=2 ;
     }
     else pattern=0;
   }
         
        
        
     
    }
  
    }

你可能感兴趣的:(JAVA)