All pastes #257313 Raw Edit

Mine

public java v1 · immutable
#257313 ·published 2006-11-25 05:11 UTC
rendered paste body
import java.awt.*;import java.awt.geom.*;import java.awt.event.*;import java.text.DecimalFormat;import java.util.ArrayList;import java.util.StringTokenizer;import javax.swing.JFrame;import javax.swing.JPanel;   public class moveGUI extends JPanel implements KeyListener{private ArrayList<String> stack;private JFrame gBigFrame;private JFrame background;public Graphics dummyvariable;private String postfix;private ArrayList<String> postfixbreaker = new ArrayList<String>();private int width = 0;private int height = 0;public int hitcounter = 0;public int hitcounter2 = 0;private Color bg;public int x = 125;public int y = 125;public int xsquare;public int ysquare;public Color color;public boolean backsquare;public double seconds =180.0;public boolean showseconds = true;public ArrayList<ball> balllist;int xinput = (int)(Math.random()*140) + 20;int yinput = (int)(Math.random()*140) + 20;int xinput2 = (int)(Math.random()*140) + 20;int yinput2 = (int)(Math.random()*140) + 20;int xinput3 = 600;int yinput3 = 600;int xinput4 = (int)(Math.random()*140) + 20;int yinput4 = (int)(Math.random()*140) + 20;public int ballcount = 0;private final DecimalFormat DF = new DecimalFormat(".0");public boolean done = false;public int total = 0;public boolean showbonus = false;public boolean showbonus2 = false;public boolean showballs = true;public int kcount = 5000;public boolean showbonusmsg = false;public boolean startmove = true;public int reversecircleX = 1;public int reversecircleY = 1;public int reversecircle2X = 1;public int reversecircle2Y = 1;public int reverseboxX = 1;public int reverseboxY = 1;public boolean reversecircle = true;public boolean pause = false;public Thread thread;   public moveGUI(){ xsquare = 50;ysquare = 50;background = new JFrame("BG");background.setSize(300, 300);background.setContentPane(this);background.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);background.setVisible(true);background.setLocation(85, 80);background.setBackground(Color.black);gBigFrame = new JFrame("Ball-Hunter");gBigFrame.setSize(300, 300);gBigFrame.setContentPane(this);gBigFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);gBigFrame.setVisible(true);gBigFrame.setLocation(85, 80);gBigFrame.setBackground(Color.black);gBigFrame.addKeyListener(this);color = Color.blue;  }       public void update(){	  	  //THIS IS WHAT YOU CHANGE TO SELECT BALL NUMBER   ballcount = 5;   // :) :) :) :) Got Balls?      if (showballs) {		  balllist = new ArrayList<ball>();		   for (int i = 0; i < ballcount; i++) {			   ball a = new ball();			   balllist.add(a);		   }		  showballs = false;	  }   repaint(); try {if  (showseconds) { showseconds = false; while (seconds>0 && !pause) {  seconds = seconds-.1;  pause(50);  for (int i = 0; ballcount > i; i++) {	  for (int j=i; ballcount > j; j++) {		  if ((Math.sqrt(Math.pow((balllist.get(i).ballx-balllist.get(j).ballx), 2) + (Math.pow((balllist.get(i).bally-balllist.get(j).bally), 2))) <13) &&  i!=j) {			  this.repaint();						  balllist.get(i).reverse();			  balllist.get(j).reverse();			  balllist.get(i).hitmove();			  balllist.get(j).hitmove();			  		  }	  } }for (int i = 0; ballcount > i; i++) {	  if (balllist.get(i).ballx > 270 && balllist.get(i).bally > 215) {		  balllist.get(i).ballx = balllist.get(i).ballx - 10;		  balllist.get(i).bally = balllist.get(i).bally - 10;		  this.repaint();		  balllist.get(i).reverse();	  }	  else if (balllist.get(i).ballx > 270){		  balllist.get(i).ballx = balllist.get(i).ballx - 10;		  this.repaint();		  balllist.get(i).reversex();		}	  else if (balllist.get(i).bally > 215){		  balllist.get(i).bally = balllist.get(i).bally - 10;		  this.repaint();		  balllist.get(i).reversey();		}	  if (balllist.get(i).ballx < 5 && balllist.get(i).bally < 15) {		  balllist.get(i).ballx = balllist.get(i).ballx + 10;		  balllist.get(i).bally = balllist.get(i).bally + 10;		  this.repaint();		  balllist.get(i).reverse();	  }	  else if (balllist.get(i).ballx < 5){		  balllist.get(i).ballx = balllist.get(i).ballx + 10;		  this.repaint();		  balllist.get(i).reversex();		}	  else if (balllist.get(i).bally < 15){		  balllist.get(i).bally = balllist.get(i).bally + 10;		  this.repaint();		  balllist.get(i).reversey();		}	  }for (int i = 0; i < ballcount; i++) { balllist.get(i).move();}  gBigFrame.setContentPane(this);  this.repaint(); } pause(5000); this.clear();} pause(10);}catch (Exception x) {	System.out.println("WTF?");	x.printStackTrace();}} public synchronized void pause(int ms) {try{ wait(ms); }catch(InterruptedException mIE) { }} public void paint (Graphics g){try { Graphics2D tGraph = (Graphics2D)g;   String s = DF.format(seconds); width++; //System.out.println(width);   total = 150 * hitcounter + 400 * hitcounter2;  tGraph.setFont(new Font("Comic Sans MS", 17, 50)); tGraph.setColor(color); tGraph.drawString(".", x,y); tGraph.setColor(Color.green); tGraph.setFont(new Font("Comic Sans MS", 17, 10)); tGraph.drawString("Sq. Hits: " + hitcounter, 230,260); tGraph.drawString("Circ. Hits: " + hitcounter2, 160,260); tGraph.setColor(Color.pink); tGraph.drawString("Total Score [" + total + "]", 60, 260);   tGraph.setColor(Color.yellow); tGraph.drawRect(14, 250, 42, 12); tGraph.setColor(Color.blue); tGraph.fillRect(15, 251, 41, 10);   tGraph.setColor(Color.red); tGraph.drawString(s, 20, 260);   //tGraph.setColor(color); //tGraph.fillRect(xinput, yinput, 50,50); for (int i = 0; i < ballcount; i++) {	 tGraph.setColor(balllist.get(i).color);	 tGraph.fillOval(balllist.get(i).ballx, balllist.get(i).bally, 13, 13); } //tGraph.setColor(Color.red); //tGraph.fillOval(xinput4, yinput4, 13, 13);   int rand = (int)(Math.random()*10000);   if (showbonusmsg) {  tGraph.setFont(new Font("Comic Sans MS", 30, 70));  tGraph.setColor(Color.green);  tGraph.drawString("BONUS", 20, 150);   xinput3 = 500;   yinput3 =500; }   if (showbonus) { // System.out.println("SHOWBONUS1 " + xinput3 + " " + yinput3);  tGraph.setFont(new Font("Comic Sans MS", 30, 10));  tGraph.setColor(Color.red);  tGraph.drawString("BONUS", xinput3, yinput3); } if (showbonus2) {  //System.out.println("SHOWBONUS2 TRUE");  tGraph.setFont(new Font("Comic Sans MS", 30, 10));  tGraph.setColor(Color.YELLOW);  tGraph.drawString("BONUS", xinput3, yinput3); }     //System.out.println(" random is " + rand); if (rand >9995) {  System.out.println(" random is " + rand);    xinput3 = (int)(Math.random()*230);   yinput3 = (int)(Math.random()*150);  showbonus = true;  showbonus2 = false;  } else if (total > kcount) {  System.out.println("Total " + total + " > Kcount " + kcount);  tGraph.setFont(new Font("Comic Sans MS", 30, 10));  tGraph.setColor(Color.yellow);  tGraph.drawString("BONUS", xinput3, yinput3);    xinput3 = (int)(Math.random()*230);   yinput3 = (int)(Math.random()*150);  showbonus2 = true;  showbonus = false;  kcount = kcount + 5000; } //System.out.println(showbonus + " " + showbonus2);          if (done) {  tGraph.setColor(Color.red);  tGraph.setFont(new Font("Comic Sans MS", 17, 20)); // System.out.println("Counter is " + hitcounter);  if (total < 5000) {  // System.out.println("here");   tGraph.drawString("You are Ranked Newbie!", 20, 150);   tGraph.drawString("TOTAL SCORE [" + total + "]", 40, 180);  }  else if (total < 10000) {   tGraph.drawString("You are Ranked Moderate!", 20, 150);   tGraph.drawString("TOTAL SCORE [" + total + "]", 40, 180);  }  else if (total < 20000) {   tGraph.drawString("You are Ranked Expert!", 20, 150);   tGraph.drawString("TOTAL SCORE [" + total + "]", 40, 180);  }  else if (total< 30000) {   tGraph.drawString("You are Ranked Cheater!!", 20, 150);   tGraph.drawString("TOTAL SCORE [" + total + "]", 40, 180);  }    //this.repaint(); //pause(10000); //this.clear();    } }catch (Exception b) {}} public void clear(){gBigFrame.dispose();background.dispose();}  public void keyPressed(KeyEvent e){   if (!done) {	 int keyPressed = e.getKeyCode();	 if (keyPressed==32) {		   pause = !pause;		}	 if (!pause) { //System.out.println(" IN HERE "); if (keyPressed==38) {  y=y-10;   }   else if (keyPressed==39) {  x=x+10;   }   else if (keyPressed==37) {   x=x-10;   }   else if (keyPressed==40) {  y=y+10;   }	    			 // move.xsquare = xinput;// move.ysquare = yinput; if (this.x>295) {  this.x=5; } else if (this.x<5) {  this.x = 295; } else if (this.y>245) {  this.y = 5; } else if (y<5) {  this.y = 245; }// this.update(); //System.out.println("Xinput " + xinput + " Yinput " + yinput); //System.out.println("X " + x + " Y " + y);  // if (x>=xinput-4 && x<=xinput+54 && y>=yinput-4 && y<=yinput+54) {//  showbonusmsg = false;//  System.out.println("ZOMG YOU HIT A SQUARE");//   //move.clear();//  // move = new moveGUI();//   xinput = (int)(Math.random()*250) + 20;//   yinput = (int)(Math.random()*200) + 20;//   this.xsquare = xinput;//   this.ysquare = yinput;//   this.hitcounter = this.hitcounter+1;//   this.color = new Color((int)(Math.random()*240)+15,(int)(Math.random()*240)+15,(int)(Math.random()*240)+15);//    //   //break;// } // else  for (int i = 0; i<ballcount; i++) {	 if (Math.sqrt(Math.pow((x-balllist.get(i).ballx), 2) + (Math.pow((y-balllist.get(i).bally), 2))) <=17) {		 showbonusmsg = false;		 System.out.println("ZOMG YOU HIT A CIRCLE");		 //move.clear();		 // move = new moveGUI();	   balllist.get(i).ballx = (int)(Math.random()*250) + 20;	   balllist.get(i).bally = (int)(Math.random()*200)+ 20;	   this.hitcounter2 = this.hitcounter2+1;	   this.color = new Color((int)(Math.random()*240)+15,(int)(Math.random()*240)+15,(int)(Math.random()*240)+15);	   //break;	 } }//  else if (Math.sqrt(Math.pow((x-xinput4), 2) + (Math.pow((y-yinput4), 2))) <=14) {//	  showbonusmsg = false;//	  System.out.println("ZOMG YOU HIT A CIRCLE2");//	   //move.clear();//	  // move = new moveGUI();//	   xinput4 = (int)(Math.random()*250 + 20);//	   yinput4 = (int)(Math.random()*200)+ 20;//	   this.xsquare = xinput4;//	   this.ysquare = yinput4;//	   this.hitcounter2 = this.hitcounter2+1;//	   this.color = new Color((int)(Math.random()*240)+15,(int)(Math.random()*240)+15,(int)(Math.random()*240)+15);//	   //break;//	 } //else if (x>=xinput3-4 && x<=xinput3+24 && y>=yinput3-9 && y<=yinput3+9) {  showbonusmsg = false;  //System.out.println("BONUS TIME");   //move.clear();  // move = new moveGUI();   seconds = seconds + 10.0;   total = total + 300;   this.color = new Color((int)(Math.random()*240)+15,(int)(Math.random()*240)+15,(int)(Math.random()*240)+15);   showbonus = false;   showbonus2 = false;   showbonusmsg = true;       //break; }// System.out.println(keyPressed); } } else {  System.out.println("Game Over - no Cheating!"); }}public void keyReleased(KeyEvent e){ int keyPressed = e.getKeyCode(); //System.out.println(keyPressed);}public void keyTyped(KeyEvent e){   int keyPressed = e.getKeyCode(); //System.out.println(keyPressed);} }