View difference between Paste ID: NgsYFLnD and xKdg1gka
SHOW: | | - or go back to the newest paste.
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.Windows;
7
using System.Windows.Controls;
8
using System.Windows.Data;
9
using System.Windows.Documents;
10
using System.Windows.Input;
11
using System.Windows.Media;
12
using System.Windows.Media.Imaging;
13
using System.Windows.Navigation;
14
using System.Windows.Shapes;
15-
    class Cuadrado
15+
using System.Windows.Threading;
16
17
18-
        public SolidColorBrush C = new SolidColorBrush();
18+
19-
        public Rectangle _P = new Rectangle();
19+
20-
        public int X,
20+
    /// <summary>
21-
                   Y,
21+
    /// Lógica de interacción para MainWindow.xaml
22-
                   YDIR,
22+
    /// </summary>
23-
                   XDIR = 5;
23+
    public partial class MainWindow : Window
24-
        const int TAM = 10;
24+
25
        Cuadrado P1, P2, P3, P4,
26
                 P5, P6, P7, P8,
27-
        public Cuadrado(Canvas c, int X, int Y)
27+
                 P9, P10, P11, P12,
28
                 P13, P14, P15, P16;
29-
            _P.Width = TAM;
29+
30-
            _P.Height = TAM;
30+
31-
            this.X = X;
31+
32-
            this.Y = Y;
32+
        int[,] MatrizTetris;
33-
            C.Color = Color.FromRgb(255, 0, 0);
33+
        DispatcherTimer DP;
34-
            _P.Fill = C;
34+
        public int X;
35
36-
            Canvas.SetLeft(_P, X);
36+
37-
            Canvas.SetTop(_P, Y );
37+
38
        public MainWindow()
39
        {
40-
            c.Children.Add(_P);
40+
            InitializeComponent();
41
42
            DP = new DispatcherTimer();
43-
      public void Gravity()
43+
            DP.Interval = new TimeSpan(0, 0, 0, 0, 100);
44
            DP.Tick += new EventHandler(DP_TICK);
45-
            Y += YDIR;
45+
            DP.IsEnabled = true;
46-
            Canvas.SetTop(_P, Y);
46+
            MatrizTetris = new int[100, 100];
47-
            YDIR += 1;
47+
           
48
           
49
50-
       public void MoveL()
50+
            //Load Piece 1
51
           
52-
            X -= XDIR;
52+
            P1 = new Cuadrado(Canvas, 50, 50);
53-
            Canvas.SetLeft(_P, X);
53+
            P2 = new Cuadrado(Canvas, 50, 60); //50 60 se invierte las cord
54
            P3 = new Cuadrado(Canvas, 40, 60);
55
            P4 = new Cuadrado(Canvas, 40, 70);
56-
       
56+
57-
       public void MoveR()
57+
58
59-
            X += XDIR;
59+
60-
            Canvas.SetLeft(_P, X);
60+
61
62
63
64
        public void DP_TICK(object sender, EventArgs e)
65
        {
66
            Prp_1.Content = P1.X;
67
            Prp_2.Content = P1.Y;
68
            Prp_3.Content = P2.X;
69
            Prp_4.Content = P2.Y;
70
71
 
72
73
74
        }
75
76
        private void Window_KeyDown(object sender, KeyEventArgs e)
77
        {
78
           if (e.Key == Key.A)
79
            {
80
                P1.MoveL();
81
                P2.MoveL();
82
                P3.MoveL();
83
                P4.MoveL();
84
               
85
         
86
87
            }
88
89
            if (e.Key == Key.D)
90
            {
91
                P1.MoveR();
92
                P2.MoveR();
93
                P3.MoveR();
94
                P4.MoveR();
95
            }
96
97
        }
98
99
    }
100
}