protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load<SpriteFont>("font"); ballTex = Content.Load<Texture2D>("fysikBall"); BallInfo bi = new BallInfo(); bi.elasticity = 0.7f; bi.scale = 0.2f; bi.gravity = 9.82f; bi.mass = 1.0f; bi.startVelocityMultiplyer = 1.5f; bi.screenHeight = graphics.PreferredBackBufferHeight; bi.screenWidth = graphics.PreferredBackBufferWidth; spawnBox = new Rectangle(0, 0, bi.screenWidth, 100); for (int i = 0; i < numballs; i++) { balls.Add(new Ball(ballTex, bi, spawnBox, colArr[rand.Next(0, colArr.Length)], i)); System.Threading.Thread.Sleep(10); } // balls.Add(new Ball(ballTex, bi, spawnBox, colArr[rand.Next(0, colArr.Length)], 21)); // balls.Add(new Ball(ballTex, bi, spawnBox, colArr[rand.Next(0, colArr.Length)], 55)); }
public Ball(Texture2D _tex, BallInfo _bi, Rectangle _spawnBox, Color _color, int _ID) { tex = _tex; bi = _bi; color = _color; ID = _ID; rand = new Random(); radian = (tex.Height * bi.scale) / 2; // X changed to static for test purposes int y = ID * 200;// rand.Next(0, _spawnBox.Height - (int)radian); int x = 100; posScale = new Rectangle(x, y, (int)(tex.Width * bi.scale), (int)(tex.Height * bi.scale)); //oldVelocity = new Vector2(0.0f, 0.0f); //newVelocity = new Vector2(0.0f, 0.0f); centerPos = new Vector2(posScale.Center.X, posScale.Center.Y); startPos = centerPos; startVel = new Vector2(0, 0.0f);// new Vector2((float)rand.NextDouble() * _bi.startVelocityMultiplyer, (float)rand.NextDouble() * _bi.startVelocityMultiplyer); oldVelocity = new Vector2(0.0f, 9.82f); newVelocity = oldVelocity; }