Example #1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public Ball(MainWindow mainWindow)
        {
            this.mainWindow = mainWindow;
            this.barArray = mainWindow.barArray;
            this.sound = mainWindow.sound;

            this.ballBitmapImage = new BitmapImage();
            this.ballBitmapImage.BeginInit();
            this.ballBitmapImage.UriSource = new Uri("Resources/Image/Ball.bmp", UriKind.Relative);
            this.ballBitmapImage.EndInit();

            this.ballBitmapImageBuffer = new byte[this.ballBitmapImage.PixelWidth * this.ballBitmapImage.PixelHeight * 4];
            this.ballBitmapImage.CopyPixels(this.ballBitmapImageBuffer, this.ballBitmapImage.PixelWidth * 4, 0);

            this.width = this.ballBitmapImage.PixelWidth;
            this.height = this.ballBitmapImage.PixelHeight;

            this.x = this.barArray[0].x + Bar.width / 2 - this.width / 2;
            this.y = this.barArray[0].y - this.height - 5;

            this.random = new Random();

            this.dx = this.random.Next(-4, 4);  // 横方向の移動速度は-4以上4未満
            this.dy = this.random.Next(-5, -3); // 縦方向の移動速度は-5以上-3未満

            if (this.dx == 0)
                this.dx = 3;
        }
Example #2
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public Bar(MainWindow mainWindow, int barType)
        {
            this.mainWindow = mainWindow;
            this.barType = barType;
            this.isActive = false;

            this.ResetPosition();
        }