smmk143143 0 Newbie Poster
package myDxBall;





import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Shape;
import javax.swing.*;
import javax.swing.event.*;

/*
<applet code="myDxball.class" width=670 height=300>
</applet>
*/

public class myDxBall extends Applet implements Runnable,MouseListener,KeyListener{
	static Rectbar Recob[] = new Rectbar[45];
	Thread th;
	int x_pos = 5 ; 
	int y_pos = 50;
	public static int radius = 10;            
	int appletsize_x = 600;    
	int appletsize_y = 300;
	private Image dbImage;
	private Graphics dbg;
	boolean collide;
	Ball bl;
	Bar br;
	Graphics fn;
	boolean fns=true;
	

	public void init(){
		/*
		 * DX_BALL GAME
		 * Developer: Mursalin Kabir(মুরসালিন কবির)
		 * North South University,Bangladesh   
		 * mail2mursalin@gmail.com
		 * cell:+8801674905511
		 * http://www.facebook.com/mursalinkabir
		 */
		setBackground(Color.BLACK);
		bl = new Ball(150,90);
		br = new Bar(70);
		int xm=30,ym=30;
		for(int i =0 ;i<36;i=i+3)
		{
		Recob[i] = new Rectbar(xm,ym);
		
		ym=ym+20;
		Recob[i+1] = new Rectbar(xm,ym); //initialization of object
		
		ym=ym+20;
		Recob[i+2] = new Rectbar(xm,ym);
		
		xm=xm+50;
		ym = 30;


		}
		
		
		
		
		this.addMouseListener(this);
		this.addKeyListener(this);
	}
  public void start(){
	 th =  new Thread(this);
	 
}
  public void stop(){
	  
  }
  public void destroy(){
	  
  }
  public void run(){
	  Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
	  
	  while(fns){
		  
		  if( bl.getX()>appletsize_x-radius ){                //BOUNDARY CHECK
				bl.move2();
			  }
			  else if(bl.getX() <radius){
				  bl.move3();
			  }
			   
			   if(bl.getY()<radius){
				   bl.move5();
			   }
			   else if(bl.getY()>appletsize_y){
				
				
				
				fns= false;
			   }
		  bl.move1();  
		  bl.move();
		  if(br.collidebar(bl)){
			  bl.move6();                  //collision detection
		  }
		  for(int i = 0;i<36;i++){
			  if(Recob[i].getdisp() == true){
			  if(Recob[i].collideRect(bl)){
			Recob[i].setdisp(false);
			bl.move7();
		  }else{
			  continue;
		  }
		  }
		  }
		  repaint();
		  try{
			  Thread.sleep(20);
		  }catch(Exception e){
			  
		  }
	  }
  }
  
  public void paint(Graphics g){
	  
		
	  bl.bpaint(g);
	  br.barpaint(g);
	  for(int i=0;i<36;i++){
		  if(Recob[i].getdisp() == true){   
		  Recob[i].paintrect(g);
	  }else{
		  continue;
	  }
		
	  }  
  }
  
  public void mousePressed(MouseEvent me)
  {
	  th.start();                            //starting the thread
  }
  public void mouseReleased(MouseEvent me)
  {
    
  }
  public void mouseClicked(MouseEvent me)
  {
   
  }
  public void mouseExited(MouseEvent me)
  {

  }
  public void mouseEntered(MouseEvent me)
  {
  }
  public void keyPressed(KeyEvent k){
	  int R= k.getKeyCode();
	  if(R== k.VK_RIGHT){
		  if(br.yy < 630){
			  br.yy= br.yy+10;
		  }
		  repaint();                  //keyboard input and controlling the bar
	  }
	  if(R== k.VK_LEFT){
		  if(br.yy > 0){
			  br.yy= br.yy-10;
		  }
		  repaint();
	  }
	  
  }
 public void keyReleased(KeyEvent k){
	  
  }
 public void keyTyped(KeyEvent k){
	  
 }
  public void update (Graphics g)
  {

      // initialize buffer
      if (dbImage == null)
      {
          dbImage = createImage (this.getSize().width, this.getSize().height);
          dbg = dbImage.getGraphics ();
      }

      // clear screen in background
      dbg.setColor (getBackground ());
      dbg.fillRect (0, 0, this.getSize().width, this.getSize().height);

      // draw elements in background
      dbg.setColor (getForeground());
      paint (dbg);

      // draw image on the screen
      g.drawImage (dbImage, 0, 0, this);

  }
  
  
}

package myDxBall;

import java.awt.Color;
import java.awt.Graphics;
import java.util.Random;

class Ball{
	 int bx,by;
	 int vx=1;
	 int vy=1;
	 Random dice = new Random();
	 int dc;
	Graphics g;
	Ball(int z,int k){
		bx = z;
		by = k;
	}
public 	void bpaint(Graphics g){
	g.setColor(Color.RED);
	g.fillOval(bx, by, 15, 15);
}
public void move(){
	bx += vx;
}
public void move1(){
	by+= vy;
}
public void move2(){
	vx= -1 ;
}
public void move3(){
	vx= 1;
}
public void move4(){
	vy= -1;
}
public void move5(){
	vy= 1;
}
public void move6(){
	vy= -1;
	dc= dice.nextInt(2);
	if(dc==0){
	vx= 1;
	System.out.println("zero rand");
	}
	else{
		vx= -1;
		System.out.println("one rand");
	}
}
public void move7(){
	vy= 1;
}
public double getX(){
	return bx;
}
public double getY(){
	return by;
}
}

package myDxBall;
import java.awt.*;
public class Bar {
	static int yy= 0 ;
	Bar(int a){
		yy = yy+a;
	}
public void barpaint(Graphics g){
	g.setColor(Color.GREEN);
	g.fillRect(yy, 290, 50, 10);
}
public boolean collidebar(Ball b){
	double colx = Math.abs(b.getX() - yy);
	double coly = Math.abs(b.getY() - 290);
	boolean bol;
	if(colx<25 & coly<25){
		bol=true;
	}
	else{
	bol= false;	
	
	
	}
	return bol;
}
}
package myDxBall;
import java.awt.*;
public class Rectbar {
	int x,y;
	Graphics g;
	static int px[] = new int [15];
	static int py[] = new int [15];
	boolean disp=true;
     Rectbar(int m,int n){
		x=m;
		y=n;
	}
public void paintrect(Graphics g){
	g.fillRect(x, y, 40, 10);
}
public boolean collideRect(Ball b){
	double colx = Math.abs(b.getX() - x);
	double coly = Math.abs(b.getY() - y);
	boolean bol;
	if(colx<25 & coly<25){
		bol=true;
	}
	else{
	bol= false;	
	
	
	}
	return bol;
}
public boolean getdisp(){
	return disp;
}
public void setdisp(boolean bln){
	 disp= bln;
}
}

I want to add a screen that will load before my actual game will start ,that will show some animation and i want to use pictures in the background without overlapping my actual game and most importantly i want to convert this game to J2ME format can anyone please help me.....