Exemplo n.º 1
0
        //returns a vector2 with the balls logical cord
        public Vector2 GetBallVisualCord(Texture2D ballTexture, Ball ball)
        {
            Vector2 a = new Vector2(0.073f, 0.03f);
            Vector2 scale = GetBallScale(ballTexture, ball);
            float ballW = ballTexture.Bounds.Width * scale.X;
            float ballH = ballTexture.Bounds.Height * scale.Y;
            float x = ball.BallLogicCords.X * (float)(device.Viewport.Width - (float)Dissort * 2);//
            float y = ball.BallLogicCords.Y * (float)(device.Viewport.Height - (float)Dissort * 2);
            x -= ballW / 2;
            y -= ballH / 2;

            return new Vector2(x, y);
        }
Exemplo n.º 2
0
 //returns a vector2 of the ball scale(depends on resolution)
 public Vector2 GetBallScale(Texture2D ballTexture, Ball ball)
 {
     float x = ((device.Viewport.Width - (float)Dissort * 2) * ball.BallLogicDiameter) / ballTexture.Bounds.Width;
     float y = ((device.Viewport.Height - (float)Dissort * 2) * ball.BallLogicDiameter) / ballTexture.Bounds.Height;
     return new Vector2(x, y);
 }
 //initiates a new instance of the Ball class and calls the UpdateGameResolution to set base values.
 public BallSimulation(GraphicsDevice device)
 {
     ball = new Ball();
     UpdateGameResolution(device);
 }