Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2010
    Posts
    10
    Rep Power
    0

    Default Help with jumping

    With the code I'm using right now, jumping is very choppy, and really doesn't look at all like jumping. I'm going for more of a "super mario" type jump, how can I achieve this? Here is my current code for movement and jumping
    Java Code:
    public void keyReleased(KeyEvent k) {
    		  	  int keyCode = k.getKeyCode();
    		  switch (keyCode) {
    			  case KeyEvent.VK_SPACE:
    			  y += 60;
    			  	break;
    
    			}
    		  }
    	    public void keyTyped(KeyEvent k) { }
    	    public void keyPressed(KeyEvent k) {
    		  	  int keyCode = k.getKeyCode();
    
    	        switch (keyCode) {
    
    	        case KeyEvent.VK_A:
    	        x -= 10;
    	        imagename1 = "boxleft.png";
    	        box1.load(imagename1);
    	        	break;
    
    	        case KeyEvent.VK_D:
    	        x += 10;
    	        imagename1 = "boxright.png";
    	        box1.load(imagename1);
    	        	break;
    
    	        case KeyEvent.VK_SPACE:
    	        y -= 60;
    	        if (imagename1 == "boxright.png")
    						  x += 50;
    			else
    			  x -= 50;
    	        	break;
    			}

  2. #2
    Join Date
    Apr 2010
    Posts
    10
    Rep Power
    0

    Default

    Also another problem I just discovered. If you hold in spacebar the character continues to fly up

Similar Threads

  1. How to stop thread from being jumping off the code without executing it.....
    By chiragkini in forum Threads and Synchronization
    Replies: 6
    Last Post: 01-22-2009, 04:38 AM
  2. Eclipse - jumping to method definition
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-07-2007, 03:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •