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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:12:31+00:00 2026-05-31T12:12:31+00:00

I am currently working on a school project and missed a class where the

  • 0

I am currently working on a school project and missed a class where the instructor explained how to do this without a massive amount of code.

Here is the assignment:

Create an XNA application shows 50 animated sprites accelerating downward. When a sprite hits the bottom of the window, make it bounce. Spawn each sprite in a random location such that the sprite is always completely in the window. Limit the Y component of the random location to be between 0 and 300. Lastly, make it so the sprites reset to their original location upon a press of the space bar.

This is a link to an example image, rep isn’t high enough for inserting images

http://hypergrade.com/grader/file_download.php?id=132

I have a single sprite drawn and animated, I just need some guidance on randomly generating locations for the same Texture2D.

  • 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-31T12:12:32+00:00Added an answer on May 31, 2026 at 12:12 pm

    you should use Random class.

     // Make one instance of random, the seed is the milliseconds, other way random always returns the same sequence of random numbers.
     static readonly Random rnd = new Random(DateTime.Nom.Milliseconds);
    
     List<Sprite> Sprites = new List<Sprite>(50); 
     public void Update()
     {
          //Add new sprites with a 90% or probability 
          if (Sprites.Count<50 && rnd.Next(100) > 90)
          {
              Sprite sprite = new Sprite();
    
              // This X calculation makes the sprite not to get out of the screen at both sides
              sprite.Pos.X = (float) ( (0.1f + 0.8f * rnd.NextDouble()) * GraphicsDevice.Viewport.Width);
              sprite.Pos.Y = (float) ( rnd.NextDouble() * 300 );
    
              Sprites.Add(Sprite);
          }
     }
    

    Of course de Sprite class depends on you.. 🙂

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

Sidebar

Related Questions

I am currently working on a school project where the assignment, among other things,
I am currently working on a Qt project for my school. For this project
Currently I'm working on a project for school, and I can't solve this. I
I am currently working on a school project and I'm not sure what is
I'm currently working on a school project in Eclipse (We have just started using
I'm currently working on some school project; we are developing a simple RPG, but
I'm currently working on a school (matrix multiplier) project and I have a problem.
I am currently working on a project for school that is a java memo
I am currently working on a project for school, it is Java based and
I'm currently working on an Equipment Reservation System for my school. Here's basically what

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.