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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:44:05+00:00 2026-06-10T02:44:05+00:00

I am developing a android game in surfaceView. When i test the game on

  • 0

I am developing a android game in surfaceView. When i test the game on different devices the playerSprite seems to go faster on some devices as compared to the other.
How do i accomodate for different devices when setting player speed programmatically?

if(MainActivity.slowSpeed == true){

             speedX = (float) (canvasWidth/266);

             speedY = (float)(canvasHeight/150);




         }




         if(MainActivity.fastSpeed == true){

             speedX = (float) (canvasWidth/192);

             speedY =(float) (canvasHeight/108);



         }
  • 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-10T02:44:06+00:00Added an answer on June 10, 2026 at 2:44 am

    When the framerate is not steady (like 30 or 60 frames a second), you should compensate every moving element in your game by a factor which you calculate from the actual framerate you achieved.

     achievedFramerate = 34.0f;    //The framerate you dynamically measure
     baseFramerate = 30.0f;        //The framerate at which your game is meant to be played
     framerateAdjustFactor = baseFramerate / achievedFramerate;
    

    You use it somewhere in your game as such:

     playerX += speedX * framerateAdjustFactor;
    

    So everywhere where something is moving, you compensate the movement by this factor. This way on a machine which is capable of 60 frames a second, everything will just move twice as slow per frame, which results in the game moving at exactly the same speed.

    Make sure your framerate calculation is done EVERY frame, and must be done with an adequate precision.

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

Sidebar

Related Questions

I am developing an android game, in which i have some trains moving on
I'm developing an Android game that has to download some assets to the SD
I just added some computationally expensive code to an Android game I am developing.
I am developing a game for android phones. When I test my ggame on
I'm developing a little game (test) for Android, but I don't understand the logic
good day we are developing game for android and have some trouble with resource
I am developing an Android game and I have my SurfaceView rendering the game
I'm developing a small game for Android devices. After each game is over, the
I am developing an Android Game. In this game some trains are moving on
I'm developing an android game on 2.3 and have started testing on more devices

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.