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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:46:40+00:00 2026-05-26T04:46:40+00:00

I am learning to program for the Android. I’ve made a couple of basic

  • 0

I am learning to program for the Android. I’ve made a couple of basic games, but for learning I’d like to make a car driving game. The simplest way I thought of doing this was to keep the car in the middle of the screen and scroll the background to give the illusion of movement.

As an experiment to figure out the engine, I created a 2048×1200 Bitmap which I load from a PNG. This will be the map. I then create a new bitmap of 1024×600 cropped from the map which I display on screen. I do this as getWidth() & getHeight() give these dimensions. I take a different crop each time based on movement to show on screen.

Unfortunately I find this too slow to use. The car would have to move at a snails pace if I wanted it to be smooth. I get about 18fps.

I am using James Daniello’s Simple Game Loop

I also read the following stack overflow article which says to keep the object creation out of the main loop as much as possible, which I am doing as best I can.
How to draw lots of bitmaps on screen in an Android game without slow performance

Also of use was this article by Romain Guy on keeping the Bitmap as the same format as the screen to stop it having to be transformed to be displayed on the screen, which is very costly.
Bitmap quality, banding and dithering

I’d like to figure out the best I can achieve with Canvas and Bitmaps before I move on to OpenGL. Am I at the limitations, or should I do something differently? I find I get 18fps when just scrolling the map 1px at a time for smooth scrolling.

private Bitmap track;
private Bitmap visible;
private Point position;
private int fps = 0;
private long lastFpsTime = 0;
private int fpsCount = 0;
Paint pText;

public void Draw(Canvas c){
    visible = Bitmap.createBitmap(track, position.x + 512, position.y + 300, 512, 300);
    position.x++;
    c.drawBitmap(visible, 0,0, null);
    c.drawText("FPS: " + fps, 10, 10, pText);
}

public void Init(Resources resources) {
    // Load Map from track1.png
    track = Bitmap.createBitmap(2048, 1200, Bitmap.Config.RGB_565);
    Bitmap track1 = BitmapFactory.decodeResource(resources, R.drawable.track1);
    track = track1.copy(Bitmap.Config.RGB_565, true);
    position = new Point(0,0);

    //Setup the Text Paint Object
    pText = new Paint();
    pText.setColor(Color.WHITE);
    pText.setStyle(Style.FILL_AND_STROKE);
}

public void Update() {
    fpsCount++;

    if (System.currentTimeMillis() - lastFpsTime >= 1000){
        lastFpsTime = System.currentTimeMillis();
        fps = fpsCount;
        fpsCount = 0;
    }
}
  • 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-26T04:46:41+00:00Added an answer on May 26, 2026 at 4:46 am

    You are creating a new bitmap on every frame you draw. It’s extremely expensive. You should use the version of drawBitmap() that takes a source and a destination rectangle instead.

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

Sidebar

Related Questions

I would like to use Swing to program a simple learning game. I am
I am learning openGL ES 2.0 to make a game for android. I was
So I am currently learning C++ and decided to make a program that tests
I started learning Java and how to program for Android last night :) So
I'm learning C++ and I made a new program. I deleted some of my
I am currently learning how to program Java in android. I read various artices
I'm learning how to program the video camera in android and wrote a very
I'm learning to develop applications for Android but I need to know the XML
I just started learning how to program for android and cant seem to get
I just started learning Android development. I am writing an Android program to scan

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.