How to make "Levels" in simple java game

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);
*/

I'm not exactly sure in your case what you are trying to accomplish. If all you want to do is make new polygons for your levels then you will simply need a Vector of type level (or polygon). Store multiple levels/polygons in that vector. This can be done many ways, probably the most efficient way would be to create a class Level of sorts and create each level object from there. This way you have all your levels stored into that vector.
I have made programs where the levels/mazes are randomly generated based on certain parameters (this way you would not need to define any specific level). This can be done inside the Level class and added to the vector so that when a level is randomly generated there are literally infinite possibilities. I would suggest posting all your code or at least a breakdown UML diagram of what is going on in your entire program.

Similar Messages

  • How to make a wall for a game

    hello developers
    I’m sharing a long time to find out how to make a wall for my game but now where is it.
    Can someone help me?
    its a wall for an iphone/ipod game.
    It must be a wall that a sprite will stop walking it’s not a killer object but a stop object.
    oh and are there differants in programing in ipad/iphone?
    Thanks for help
    Grtz Jimmy

    I don't know what's you point on the wall and the player but you should do something as that:
    -(IBAction)goLeft
         if (player.x > wall.xo && player.x < wall.xI)
                  // you are in the wall go right
              if(player.y > wall.yo && player.y < wall.yI)
                 // you are in the wall go right
                 player.x ++;
              else ; // you are up or down of wall
    -(IBAction)goRight
        if (player.x > wall.xo && player.x < wall.xI)
              if(player.y > wall.yo && player.y < wall.yI)
                 // you are in the wall go left
                 player.x --;
               else ; // you are up or down of wall

  • How to make plsql parser around java method

    can someone tell me how can i move Jdeveloper java method into oracle DB (how to make plsql parser around java method). Is this possible becouse in google i can not find any good example how to make this.

    Hi,
    I think you are talking about Java Stored Procedure (?)
    Look here, http://download.oracle.com/docs/cd/E11882_01/java.112/e10588/toc.htm
    Regards
    Peter

  • How to make destop application using java

    how to make destop application using java
    i mean to say when we double click on the exe file the program should lounch the application
    for windows

    when i double click ii got the msg
    Failed to lad main class manifest attribute from
    x/x/xyz.jar
    what exatly it meansIt means that your Manifest.MF for the JAR file should contain an attribute called Main-Class pointing to a class containing the main() method.
    Something like this should be present in META-INF/Manifest.MF :
    Main-Class: MyApplicationMain

  • How to make a really basic pong game for a beginner

    Hello.  I've read through a couple of threads on here dealing with making a game of pong in LabView, but in them the users had questions with far more complex aspects of the program than I want to deal with.  I am a beginner programmer in LabView with limited experience in Java and Visual Basic programming.  I was tasked with creating a game over winter break, and now that I finally have some time (this weekend that is), I decided that I'd make a really simple game of pong.  However, I have seriously overestimated the difficulty of this for a beginner who has very limited knowledge of Lab View.
    I ask you to please have some patience with me.
    I know what I want to do, and just need help inplementing it.
    Here is the idea for my design to keep it as simple as possible:
    -Create a field (I am not sure what to use for this, but from my reading it appears that some sort of a picture output is needed, but I cannot find that anywhere).
    -Set up some simple function that can output the dimensions of this field to use with collision tracking.
    -Create a ball that can be tracked by the program.
    -From my reading I understand that the simplest way to "bounce" the ball off the sides appears to simply reverse the X velocity of the ball when it strikes the vertical boundaries and the Y velocity when it strikes the horizontal boundaries.
    -Insert some sort of a "paddle" that the user can control with the left and right arrow keys.
    Now, as I have mentioned I am a beginner with approximately one month maximum knowledge of this software, spread over about a year.  I want to take things slow.  So for starters, would anyone be willing to walk me through creating a visual output for this and creating a ball that will bounce off all sides?
    If I can at least get that far for now, then I can move on (with help I hope!) of inserting an interactive interface for the "paddle."
    I have found some LabView code for a simple game like this, but it also includes a score keeping loop as well as an "automatic play" option, and I am attempting to wade through all that code to find the bones of it to help me with this, but due to my inexperience, this might thake a lot of time.
    I thank you for any and all help anyone may be able to provide.

    EchoWolf wrote:
    -Create a field (I am not sure what to use for this, but from my reading it appears that some sort of a picture output is needed, but I cannot find that anywhere).
     Wel, there is the picture indicator in the picture palette. In newer versions it's called "2D picture". The palettes have a search function. Using the palette search function is a basic LabVIEW skill that you should know. If you've seen the example for the other discussion, it uses a 2D boolean array indicator. The boolean array is only recommended for a monochrome very low resolution display.
    EchoWolf wrote: -Set up some simple function that can output the dimensions of this field to use with collision tracking.
    -Create a ball that can be tracked by the program.
    That seems backwards. Properly programmed, the code always knows the dimension and the ball position. The program generates, (not tracks!) the ball movement. Of course you need to do some range checking on the ball position to see when it collides with the walls.
    EchoWolf wrote:
    -From my reading I understand that the simplest way to "bounce" the ball off the sides appears to simply reverse the X velocity of the ball when it strikes the vertical boundaries and the Y velocity when it strikes the horizontal boundaries.
    Of course you could make it more realistic by keeping track of three ball parameters: x, y, spin.
    EchoWolf wrote:
    -Insert some sort of a "paddle" that the user can control with the left and right arrow keys.
    Pong is typically played with the up-down arrow keys.
    EchoWolf wrote:
    Now, as I have mentioned I am a beginner with approximately one month maximum knowledge of this software, spread over about a year.
    LabVIEW knowledge is not measured in time units. What did you do during that month? Did you attend some lectures, study tutorials, wrote some programs?
    EchoWolf wrote:
    So for starters, would anyone be willing to walk me through creating a visual output for this and creating a ball that will bounce off all sides?
    I have found some LabView code for a simple game like this, but it also includes a score keeping loop as well as an "automatic play" option, and I am attempting to wade through all that code to find the bones of it to help me with this, but due to my inexperience, this might thake a lot of time.
    Start with the posted example and delete all the controls and indicators that you don't want, then surgically remove all code with broken wires.
    Alternatively, start from scratch: Create your playing field. Easiest would be a 2D classic boolean array that is all false. Use initialize array to make it once. Now use a loop to show the ball as a function of time.
    Start with a random ball position. to display it, turn one of the array elements true before wiring to the array indicator using replace array subset.
    Keep a shift register with xy positions and xy velocities and update the positions as a function of the velocities with each iteration of the loop. Do range checking and reverse the velocieis when a edge is encountered.
    What LabVIEW version do you have?
    LabVIEW Champion . Do more with less code and in less time .

  • How do I call a simple java class from a bpel process?

    Hi.
    In JDeveloper 10.1.4.3.0 I've created a simple java class that does an ftp get operation followed by an unzip. The class uses some 3rd part libraries (jars).
    I want to use a simple bpel process to schedule a daily execution of this java class, and deploy it all to our SOA-server, - and was looking into using the <bpelx:exec> function.
    The java class and the bpel process is all stored in the same JDeveloper project.
    How do I put this together so that both my java class and the necessary jars are available to the bpel process?
    I've looked into the JavaExecSample.bpel, and it's says something about "...the class com.otn.samples.javaexec.CreditCalculator is locally packaged with this BPEL process".
    How do I do that?
    Can I make it and test it all locally from my workstation (only JDeveloper installed, I guess there's nothing that can execute the bpel code?), or do I have to compile class etc (make war-file?) and deploy to SOA server (BPEL-INF/lib or classes?) before anything can be tested?
    (I guess all this is simple, once you know how, but being a newbie to this I need a shove in the right direction :-)
    Regards,
    -Haakon-

    To create a java class and dependent jars inside the BPEL process project you need to do the following:
    1. Right click on your BPEL process project and select New and then Java Class from the Items.
    2. Make the BPEL process project, JDeveloper would compile the java classes and add them into the BPEL suite case jar, see the output folder and check the BPEL suite case jar file for java classes and dependent jars.
    You can test your Java classes from JDeveloper IDE, no need to deploy the classes on SOA server. When you make the BPEL project it compiles .bpel files and Java classes. You can test your classes once .bpel file and java classes compiled successfully.
    Regards,
    Dharmendra
    http://soa-howto.blogspot.com

  • How to make a table in java without using GUI??

    how can i make a table in java without usinf GUI, just simple codes??
    NAME ID NUMBER ADDRESS STATUS

    If you simply want to store them internally, you don't want to use a table.
    Make a simple class with properties id, name, number, address, status. Then create a Hashtable that indexes instances of the class by id or some other property.

  • How to make a scheduler in Java

    I am interested in make a scheduler in java that can run my own services according to schedule.Can any one help me for this.Thanks in advance.
    Rizwan

    Follow this code Hope this will help u
    import java.util.Timer;
    import java.util.TimerTask;
    * Simple demo that uses java.util.Timer to schedule a task to execute
    * once 5 seconds have passed.
    public class Reminder {
    Timer timer;
    public Reminder(int seconds) {
    timer = new Timer();
    timer.schedule(new RemindTask(), seconds*1000);
    class RemindTask extends TimerTask {
    public void run() {
    System.out.println("Time's up!");
    timer.cancel(); //Terminate the timer thread
    public static void main(String args[]) {
    System.out.println("About to schedule task.");
    new Reminder(5);
    System.out.println("Task scheduled.");
    When you run the example, you first see this:
    Task scheduled.
    Five seconds later, you see this:
    Time's up!
    Chatrapathy

  • How to call JCS in simple java class

    I want to make a atsratup class and this class will have to communicate with a
    java controls.But i am not able to create an instance of java control in simple
    startup class.
    IF any body has called java control in simple java class pls. let me know

    Hi Surinder,
    you can use (some types of) controls with the following code:
    Class controlClass = Class.forName("mypackage.MyControl");
    MyControl control = (MyControl)WlwProxy.create(controlClass, request);
    control.callMethod();
    Unfortunatelly it requires a request (or an URL), so you will need some
    tricks to use it in a startup class.
    This is an internal, undocumneted... call and does not set any
    parameters of the control, so use it with care.
    Let me know if you can solve your problem, pls
    BR,
    don
    surinder wrote:
    I want to make a startup class and this class will have to communicate with a java
    controls.But i am not able to create an instance of java control in simple startup
    class.
    IF any body has called java control in simple java class pls. let me know
    "surinder" <[email protected]> wrote:
    I want to make a atsratup class and this class will have to communicate
    with a
    java controls.But i am not able to create an instance of java control
    in simple
    startup class.
    IF any body has called java control in simple java class pls. let me
    know

  • How to make Connection Pooling in JAVA

    Dear Members
    I want to know that how can i make connection pooling in java and also how can i use that pool in my jsp/servlet application.
    Plz Describe in Detail.
    Thanks
    Vasim

    vasim_saiyad2000 wrote:
    Dear Members
    I want to know that how can i make connection pooling in java and also how can i use that pool in my jsp/servlet application.
    Plz Describe in Detail.
    Thanks
    VasimAs the previous poster is trying to suggest, the server you use will have datasource and connection pooling support. so look up in the manual how to set it up, or do a google search. For example if you use Tomcat, look here:
    http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html

  • Simple java game

    I'm trying to create a simple game where you specify where you would like to start in a 2d array, then use directional buttons to move the character around. However, rather than store the value of 's', it stores it's value in the character set.. here is my code:
    import java.util.*;
    public class Map1
         static Scanner console = new Scanner(System.in);
         public static void main(String[] args)
              char character;
              char[][]map = new char[10][10];
              char x, y;
              int printing;
              boolean end = false;
              System.out.println("Indicate where you would like your ship to start by entering a value"
                             + "\nbetween 0 and 9 for x, followed by a value for y");
                             x = console.next().charAt(0);
                             y = console.next().charAt(0);
              System.out.println("The value you entered for x is: " + x);
              System.out.println("The value you entered for y is: " + y);
              map[x][y] = 's';
              System.out.println(map[x][y]);
              System.out.println("Ok, now your directional keys are:"
                             + "\nA moves you to the left, W moves you up,"
                             + "\nD moves you to the right, and S moves you down"
                             + "\nTo end the game and view your map, press x.");
              System.out.println("So now, choose your direction!");
              character = console.next().charAt(0);
              do
                   switch(character)
                        case 'a':
                        case 'A':
                             map[x--][y] = 's';
                             break;
                        case 'w':
                        case 'W':
                             map[x][y--] = 's';
                             break;
                        case 's':
                        case 'S':
                             map[x++][y] = 's';
                             break;
                        case 'd':
                        case 'D':
                             map[x][y++] = 's';
                             break;
                        case 'x':
                        case 'X':
                             end = true;
                             System.out.println("Thank you for playing, here is your map.");
                             for (printing = 0; printing < map.length; printing++)
                                  System.out.println(map[x][y]);
                             break;
                        default:
                             System.out.println("The value you entered is invalid. Please try again.");
              while (!end);
    }

    To post code, use the code tags -- [code]Your Code[/code]will display asYour CodeOr use the code button above the editing area and paste your code between the tags it generates.
    Declare x and y as int instead of char and use nextInt () instead of next.charAt (0) to read the values inputted. Fragments:        //char x, y;
            int x, y;
            x = console.nextInt ();//.charAt (0);
            y = console.nextInt ();//.charAt (0);That's not all that's wrong, you also need to read the input for directional movement inside rather than before the loop, but try to fix that yourself.
    db

  • How to make a 3X3 Slider puzzle game?

    Hey guys, im new here and decided to make an account on here. Im coming to you guys for help. In my grade 12 infotech class, we were assigned a project dealing with 2d arrays but im having a bit of trouble doing this :S. It needs to do the required:
    1. Acquire an image
    2. Divide image into NINE separate images
    a. You will have a TENTH image that will represent the &ldquo;removed&rdquo; space
    3. Create TWO 2-D Image arrays
    a. One array will store the correct images as reference (use the array index as coordinates for the locations)
    b. One array will store the images mixed up
    4. Create ONE 2-D Boolean array
    a. This array will store the location of where the empty tile is since you actually don&rsquo;t delete the image
    5. Create ONE 2-D Rectangle array
    a. This array will store the information for the tiles (width, height, x-start, y-start) you are moving
    6. Display the tiles in the right order for the correct image
    7. Create a button that will remove a random image-tile
    8. Allow the remaining pieces to be moved around (into the empty space) to mix up the picture
    9. Keep track of number of moves made
    10. Create a button that will indicate it&rsquo;s the &ldquo;Solver&rsquo;s&rdquo; turn
    11. Keep track of number of steps made to solve the puzzle
    12. Check if the pieces have been moved into the right locations
    13. If the puzzle is completed, add back in the removed piece
    14. Play sounds at appropriate times
    this is what ive gotten so far.. sorry if its a strain on the eyes.
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    public class movingThingGame extends Applet implements ActionListener KeyListener {
         boolean[] keyUp;
         char Kp;
         //Store correct image co-ordinates
         Image[][] aImages;
         //Store mixed image co-ordinates
         Image[][] bImages;
         //Store location of blanked out image
         Boolean[][] cTile;
         //Store x,y,width,height
         Rectangle[][] dInfo;
         //Top Row
         Image zz; //0,0
         Image oz; //1,0
         Image tz; //2,0               
         //Middle Row
         Image zo; //0,1
         Image oo; //1,1
         Image to; //2,1
         //Last Row
         Image zt; //0,2
         Image ot; //1,2     
         Image tt; //2,2
         //Blank Square
         Image c;
         public void init() {
              keyUp=new boolean[4];
              for (int x=0;x<4;x++){
                        keyUp[x]=true;
              //Declare 2d array aImages have 3 by 3 perimeter
              aImages=new Image[3][3];
              //Top Row
              aImages[0][0]=getImage(getCodeBase(),"spiralTOPLEFT(0,0).gif");
              aImages[1][0]=getImage(getCodeBase(),"spiralTOPMIDDLE(1,0).gif");
              aImages[2][0]=getImage(getCodeBase(),"spiralTOPRIGHT(2,0).gif");
              //Middle Row
              aImages[0][1]=getImage(getCodeBase(),"spiralMIDDLELEFT(0,1).gif");
              aImages[1][1]=getImage(getCodeBase(),"spiralMIDDLEMIDDLE(1,1).gif");
              aImages[2][1]=getImage(getCodeBase(),"spiralMIDDLERIGHT(2,1).gif");
              //Bottom Row
              aImages[0][2]=getImage(getCodeBase(),"spiralBOTTOMLEFT(0,2).gif");
              aImages[1][2]=getImage(getCodeBase(),"spiralBOTTOMMIDDLE(1,2).gif");
              aImages[2][2]=getImage(getCodeBase(),"spiralBOTTOMRIGHT(2,2).gif");
         public void paint(Graphics g) {
              //TOP
              g.drawImage(aImages[0][0],20,98,128,128,this);
              g.drawImage(aImages[1][0],148,98,128,128,this);
              g.drawImage(aImages[2][0],276,98,128,128,this);
              //MIDDLE
              g.drawImage(aImages[0][1],20,226,128,128,this);
              g.drawImage(aImages[1][1],148,226,128,128,this);
              g.drawImage(aImages[2][1],276,226,128,128,this);
              //BOTTOM
              g.drawImage(aImages[0][2],20,352,128,128,this);
              g.drawImage(aImages[1][2],148,352,128,128,this);
              g.drawImage(aImages[2][2],276,352,128,128,this);
         public void update(Graphics g) {
              paint(g);
         public void actionPerformed(ActionEvent e) {
         public void keyPressed(KeyEvent event) {
              Kp=event.getKeyCode();
              if (Kp==37);{          //left               
                   keyUp[0]=false;
              else if (Kp==39);{  //right
                   keyUp[1]=false;
              else if (Kp==38);{  //up
                   keyUp[2]=false;
              else if (kp==40);{  //down
                   keyUp[3]=false;
              moveImage();
              repaint();
         public void KeyReleased(KeyEvent event) {
              Kp=event.getKeyCode();
              if (Kp==37);{
                   keyUp[0]=true;
              else if (Kp==39);{
                   keyUp[1]=true;
              else if (Kp==38);{
                   keyUp[2]=true;
              else if (Kp==40); {
                   keyUp[3]=true;
         public void moveImage() {
    }

    Hello, and welcome to the forum!
    Suggestions:
    1) Ask an actual question: the more specific your question, usually the more helpful the answer. This site can help you formulate questions here (I know because it's helped me): [smart questions|http://catb.org/~esr/faqs/smart-questions.html]
    2) when posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?
    To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.
    Another way to do this is to manually place the tags into your code by placing the tag [cod&#101;] above your pasted code and the tag [cod&#101;] below your pasted code like so:
    [cod&#101;]
      // your code goes here
      // notice how the top and bottom tags are different
    [/cod&#101;]for example, which is easier to read, your post or this?
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    public class movingThingGame extends Applet implements ActionListener KeyListener {
         boolean[] keyUp;
         char Kp;
         //Store correct image co-ordinates
         Image[][] aImages;
         //Store mixed image co-ordinates
         Image[][] bImages;
         //Store location of blanked out image
         Boolean[][] cTile;
         //Store x,y,width,height
         Rectangle[][] dInfo;
         //Top Row
         Image zz; //0,0
         Image oz; //1,0
         Image tz; //2,0               
         //Middle Row
         Image zo; //0,1
         Image oo; //1,1
         Image to; //2,1
         //Last Row
         Image zt; //0,2
         Image ot; //1,2     
         Image tt; //2,2
         //Blank Square
         Image c;
         public void init() {
              keyUp=new boolean[4];
              for (int x=0;x<4;x++){
                        keyUp[x]=true;
              //Declare 2d array aImages have 3 by 3 perimeter
              aImages=new Image[3][3];
              //Top Row
              aImages[0][0]=getImage(getCodeBase(),"spiralTOPLEFT(0,0).gif");
              aImages[1][0]=getImage(getCodeBase(),"spiralTOPMIDDLE(1,0).gif");
              aImages[2][0]=getImage(getCodeBase(),"spiralTOPRIGHT(2,0).gif");
              //Middle Row
              aImages[0][1]=getImage(getCodeBase(),"spiralMIDDLELEFT(0,1).gif");
              aImages[1][1]=getImage(getCodeBase(),"spiralMIDDLEMIDDLE(1,1).gif");
              aImages[2][1]=getImage(getCodeBase(),"spiralMIDDLERIGHT(2,1).gif");
              //Bottom Row
              aImages[0][2]=getImage(getCodeBase(),"spiralBOTTOMLEFT(0,2).gif");
              aImages[1][2]=getImage(getCodeBase(),"spiralBOTTOMMIDDLE(1,2).gif");
              aImages[2][2]=getImage(getCodeBase(),"spiralBOTTOMRIGHT(2,2).gif");
         public void paint(Graphics g) {
              //TOP
              g.drawImage(aImages[0][0],20,98,128,128,this);
              g.drawImage(aImages[1][0],148,98,128,128,this);
              g.drawImage(aImages[2][0],276,98,128,128,this);
              //MIDDLE
              g.drawImage(aImages[0][1],20,226,128,128,this);
              g.drawImage(aImages[1][1],148,226,128,128,this);
              g.drawImage(aImages[2][1],276,226,128,128,this);
              //BOTTOM
              g.drawImage(aImages[0][2],20,352,128,128,this);
              g.drawImage(aImages[1][2],148,352,128,128,this);
              g.drawImage(aImages[2][2],276,352,128,128,this);
         public void update(Graphics g) {
              paint(g);
         public void actionPerformed(ActionEvent e) {
         public void keyPressed(KeyEvent event) {
              Kp=event.getKeyCode();
              if (Kp==37);{          //left               
                   keyUp[0]=false;
              else if (Kp==39);{  //right
                   keyUp[1]=false;
              else if (Kp==38);{  //up
                   keyUp[2]=false;
              else if (kp==40);{  //down
                   keyUp[3]=false;
              moveImage();
              repaint();
         public void KeyReleased(KeyEvent event) {
              Kp=event.getKeyCode();
              if (Kp==37);{
                   keyUp[0]=true;
              else if (Kp==39);{
                   keyUp[1]=true;
              else if (Kp==38);{
                   keyUp[2]=true;
              else if (Kp==40); {
                   keyUp[3]=true;
         public void moveImage() {
    }Much luck!

  • Programming my first simple java game

    I want to program a Java Applet called: a knight's tour.
    The game goes as follows:
    When you start the applet a chessboard will be shown.
    When you click on a compartment the knight will appear. Then you've got to click on the next compartment. The applet has to check if this is a "knight move" and if the square has'nt been visited yet.
    You win when you have visited all the compartiments.
    Can anywone help me? The chessboard isn't a problem. But for example, when you click on a point, how can I ask the color of that specific location?
    Thanks for the reaction.

    I very much agree with yawmark. I'm also not really sure how far you want to take this in terms of being an actual chess game, since - to my mind at least - your post is not too clear. Since you mentioned that you did not really understand Java very well, I again 2nd what yawmark said. Still, since you were considerate and frank, I had a few minutes and so coded up what I meant in my prior post. As I said, I'm sure there are better approaches, but since I'm not really sure where you're headed with this, I thought I'd post the code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class ChessGame  extends JFrame {
      private boolean isRed;
      private JLabel  jl;
      public ChessGame() {
        super( "ChessGame" );
        Container c = this.getContentPane();
        JPanel jp = new JPanel();
        jp.setLayout( new GridLayout( 8, 8, 0, 0 ) );
        for ( int idx = 1; idx < 65; idx++ ) {
          jp.add( buildJButton() );
          if ( idx % 8 == 0 ) isRed = !isRed;
        c.add( jp );
        jl = new JLabel( "click on a square" );
        c.add( jl, BorderLayout.SOUTH );
        setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        setBounds( 100, 100, 500, 500 );
        setVisible( true );
      public JButton buildJButton() {
        final JButton jb = new JButton( "" );
        jb.setBorderPainted( false );
        if ( isRed ) jb.setBackground( Color.red );
        else         jb.setBackground( Color.black );
        isRed = !isRed;
        jb.addActionListener( new ActionListener() {
          public void actionPerformed( ActionEvent ae ) {
            if ( ( ""+jb.getBackground() ).startsWith( "java.awt.Color[r=0" ) )
              jl.setText( "black" );
            else
              jl.setText( "red" );
        return( jb );
      public static void main( String[] argv ) {
        new ChessGame();
    }HTH

  • HP knows how to make KISS-rule, simple, ink-sparing printers

    I posted a message earlier today about HP's shameless ripoff re ink usage.  In that thread, one poster commented about printer design, print heads, etc., by way of explanation as to why my HP 6100 appears to use color ink, when in fact I am not printing anything in color. 
    It occurred to me that the answer is simple, and understandable:  everying knows, and certainly everyone at HP involved with printer design and sales knows, that on earlier printers--such as the HP 870, which I had for YEARS--the ink cartridge could be easily refilled (only once did I use a refilled cartridge), and they did not use enough color ink.
    I finally had to dump my 870 when it became clogged with ink.  And boy, do I mean CLOGGED.  I set it down on-end on the floor and the ink came dripping out. 
    The case of the 870,. and no doubt other printers, shows clearly that HP does know how to design a KISS-rule printer, one that uses no more ink than necessary, that doesn't have any issues with print heads, etc.
    All corporations in the US must make money, and no one begrudges them their profit motive.  What I object to is when they do it in a way that is such a blatant and unavoidable rip-off.   
    (NOTE:  I would have posted this message in my earlier thread, but it appears that that thread is closed; or at any rate, there was no REPLY button.)

    As I mentioned before you need to select "Print in Grayscale" and "Black ink only" to minimize color use.  There are a few other considerations:
    Always keep the printer plugged directly into an active outlet.  Using an external switch (such as an outlet switch or power strip) will cause ink to be used from all colors at startup.  This is because the printer will lose track of how long it has been since the last print job and will do the maximum servicing at startup
    For your usage (mostly black, rare color printing) I would suggest the Deskjet 1010, or perhaps a used Deskjet 6840 or 6540.  When you get the printer install the black cartridge but keep the color cartridge in its original package until you actually need to print color.  The Deskjet 1010 will print with the black or color cartrdige removed in ink backup mode.
    You are not likely going to be happy with any manufacturer's IIC type printer.  They will all use color ink even when printing in B&W as the carriage that moves across the apper contains both the lack and color printheads.  The printheads will dry out if some ink is not "spit" through the nozzles.  The frequency of this will vary; some printers will measure the relative humidity and adjust the timing but typically every nozzle must be cleared every ten seconds or so while exposed to air.  Your Deskjet 870 had color droplets about 30 pL in size and had 192 nozzles between the three colors.  Modern printers have droplets more like 5 pL and may have ten times as many nozzles to keep clear.  The smaller nozzles may require more frequent servicing.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • How to make Exe file of java program

    how we can make the exe file of java programs. that can run independently of particuler JVM. like in VB we can create exe files.
    - early thanks

    Check this out:
    http://search.java.sun.com/search/java/index.jsp?qp=%2B
    orum%3A31&nh=10&qt=create+exe+file+program&col=javaforu
    s

Maybe you are looking for

  • CGS(cost of goods sold)

    CGS(cost of goods sold) Posted: Nov 7, 2006 7:47 PM        Reply      E-mail this post  Hi every one, I want to assign account for CGS, where i have to do it. and what customizations and configuartions required for CGS both in SD and FI-co. Doucment

  • How to compile a servlet

    I am trying to compile a servlet using the import javax.servlet.*; import javax.servlet.http.*; packages. But the only thing I keep getting is : BasicServlet.java:1: package javax.servlet does not exist import javax.servlet.*; ^ BasicServlet.java:2:

  • Safari skipping to previous page

    Within the last couple of months, I have had problems with Safari suddenly skipping back to the previous page. It is as though I clicked the "back" button. It is happening more and more frequently. It is very frustrating when I am in the middle of co

  • How do u write a LEFT JOIN in Oracle Developer Forms 6i?

    I have 2 tables:PERSDET and EMP_MEDICAL_LTA PERSDET has EMP_ID,EMP_NAME n some other fields. EMP_MEDICAL_LTA has EMP_ID,FIELD1,FIELD2 n some other fields EMP_ID is the common field between these 2 tables. My requirement is to display all the EMP_NAME

  • İOS 7 yükledim ama ios 6.1.4 e geri dönmek istiyorum nasıl yaparım

    arkadaşlar bir kaç gün önce ios 7 yükledim ama hiç hoşuma gitmedi ios 6.1.4 e geri dönmek istiyorum nasıl yaparım bilen varmı ...