Exemplo n.º 1
0
        protected IBall AddBall(BallGraphicsData graphicsData, BallPhysicsData physicsData, Coordinates startPosition)
        {
            Ball b = new Ball(graphicsData, physicsData, m_Table, startPosition);

            m_Balls.Add(b);
            ComputeSteps();
            return(b);
        }
Exemplo n.º 2
0
 public Ball(BallGraphicsData graphicsData, BallPhysicsData physicsData, ITableInternal table, Coordinates startPosition)
 {
     m_GraphicsData  = graphicsData;
     m_PhysicsData   = physicsData;
     m_Table         = table;
     m_BallInterface = this;
     m_InGame        = true;
     m_Position      = startPosition;
     m_Velocity      = Coordinates.Zero;
     m_DrawingOffset = new Coordinates(m_Table.Width / 2, m_Table.Height / 2);
     Coordinates.MakeReadonly(m_DrawingOffset);
     m_BallDrawingOffset = new Coordinates(m_PhysicsData.Radius, m_PhysicsData.Radius);
     Coordinates.MakeReadonly(m_BallDrawingOffset);
     m_StripedRadius        = (int)Math.Ceiling(m_PhysicsData.Radius * m_GraphicsData.StripedRadiusCoefficient);
     m_StripedDiameter      = 2 * m_StripedRadius;
     m_StripedDrawingOffset = new Coordinates(m_StripedRadius, m_StripedRadius);
     Coordinates.MakeReadonly(m_StripedDrawingOffset);
     m_DirectionUpdated = false;
 }
Exemplo n.º 3
0
 static TriangleBallSet()
 {
     c_PhysicsData  = new BallPhysicsData(13, 0.5, 0.98, 0.016);
     c_GraphicsData = new List <BallGraphicsData>()
     {
         new BallGraphicsData("1", Color.FromArgb(0xFF, 0xFF, 0xC9, 0x0E), false, 0.5),
         new BallGraphicsData("2", Color.FromArgb(0xFF, 0x00, 0x40, 0x80), false, 0.5),
         new BallGraphicsData("3", Color.FromArgb(0xFF, 0xED, 0x1C, 0x24), false, 0.5),
         new BallGraphicsData("4", Color.FromArgb(0xFF, 0x80, 0x00, 0xFF), false, 0.5),
         new BallGraphicsData("5", Color.FromArgb(0xFF, 0xFF, 0x7F, 0x27), false, 0.5),
         new BallGraphicsData("6", Color.FromArgb(0xFF, 0x00, 0x80, 0x40), false, 0.5),
         new BallGraphicsData("7", Color.FromArgb(0xFF, 0x88, 0x00, 0x15), false, 0.5),
         new BallGraphicsData("9", Color.FromArgb(0xFF, 0xFF, 0xC9, 0x0E), true, 0.5),
         new BallGraphicsData("10", Color.FromArgb(0xFF, 0x00, 0x40, 0x80), true, 0.5),
         new BallGraphicsData("11", Color.FromArgb(0xFF, 0xED, 0x1C, 0x24), true, 0.5),
         new BallGraphicsData("8", Color.FromArgb(0xFF, 0x00, 0x00, 0x00), true, 0.5),
         new BallGraphicsData("12", Color.FromArgb(0xFF, 0x80, 0x00, 0xFF), true, 0.5),
         new BallGraphicsData("13", Color.FromArgb(0xFF, 0xFF, 0x7F, 0x27), true, 0.5),
         new BallGraphicsData("14", Color.FromArgb(0xFF, 0x00, 0x80, 0x40), true, 0.5),
         new BallGraphicsData("15", Color.FromArgb(0xFF, 0x88, 0x00, 0x15), true, 0.5),
     };
     c_BallPositionOffsets = new List <Coordinates>()
     {
         new Coordinates(0 * Math.Cos(Math.PI / 6) * c_PhysicsData.Radius * 2, 0 * Math.Sin(Math.PI / 6) * c_PhysicsData.Radius * 2),
         new Coordinates(1 * Math.Cos(Math.PI / 6) * c_PhysicsData.Radius * 2, -1 * Math.Sin(Math.PI / 6) * c_PhysicsData.Radius * 2),
         new Coordinates(1 * Math.Cos(Math.PI / 6) * c_PhysicsData.Radius * 2, 1 * Math.Sin(Math.PI / 6) * c_PhysicsData.Radius * 2),
         new Coordinates(2 * Math.Cos(Math.PI / 6) * c_PhysicsData.Radius * 2, -2 * Math.Sin(Math.PI / 6) * c_PhysicsData.Radius * 2),
         new Coordinates(2 * Math.Cos(Math.PI / 6) * c_PhysicsData.Radius * 2, 0 * Math.Sin(Math.PI / 6) * c_PhysicsData.Radius * 2),
         new Coordinates(2 * Math.Cos(Math.PI / 6) * c_PhysicsData.Radius * 2, 2 * Math.Sin(Math.PI / 6) * c_PhysicsData.Radius * 2),
         new Coordinates(3 * Math.Cos(Math.PI / 6) * c_PhysicsData.Radius * 2, -3 * Math.Sin(Math.PI / 6) * c_PhysicsData.Radius * 2),
         new Coordinates(3 * Math.Cos(Math.PI / 6) * c_PhysicsData.Radius * 2, -1 * Math.Sin(Math.PI / 6) * c_PhysicsData.Radius * 2),
         new Coordinates(3 * Math.Cos(Math.PI / 6) * c_PhysicsData.Radius * 2, 1 * Math.Sin(Math.PI / 6) * c_PhysicsData.Radius * 2),
         new Coordinates(3 * Math.Cos(Math.PI / 6) * c_PhysicsData.Radius * 2, 3 * Math.Sin(Math.PI / 6) * c_PhysicsData.Radius * 2),
         new Coordinates(4 * Math.Cos(Math.PI / 6) * c_PhysicsData.Radius * 2, 4 * Math.Sin(Math.PI / 6) * c_PhysicsData.Radius * 2),
         new Coordinates(4 * Math.Cos(Math.PI / 6) * c_PhysicsData.Radius * 2, -2 * Math.Sin(Math.PI / 6) * c_PhysicsData.Radius * 2),
         new Coordinates(4 * Math.Cos(Math.PI / 6) * c_PhysicsData.Radius * 2, 0 * Math.Sin(Math.PI / 6) * c_PhysicsData.Radius * 2),
         new Coordinates(4 * Math.Cos(Math.PI / 6) * c_PhysicsData.Radius * 2, 2 * Math.Sin(Math.PI / 6) * c_PhysicsData.Radius * 2),
         new Coordinates(4 * Math.Cos(Math.PI / 6) * c_PhysicsData.Radius * 2, -4 * Math.Sin(Math.PI / 6) * c_PhysicsData.Radius * 2),
     };
 }