Esempio n. 1
0
 public Paddle(Side side, GameOfPaddles game) {
     _side = side;
     _game = game;
     _world = game.World;
     _ball = _world["ball"];
     _pixels = new PlayerMissile[Size];
     for(var i = 0; i < Size; i++) {
         _pixels[i] = new PlayerMissile(
             "paddle" +
             (_side == Side.Right ? 'R' : 'L') +
             i,
             _side == Side.Right ? 7 : 0,
             i,
             _world);
     }
     _world.Coinc +=
         (s, a) => {
             if (_ball.X == 0 && _side == Side.Left) {
                 _game.BallGoingRight = true;
             }
             if (_ball.X == 7 && _side == Side.Right) {
                 _game.BallGoingRight = false;
             }
         };
 }
Esempio n. 2
0
        public static void Main()
        {
            var LeftJoystick = new AnalogJoystick(Pins.GPIO_PIN_A0, Pins.GPIO_PIN_A1);
            var RightJoystick = new AnalogJoystick(Pins.GPIO_PIN_A2, Pins.GPIO_PIN_A3);

            var matrix = new Max72197221(chipSelect: Pins.GPIO_PIN_D8);

            matrix.Shutdown(Max72197221.ShutdownRegister.NormalOperation);
            matrix.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode);
            matrix.SetDigitScanLimit(7);
            matrix.SetIntensity(8);

            var comp = new Composition(new byte[8], 8, 8);

            var leftBall = new PlayerMissile("leftBall", 0, 0);
            var rightBall = new PlayerMissile("rightBall", 0, 0);

            comp.AddMissile(leftBall);
            comp.AddMissile(rightBall);

            while (true)
            {
                leftBall.X = LeftJoystick.X / 128;
                leftBall.Y = LeftJoystick.Y / 128;
                rightBall.X = RightJoystick.X / 128;
                rightBall.Y = RightJoystick.Y / 128;

                Debug.Print("X=" + LeftJoystick.X.ToString() + " (" + LeftJoystick.XDirection.ToString() + ")" + ", Y=" + LeftJoystick.Y.ToString() + " (" + LeftJoystick.YDirection.ToString() + ")");

                matrix.Display(comp.GetFrame(0, 0));

                Thread.Sleep(80);
            }
        }
        public GameOfPaddles(ConsoleHardwareConfig config) : base(config) {
            Hardware.LeftButton.Input.DisableInterrupt();
            Hardware.RightButton.Input.DisableInterrupt();
            Hardware.LeftButton.Input.OnInterrupt += OnLeftButtonClick;
            Hardware.RightButton.Input.OnInterrupt += OnRightButtonClick;
            Hardware.LeftButton.Input.EnableInterrupt();
            Hardware.RightButton.Input.EnableInterrupt();

            DisplaySplashScreen();

            World = new Composition(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, ScreenSize, ScreenSize);
            Ball = new PlayerMissile("ball", 0, 0, World);
            LeftPaddle = new Paddle(Side.Left, this);
            RightPaddle = new Paddle(Side.Right, this);
            
            ResetBall(true);
        }
Esempio n. 4
0
        public static void Main() {
            using (var matrix = new Max72197221(chipSelect: Pins.GPIO_PIN_D8, speedKHz: 10000)) {

                matrix.Shutdown(Max72197221.ShutdownRegister.NormalOperation);
                matrix.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode);
                matrix.SetDigitScanLimit(7);
                matrix.SetIntensity(8);

                var comp = new Composition(new byte[]  {
                    0x00, 0x00,
                    0x00, 0x00,
                    0x00, 0x00,
                    0x00, 0x00,
                    0x03, 0xC0,
                    0x07, 0xE0,
                    0x0F, 0xF0,
                    0x0F, 0xF0,
                    0x0F, 0xF0,
                    0x0F, 0xF0,
                    0x07, 0xE0,
                    0x03, 0xC0,
                    0x00, 0x00,
                    0x00, 0x00,
                    0x00, 0x00,
                    0x00, 0x00,
                }, 16, 16);

                var player = new PlayerMissile("player", 0, 0);
                var missile = new PlayerMissile("missile", 0, 0);
                comp.AddMissile(player);
                comp.AddMissile(missile);

                while (true) {
                    for (var angle = 0; angle < 360; angle++) {
                        player.X = 8 + Math.Sin(angle * 2)/160;
                        player.Y = 8 + Math.Cos(angle * 2)/160;
                        missile.X = 8 + Math.Sin(angle) / 160;
                        missile.Y = 8 + Math.Cos(angle) / 160;
                        var frame = comp.GetFrame(Math.Sin(angle*20)/250 + 4, Math.Cos(angle*20)/250 + 4);
                        matrix.Display(frame);
                        Thread.Sleep(25);
                    }
                }
            }
        }
