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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:07:20+00:00 2026-06-11T12:07:20+00:00

How can I make a piece of code that will generate me my bitmaps

  • 0

How can I make a piece of code that will generate me my bitmaps by chance. I want a 50% chance for bitmap1, 50% for bitmap2 and 20% for bitmap3. Can I get some advice on how to do that?

I know how to do it for fifty-fifty:

Random r = new Random();
int randBall = r.nextInt(2);

if (randBall == 0) {
   return Gball;
} else if (randBall == 1) {
   return Bball;
}

But if I want to add one more ball with a 20% chance of spawning, I don’t know how to do that.

  • 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-11T12:07:21+00:00Added an answer on June 11, 2026 at 12:07 pm

    You can use the java Random.nextInt(int) method.
    Call nextInt(100); and use

    int p1 = 30;
    int p2 = 50;
    
    if ( n < p1 )
       return GBall;
    else if ( n >= p1 && n < p1 + p2 )
       return BBall;
    else // n < 100, always holds
       return RBall;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, I'm not looking for some piece of code (that will help,
So I have made a little piece of code that will insert and manipulate
I'm trying to write a piece of code that will do the following: Take
How can make a link within a facebox window that redirects it to another
I can make a log in for easily, so that's not the problem. What
Yesterday I created this piece of code that could calculate z^n, where z is
Can i do the following in actionscript-3? : I want to make an application
While listening through Stanford's Programming Abstractions course, I come across some piece of code
I am working on a piece of code that writes data from 4 different
I have a piece of code that checks to see if a macro is

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.