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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:25:38+00:00 2026-05-25T10:25:38+00:00

I’m trying to make a simple game (such as Arkanoid) on Android. I used

  • 0

I’m trying to make a simple game (such as Arkanoid) on Android.

I used some elements from ping-pong-game pattern which I found on the internet.

So I was trying to change this class (GameObject) by using Bitmap instead of Drawable, but some problems appeared.

I have got some questions:

  1. The Rect object which I’ve got here used like field with it own resolution so how can make something like this using Bitmap?
  2. Is something like .getBounds() exist for Bitmap?
  3. Can I make animated objects (blinking, change colour and e.t.c) somehow with Drawable or Bitmap is better for animation?

Here’s my code:

package project.java.game.objects;

import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;

public abstract class GameObject {

    // Directions
    public final static int DIR_LEFT = -1;
    public final static int DIR_RIGHT = 1;
    public final static int DIR_NONE = 0;
    public final static int DIR_UP = 1;
    public final static int DIR_DOWN = -1;


    /** Higer border of object */
    public int getTop() { return mPoint.y; }

    /** Lower border */
    public int getBottom() { return mPoint.y + mHeight; }

    /** Left border */
    public int getLeft() { return mPoint.x; }

    /** right border */
    public int getRight() { return mPoint.x + mWidth; }

    public int returnCenter(){ return mPoint.x + mWidth/2; }

    /** Central point */
    public Point getCenter() { return new Point(mPoint.x + mWidth / 2, mPoint.y + mHeight / 2); }

    /** Height of object */
    public int getHeight() { return mHeight; }

    /** Width */
    public int getWidth() { return mWidth; }

    /** @return Recatngle, which is limit objects */
    public Rect getRect() { 
        return mImage.getBounds(); 
    }

    /** for intersection */
    public static boolean intersects(GameObject obj1, GameObject obj2)
    {
        return Rect.intersects(obj1.getRect(), obj2.getRect());
    }


    /** for coordinates */
    protected Point mPoint;

    /** Height of image */
    protected int mHeight;

    /** Width */
    protected int mWidth;

    /** image */
    private Drawable mImage;

    /** speed */
    protected int mSpeed;

    /**Life level*/
    protected int mLifeLvl;

    /**
     * Constructor
     * @param image image which will use for object
     */
    public GameObject(Drawable image)
    {
        mImage = image;
        mPoint = new Point(0, 0);
        mWidth = image.getIntrinsicWidth();
        mHeight = image.getIntrinsicHeight();
    }

    /** point change position  */
    protected abstract void updatePoint();

    /** object change position */
    public void update()
    {
        updatePoint();
        mImage.setBounds(mPoint.x, mPoint.y, mPoint.x + mWidth, mPoint.y + mHeight);
    }

    /**to draw object */
    public void draw(Canvas canvas)
    {
        mImage.draw(canvas);
    }
    /** set Left bound */
    public void setLeft(int value) { mPoint.x = value; }

    /** set Right bound  */
    public void setRight(int value) { mPoint.x = value - mWidth; }

    /** set top bound */
    public void setTop(int value) { mPoint.y = value; }

    /** set Lower bound */
    public void setBottom(int value) { mPoint.y = value - mHeight; }

    /** center of object on OX */
    public void setCenterX(int value) { mPoint.x = value - mHeight / 2; }

    /** center of object on OY */
    public void setCenterY(int value) { mPoint.y = value - mWidth / 2; }
}
  • 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-25T10:25:39+00:00Added an answer on May 25, 2026 at 10:25 am

    To get bitmap’s dimension use the getWidth() and getHeight() methods.

    Bitmap b = MediaStore.Images.Media.getBitmap(getContentResolver(), imageUri);
    int width = b.getWidth();
    int height = b.getHeight();  
    

    To create bitmap from a bitmap of desired dimension, use the createScaledBitmap method of the Bitmap class

    Bitmap newBitmap  = Bitmap.createScaledBitmap(b, width, height, false);
    

    You can use the Android Animation class to apply animation on bitmap through layout. Available in the APIDemos application. (ApiDemos->Views->Animation->3D Transition)

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping 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.