Esempio n. 5
0
        public GameOfPaddles(ConsoleHardwareConfig config) : base(config) {
            World = new Composition(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, ScreenSize, ScreenSize);
            Ball = new PlayerMissile {
                Name = "ball",
                Owner = World,
                IsEnemy = true
            };
            LeftPaddle = new Paddle(Side.Left, this);
            RightPaddle = new Paddle(Side.Right, this);

            World.Coinc +=
                (s, a, b) => {
                    Ball.HorizontalSpeed = -Ball.HorizontalSpeed;
                    return false;
                };
            
            ResetBall(true);
        }
 public GameOfMeteors(ConsoleHardwareConfig config)
     : base(config) {
     World = new Composition(new byte[WorldSize * WorldSize / 8], WorldSize, WorldSize);
     World.Coinc += WorldCoinc;
     Ship = new PlayerMissile("ship", WorldSize / 2, WorldSize / 2, World);
     Ship.X = WorldSize / 2;
     Ship.Y = WorldSize / 2;
     Pruneau = new PlayerMissile {
         Name = "Pruneau",
         Owner = World,
         IsVisible = false
     };
     Meteors = new Meteor[NumberOfMeteors];
     for (var i = 0; i < NumberOfMeteors; i++) {
         Meteors[i] = new Meteor(this, i,
             new[] {0, WorldSize - 2, 0, WorldSize - 2} [i],
             new[] {0, 0, WorldSize - 2, WorldSize - 2} [i]);
     }
     DisplayDelay = 0;
 }
Esempio n. 7
0
        public static void Main()
        {
#if NETDUINO || NETDUINO_PLUS
            var LeftJoystick = new AnalogJoystick(Pins.GPIO_PIN_A0, Pins.GPIO_PIN_A1);
            var RightJoystick = new AnalogJoystick(Pins.GPIO_PIN_A2, Pins.GPIO_PIN_A3);
            var matrix = new Max72197221(chipSelect: Pins.GPIO_PIN_D8);
#endif
#if NETDUINO_MINI
            var LeftJoystick = new AnalogJoystick(Pins.GPIO_PIN_5, Pins.GPIO_PIN_6, minYRange: 1023, maxYRange: 0, centerDeadZoneRadius: 30);
            var RightJoystick = new AnalogJoystick(Pins.GPIO_PIN_7, Pins.GPIO_PIN_8, minYRange: 1023, maxYRange: 0, centerDeadZoneRadius: 30);
            var matrix = new Max72197221(chipSelect: Pins.GPIO_PIN_17);
#endif

            matrix.Shutdown(Max72197221.ShutdownRegister.NormalOperation);
            matrix.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode);
            matrix.SetDigitScanLimit(7);
            matrix.SetIntensity(4);

            var comp = new Composition(new byte[8], 8, 8);

            var leftBall = new PlayerMissile("leftBall", 0, 0);
            var rightBall = new PlayerMissile("rightBall", 0, 0);

            comp.AddMissile(leftBall);
            comp.AddMissile(rightBall);

            while (true)
            {
                leftBall.X = LeftJoystick.X / 128;
                leftBall.Y = LeftJoystick.Y / 128;
                rightBall.X = RightJoystick.X / 128;
                rightBall.Y = RightJoystick.Y / 128;

                Debug.Print("LEFT: (X=" + LeftJoystick.X + " (" + LeftJoystick.XDirection + ")" + ", Y=" + LeftJoystick.Y + " (" + LeftJoystick.YDirection + "), RIGHT: (X=" + RightJoystick.X + " (" + RightJoystick.XDirection + ")" + ", Y=" + RightJoystick.Y + " (" + RightJoystick.YDirection + ")");

                matrix.Display(comp.GetFrame(0, 0));

                Thread.Sleep(80);
            }
        }
Esempio n. 8
0
 public GameOfMeteors(ConsoleHardwareConfig config) : base(config) {
     World = new Composition(new byte[WorldSize * WorldSize / 8], WorldSize, WorldSize);
     World.Coinc += WorldCoinc;
     Ship = new PlayerMissile {
         Name = "Ship",
         Owner = World,
         X = WorldSize/2,
         Y = WorldSize/2
     };
     Pruneau = new PlayerMissile {
         Name = "Pruneau",
         Owner = World,
         IsVisible = false
     };
     Meteors = new Meteor[WinningNumberOfMeteors];
     for (var i = 0; i < Meteors.Length; i++) {
         Meteors[i] = new Meteor(this, i);
     }
     NumberOfMeteors = StartingNumberOfMeteors;
     SpawnMeteors();
     DisplayDelay = 0;
 }