Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to make "Levels" in simple java game

843785Dec 11 2008 — edited Dec 13 2008
I just wanted to know if anybody knew how to make "Levels" in a java game. In my case, it is to change two polygons that are used in the background. I think you have to use an array of some kind, but i dont really know.
Here is my source, the polygons are by the massive ///////// areas.
I cut out the majority of the program, because it was too long.
/**
 

public class collision extends Applet implements MouseListener,MouseMotionListener
{
    private  Image rickImage,mazeImage;
   
   Image Buffer;
   Graphics gBuffer;
   int x, y;
  /////////////////////////////////////////////////////////////
   int[] LeftWallX = {0,204,204,149,149,162,162,243,260,235,259,232,260,230,207,207,0};
   int[] LeftWallY = {500,499,402,402,341,324,227,191,157,141,135,123,116,109,86,1,1};
   //int[] PlayAreaX = {204,204,149,149,162,162,243,260,235,259,232,260,230,207,207,263,263,245,282,262,274,257,273,250,184,184,170,170,208,216,216};
  // int[] PlayAreaY = {499,402,402,341,324,227,191,157,141,135,123,116,109,86,1,1,86,103,115,129,138,147,155,201,230,323,340,384,384,402,499};
   int[] RightWallX = {500,500,263,263,245,282,262,274,257,273,250,184,184,170,170,208,216,216};
   int[] RightWallY = {500,0,1,86,103,115,129,138,147,155,201,230,323,340,384,384,402,499};
//////////////////////////////////////////////////
   boolean mouseInside, collide;
   boolean rolled = false;
   boolean msg = true;
   int sX=204,sY=490,sW=12,sH=9;
   //Declare the rectangles
   Rectangle  movingRect,finshBloc,startBloc,oopsBloc;
   //Declare the polygons
   Polygon leftWall,playerArea,rightWall;
        
        ///Initiate 
        public void init()
        {
        	
        	
        	rickImage = getImage(getDocumentBase(), "rick.jpg");
        	mazeImage = getImage(getDocumentBase(), "maze1.jpg");
        	collide=false;
             Buffer=createImage(getSize().width,getSize().height);
             gBuffer=Buffer.getGraphics();
////////////////////////////////////
             rightWall=new Polygon(RightWallX,RightWallY,18);
             playerArea= new Polygon(PlayAreaX,PlayAreaY,31);
             leftWall= new Polygon(LeftWallX,LeftWallY,17);
//////////////////////////////////
           
             
        }
  

     
        public void paint(Graphics g)
        {
             drawStuff();
             g.drawImage (Buffer,0,0, this);
        }
        
        
       
        

 
}

*/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 10 2009
Added on Dec 11 2008
15 comments
418 views