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 194981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:38:30+00:00 2026-05-11T16:38:30+00:00

As I have said in my previous questions, I’m still new to Java. I’m

  • 0

As I have said in my previous questions, I’m still new to Java.
I’m developing a tile-based game in Java. The movement is on a grid. I’m at the stage where I’m implementing character movement.

My plan was to use the code which I pasted in this question. However, this didn’t work, and I was told I should use SwingWorker.

Being a problem solver, I’ve been thinking about this over the day, and I had a thought.
I could achieve the same effect by doing things a bit differently.

I mentioned that I had a timer that went off every 20 milliseconds, calling a repaint.

My idea was that I could have a method call before the repaint in the event for the timer, which would move all of the people 1 unit nearer to their destination (next square/tile).
Would that sort of thing work? Later on in the game, there may be 100 or so people. Would 20ms be enough time to loop through all the people and move them one unit closer to their destination? Is 20ms too short a time? Am I just making no sense at all?

Your opinions / answers / thoughts are welcome 🙂

  • 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-05-11T16:38:30+00:00Added an answer on May 11, 2026 at 4:38 pm

    OK, first to answer the 20 millis question. You can get quite a lot of game logic done in 20ms. But I’d say it’s too frequently to be updating the display. You should also bear in mind that the OS generally dishes out CPU in the order of 10-20 ms timeslices– in other words, another process at any moment could easily delay your process by about that amount of time. Have a look, for example, at my article on the behaviour of Thread.sleep()— notice from the graph that as the system is moderately busy, the OS can’t honour the sleep time we asked for. If you need an average sleep between frames of 100ms, then 20ms or so jitter here and there won’t be too bad. But 20ms jitter when you asked for 20ms will probably be more noticeable…

    So I’d probably start at 10 frames per second (100ms pauses) and see how that looks.

    As far as the code is concerned, if your game logic will take more or less the same amount of time each tick, then I’d start with logic-repaint-sleep on each tick. Remember you need to synchronize on the things you’re painting, so in your game logic thread, you ideally need to avoid holding on to locks for too long.

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

Sidebar

Related Questions

Let's say i have a 2d linear grid and a point in said grid.
So, i have 3 section like i said in my previous question, A, B,
I have a ethenet access control device that is said to be able to
today i have talk with other friend ,he said he has logic programming skill
I have two processes: Writes to two tables every second (ish) Reads from said
I have a table in which users store scores and other information about said
In C# you can not have indexed properties. That said, how do I convert
Does jQuery validation plugin have some dependencies? For example, I saw blogposts that said
I have a table linking customers to previous purchases: RecID CustID ProdID 1 20
I have to execute my program with this line: java -DImport=data.txt -Din=input.dat -Dout=output1.dat main.Main

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.