Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8311801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:55:47+00:00 2026-06-08T19:55:47+00:00

I watch thenewboston’s tutorials on youtube, so right now I am creating Bucky’s Land.

  • 0

I watch thenewboston’s tutorials on youtube, so right now I am creating “Bucky’s Land.” This code currently lets me move my character left, right, up and down. It changes the sides of the player depending on how he is moving. I am a beginner at java and I want to know how to make my character jump. Any help would be appreciated!

package javagame;

import org.newdawn.slick.*;
import org.newdawn.slick.state.*;

public class Play extends BasicGameState{

Animation bucky, movingUp, movingDown, movingLeft, movingRight;
Image worldMap;
boolean quit = false;
int[] duration = {200,200};
float buckyPositionX = 0;
float buckyPositionY = 0;
float shiftX = buckyPositionX + 320;
float shiftY = buckyPositionY + 160;
boolean jumping = false; 
float verticalSpeed = 0.0f;

public Play(int state){
}

public void init(GameContainer gc, StateBasedGame sbg) throws SlickException{
   worldMap = new Image("res/world.png");
      Image[] walkUp = {new Image("res/buckysBack.png"), new Image("res/buckysBack.png")}; 
      Image[] walkDown = {new Image("res/buckysFront.png"), new Image("res/buckysFront.png")};
      Image[] walkLeft = {new Image("res/buckysLeft.png"), new Image("res/buckysLeft.png")};
      Image[] walkRight = {new Image("res/buckysRight.png"), new Image("res/buckysRight.png")};

      movingUp = new Animation(walkUp, duration, false);
      movingDown = new Animation(walkDown, duration, false);
      movingLeft = new Animation(walkLeft, duration, false);
      movingRight = new Animation(walkRight, duration, false);
      bucky = movingDown; 
  }

public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException{
   worldMap.draw(buckyPositionX, buckyPositionY);
   bucky.draw(shiftX, shiftY);
   g.drawString("Buckys X: "+buckyPositionX+"\nBuckys Y: "+buckyPositionY, 400, 20);

   if(quit==true){
         g.drawString("Resume (R)", 250, 100);
         g.drawString("Main Menu (M)", 250, 150);
         g.drawString("Quit Game (Q)", 250, 200);
         if(quit==false){
            g.clear();
         }
    }
 }

public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException{
   Input input = gc.getInput();
   if(input.isKeyDown(Input.KEY_UP)){
         bucky = movingUp; //change bucky to up image
         buckyPositionY += delta * .1f; //increase the Y coordinates of bucky (move him up)
         if(buckyPositionY>162){
            buckyPositionY -= delta * .1f; //dont let him keep going up if he reaches the top
         }
      }
      if(input.isKeyDown(Input.KEY_DOWN)){
         bucky = movingDown;
         buckyPositionY -= delta * .1f;
         if(buckyPositionY<-600){
            buckyPositionY += delta * .1f;
         }
      }
      if(input.isKeyDown(Input.KEY_LEFT)){
         bucky = movingLeft;
         buckyPositionX += delta * .1f;
         if(buckyPositionX>324){
            buckyPositionX -= delta * .1f;
         }
      }
      if(input.isKeyDown(Input.KEY_RIGHT)){
         bucky = movingRight;
         buckyPositionX -= delta * .1f;
         if(buckyPositionX<-840){
            buckyPositionX += delta * .1f;
         }
      }
        //when they hit escape
      if(quit==true){
         if(input.isKeyDown(Input.KEY_R)){
            quit = false;
         }
         if(input.isKeyDown(Input.KEY_M)){
            sbg.enterState(0);
            try{
               Thread.sleep(250);
            }catch(InterruptedException e){
               e.printStackTrace();
            }
         }
         if(input.isKeyDown(Input.KEY_Q)){
            System.exit(0);

         }
     }
}

public int getID(){
  return 1;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T19:55:48+00:00Added an answer on June 8, 2026 at 7:55 pm

    You need to a bit of physics for that. the idea is that when somebody presses the space bar for example, you set the velocity of the character to for example 5 up. Each second you substract 1 from it and add it to the character’s altitude, until he hits the ground again. You might also want to limit the velocity to (5,-5)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://www.youtube.com/watch?v=gZNdfVwkttM - you can see all of the problem described on this video if
http://www.youtube.com/watch?feature=player_detailpage&v=Boz3yVBz1hM#t=18s In this video, at 22 sec, man is drawing a square on SetupWizard
If you watch this link of my game: http://www.youtube.com/watch?v=HMWl8D_OwyM If you watch this you
Watch following code: $a = 'Test'; echo ++$a; This will output: Tesu Question is,
I watch a lot of tutorials on the web, expesially ASP.NET tutorials - And
Something like this: sass --watch style.css:(other than root directory) //or sass --watch (other directory
I setup some stop watch calls in my code to measure some code blocks
I juste watch this effect : alt text http://grab.by/5UBM I would like to reproduce
I watch all of these Android tutorials online and am getting more and more
Can we watch youtube video in android app? I mean if we have link

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.