示例#1
0
        public void setup(TetrisForm form, bool ismultiplayer, Random ownRandom, Random otherRandom)
        {
            tetrisForm = form;

            //Set multiplayer
            isMultiplayer = ismultiplayer;

            //Set gamesize
            gameSize = new Size(10, 15); // sideways, downwards

            //Set tetrisForm size
            tetrisForm.setGameSize(gameSize, isMultiplayer);

            //Get local box
            localPlayer = new TetrisPlayer(tetrisForm.getLocalPlayerBox(), gameSize, ownRandom);

            //Set paint event
            tetrisForm.getLocalPlayerBox().Paint += (o, args) => paintForPlayer(args, localPlayer, true);

            //Set keypress event
            tetrisForm.getPreviewPanel().Paint += paintPreview;
            tetrisForm.KeyPress += keyBoardHandler;

            //If multiplayer active create other player and set paint event
            if (isMultiplayer)
            {
                otherPlayer = new TetrisPlayer(tetrisForm.getOtherPlayerBox(), gameSize, otherRandom);
                tetrisForm.getOtherPlayerBox().Paint += (o, args) => paintForPlayer(args, otherPlayer, false);
            }

            //Start timer
            startTimer();
        }
示例#2
0
        /*
         * Invalidates the panels and forces them to execute their paint event
         */

        public void redraw()
        {
            localPlayer.getBox().Invalidate();
            tetrisForm.getPreviewPanel().Invalidate();
            otherPlayer?.getBox().Invalidate();
        }