0
if(e.getSource() == UpButton) {
        kickBall("up");
    }
    else if(e.getSource() == mvDBtn){
        kickBall("down");
    }
    else if(e.getSource() == MvleftBtn){
        kickBall("right");
    }
    else if(e.getSource() == MvLbutton) {
        kickBall("left");
    }
    if(e.getSource() == runBtn) {
           timer1();
    }
     }
    public void kickBall(String a) {

        if(a == "right") {

            //how to move

        }
        else if(a == "left") {
            //how to move

        }
        else if(a == "up") {
            //how to move

        }
        else if(a == "down") {
          //how to move
        }

I have a 13*16 grid layout and i want move a player(character).is it possible to move it pixel wise or should it moved a grid cell at a time.

Shiva Khattri
  • 13
  • 1
  • 7
  • 1
    There is not enough information in your question. How is your game supposed to look? If you need pixel movements, the image should be drawn in the `paintComponent` method of a component like a `JPanel`. You have only shown a (partial) event handler, and we don't know what is supposed to happen. – RealSkeptic Jul 24 '17 at 12:31
  • It might pay to look into the official tutorial for custom painting, because it should cover what you need: https://docs.oracle.com/javase/tutorial/uiswing/painting/ – sorifiend Jul 24 '17 at 12:57
  • Whatever problems you’re having probably stem from using `==` to compare Strings. See https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java. – VGR Jul 24 '17 at 14:43

0 Answers0