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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:35:04+00:00 2026-06-15T18:35:04+00:00

Im doing a dxball like game for a school project. I am trying to

  • 0

Im doing a dxball like game for a school project. I am trying to create spawn points for the objects(blocks) that will move across the screen. But my problem is when i lets say create 2 objects of type Block. They will get the same random spawnlocation and they will keep having the same respawn location at all time. So i guess i am doing to random function wrong

public class blocks
{
    public Texture2D texturBlock1;
    public Vector2 hastighet = new Vector2(500.0f, 000.0f);
    public Vector2 position;
    private Random random = new Random();
    private int Screen = new int();




   public blocks(int MaxWith)
   {
       this.position.X = MaxWith+10;
       this.position.Y = random.Next(300);
       Screen = MaxWith;
   }

I would love if someone could help me out. I am a real novice when it comes to XNA and c#

  • 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-15T18:35:06+00:00Added an answer on June 15, 2026 at 6:35 pm

    The Random class in .NET usually uses System.DateTime as it’s seed, so when you’re creating multiple randoms at the same time you tend to get the same seed and generate the same random #.

    Try out this static method which uses a GUID as the seed

    public static int RandNumber(int low, int high)
    {
            Random rndNum = new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8), System.Globalization.NumberStyles.HexNumber));
            int rnd = rndNum.Next(low, high);
            return rnd;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Doing the below will reproduce my problem: New WPF Project Add ListView Name the
Doing a small project I have received some Java code that I should rewrite
Doing an application that will use Access as a back end and will rely
Doing a custom Tumblr theme that will have a mix of the usual Tumblr
Im doing something like this to get a list of all users that have
Doing my first tryouts with foreign keys in a mySQL database and are trying
Doing code analysis of the project and get the message Reference-counted object is used
Doing a simple Squeryl database lookup, but trying to exclude a value. I've tried:
Doing some refactoring in some legacy code I've found in a project. This is
Doing some code reading and stumbled upon this snippet that I haven't seen before:

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.