Esempio n. 1
0
        // generates/resets game objects
        public static void NewGame()
        {
            // sets all ball pictureboxes to appropriate appearance for game
            const int BALL_DIAMETER = (int)(2 * Ball.RADIUS * (PLAYAREA_W_PIX / TABLE_WIDTH));
            Color     tableColor    = Color.FromArgb(145, 196, 125);

            foreach (PictureBox b in ballImages)
            {
                b.Size      = new Size(BALL_DIAMETER, BALL_DIAMETER);
                b.BackColor = tableColor;
            }

            // 16 balls, 6 walls, 6 pockets in Colliders
            Colliders   = new List <ICollider>();
            ActiveBalls = new List <Ball>();

            // add balls to colliders (and list of balls)
            cueBall = new CueBall(ballImages[0]);
            Colliders.Add(cueBall);
            ActiveBalls.Add(cueBall);
            for (int i = 1; i <= 15; i++)
            {
                NumberBall nb = new NumberBall(i, ballImages[i]);
                Colliders.Add(nb);
                ActiveBalls.Add(nb);
            }

            // add walls to colliders
            Colliders.Add(new Wall(Side.Top));
            Colliders.Add(new Wall(Side.Top | Side.Left));
            Colliders.Add(new Wall(Side.Top | Side.Right));
            Colliders.Add(new Wall(Side.Bottom | Side.Left));
            Colliders.Add(new Wall(Side.Bottom | Side.Right));
            Colliders.Add(new Wall(Side.Bottom));

            // add pockets to colliders
            Colliders.Add(new Pocket(Side.Top | Side.Left));
            Colliders.Add(new Pocket(Side.Top | Side.Right));
            Colliders.Add(new Pocket(Side.Left));
            Colliders.Add(new Pocket(Side.Right));
            Colliders.Add(new Pocket(Side.Bottom | Side.Left));
            Colliders.Add(new Pocket(Side.Bottom | Side.Right));

            Cue = new PoolCue(cueBall);
        }
Esempio n. 2
0
 public PoolCue(CueBall cb)
 {
     cueBall = cb;
 }