Exemplo n.º 1
0
        /*
         * Drawing
         * Each 'player' has their own logic.
         */
        public void paintForPlayer(PaintEventArgs e, TetrisPlayer player, bool drawScore)
        {
            //Draw game
            Graphics g = e.Graphics; //New Graphics Object

            //Get box
            PictureBox drawingBox = player.getBox();

            //Draw moving piece
            player.thisTetromino().drawGhost(g);
            player.thisTetromino().draw(g);

            //Draw all blocks
            foreach (TetrisBlock block in player.tetrisBlocks.ToArray()) // (SignalData error?) https://stackoverflow.com/questions/604831/collection-was-modified-enumeration-operation-may-not-execute
            {
                block.draw(g, false);
            }

            //Draw Score
            if (drawScore)
            {
                tetrisForm.setPanelInfo(player.playerScore, player.state, steps);
            }
        }
Exemplo n.º 2
0
 private void keyBoardHandler(object sender, KeyPressEventArgs e)
 {
     localPlayer.thisTetromino().keyboardEvent(e);
     tetrisClient?.sendKeyPress(e.KeyChar);
     redraw();
 }
Exemplo n.º 3
0
        /*
         * Multiplayer
         */

        public void otherPlayerKeyPress(char key)
        {
            otherPlayer.thisTetromino().keyboardEvent(new KeyPressEventArgs(key));
            redraw();
        }