Advertisement
LogicalTrue

Tetris / mainwindows

Feb 18th, 2020
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. using System.Windows.Threading;
  16.  
  17.  
  18. namespace Tetris
  19. {
  20.     /// <summary>
  21.     /// Lógica de interacción para MainWindow.xaml
  22.     /// </summary>
  23.     public partial class MainWindow : Window
  24.     {
  25.         Cuadrado P1, P2, P3, P4,
  26.                  P5, P6, P7, P8,
  27.                  P9, P10, P11, P12,
  28.                  P13, P14, P15, P16;
  29.  
  30.  
  31.  
  32.         int[,] MatrizTetris;
  33.         DispatcherTimer DP;
  34.         public int X;
  35.  
  36.  
  37.  
  38.         public MainWindow()
  39.         {
  40.             InitializeComponent();
  41.  
  42.             DP = new DispatcherTimer();
  43.             DP.Interval = new TimeSpan(0, 0, 0, 0, 100);
  44.             DP.Tick += new EventHandler(DP_TICK);
  45.             DP.IsEnabled = true;
  46.             MatrizTetris = new int[100, 100];
  47.            
  48.            
  49.  
  50.             //Load Piece 1
  51.            
  52.             P1 = new Cuadrado(Canvas, 50, 50);
  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.  
  57.         }
  58.  
  59.  
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement