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

  • SEARCH
  • Home
  • 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 7811589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:13:12+00:00 2026-06-02T04:13:12+00:00

I am developing a small Game in Java, and I’m rewriting the Player Movement

  • 0

I am developing a small Game in Java, and I’m rewriting the Player Movement system to not be Grid-Based. It is a 2D side-scroller, and what I’m trying to achieve is basic Player Movement, so that when the user presses, and holds, the right Key the Player moves right, and the same for the Left Key. The problem I am having is that the Paint Component in another Class draws the image of the Player on the screen, with positions X and Y stored in a Settings Class. Then a KeyListener Class gets when the user is pressing Right, and adds to the X value (And the same for Left, but minuses 1 every time). This creates a slowly moving Character on the screen, and what I want to do is have him move faster without adding more than 1px each time as it would seem like he was skipping pixels (I’ve already tried).

I was wondering if there was a better way to go about this, as the code I’m using is bare-minimum, and my outcome would be a smoothly moving Player.

KeyListener Snippet:

public void keyPressed(KeyEvent arg0) {
    int key = arg0.getKeyCode();

    if(key == 39) { // Right Key
        Settings.player_pos_x++;
    }else if(key == 37) { // Left Key
        Settings.player_pos_x--;
    }

    main.Game.redo();
}

Drawing User on-screen:

g.drawImage(player_image, Settings.player_pos_x, Settings.player_pos_y, this);

Any help is appreciated, if you need any more information or code please feel free to ask.

  • 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-02T04:13:15+00:00Added an answer on June 2, 2026 at 4:13 am

    Let’s try again 🙂

    Double buffering

    Quote: http://msdn.microsoft.com/en-us/library/b367a457.aspx

    Flicker is a common problem when programming graphics. Graphics operations that require
    multiple complex painting operations can cause the rendered images to appear to flicker
    or have an otherwise unacceptable appearance.

    When double buffering is enabled, all paint operations are first rendered to a memory
    buffer instead of the drawing surface on the screen. After all paint operations are
    completed, the memory buffer is copied directly to the drawing surface associated with
    it. Because only one graphics operation is performed on the screen, the image
    flickering associated with complex painting operations is eliminated.

    Quote: http://docs.oracle.com/javase/tutorial/extra/fullscreen/doublebuf.html

    Suppose you had to draw an entire picture on the screen, pixel by pixel or line by
    line. If you were to draw such a thing directly to the screen (using, say,
    Graphics.drawLine), you would probably notice with much disappointment that it takes
    a bit of time. You will probably even notice visible artifacts of how your picture is
    drawn. Rather than watching things being drawn in this fashion and at this pace, most
    programmers use a technique called double-buffering.

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

Sidebar

Related Questions

I'm developing a small game in Java and I have run into a problem
I'm developing a small game in python. I am using a 2D rectangular grid.
I am developing a small game (in Java) for a coursework and the extension
I am new to android and developing a small game based on AndEngine (www.andengine.org).
I'm developing a small HTML Canvas & JavaScript based game to train myself and
I'm developing a small 2D game engine in Java, after playing around with my
I am developing a small game in Java and I am shipping it as
I am developing a small game with Java and all my files are bundled
I'm currently developing a small OpenGL game for the Android platform and I wonder
I was developing a small function when trying to run an enumerator across a

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.