public FrmPrincipal() { InitializeComponent(); _listaDeEstadisticas = new List <Estadisticas>(Tetris.DeserializarListaEstadisticas(Inicio.Ruta)); //if (File.Exists(Ruta)) //{ // _listaDeEstadisticas = DeserializarListaPuntajes(Ruta); //} //ASOCIO EL METODO AL EVENTO FORMCLOSING this.FormClosing += new FormClosingEventHandler(CerrandoAplicacion); }
public FrmTetris() { InitializeComponent(); _tetris = new Tetris(); // _tetris.KeyPress += new KeyPressEventHandler(Tetris_KeyPress); _tetris.PreviewKeyDown += new PreviewKeyDownEventHandler(PresionTeclas); Resize += new EventHandler(FrmTetris_Resize); ClientSize = new Size(_tetris.FILAS * 30, _tetris.COL * 30); this.Controls.Add(_tetris); // MessageBox.Show("FILAS: " + _tetris.FILAS * 20 + "COLS: " + _tetris.COL * 20); _tetris.Empezar(); }
private void FrmHauptfenster_Load(object sender, EventArgs e) { startdaten = new Startdaten(); FrmStart frmStart = new FrmStart(startdaten); if (frmStart.ShowDialog() == DialogResult.Cancel) { Close(); return; } int a = startdaten.Level; tetris = new Tetris(15, 10, startdaten.Level); // tetris.SpielfeldGeändert += SpielfeldGeändert; // tetris.SpielEnde += Spielende; solidbrush = new SolidBrush[farbe.Length]; for (int i = 0; i < farbe.Length; i++) { solidbrush[i] = new SolidBrush(farbe[i]); } }
// private List<int> _puntos; public FrmGraficos(List <Estadisticas> lista) { InitializeComponent(); _listaDeEstadisticas = lista; if (File.Exists(Inicio.Ruta)) { _listaDeEstadisticas = Tetris.DeserializarListaEstadisticas(Inicio.Ruta); } // this._puntos = new List<int>(); //for (int i = 0; i < _listaDeEstadisticas.Count ; i++) //{ // this._puntos.Add(_listaDeEstadisticas[i].Puntos); //} double[] x = new double[_listaDeEstadisticas.Count]; double[] y = new double[_listaDeEstadisticas.Count]; for (int i = 0; i < _listaDeEstadisticas.Count; i++) { x[i] = i; y[i] = _listaDeEstadisticas[i].Puntos; } zedGraphControl1.GraphPane.CurveList.Clear(); zedGraphControl1.GraphPane.Title.Text = "Puntos en funcion del tiempo"; zedGraphControl1.GraphPane.XAxis.Title.Text = "Tiempo"; zedGraphControl1.GraphPane.YAxis.Title.Text = "Puntos"; GraphPane myPane = zedGraphControl1.GraphPane; PointPairList spl1 = new PointPairList(x, y); LineItem myCurve1 = myPane.AddCurve("Puntos", spl1, Color.Blue, SymbolType.None); myCurve1.Line.Width = 2.0F; //GROSOR DE LA LINEA zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); zedGraphControl1.Refresh(); }
// public string Ruta = Application.StartupPath + "\\Tetris.xml"; public Tetris() { if (File.Exists(Inicio.Ruta)) { _listaDeEstadisticas = Tetris.DeserializarListaEstadisticas(Inicio.Ruta); } else { _listaDeEstadisticas = new List <Estadisticas>(); } // _estaFuncionando = true; _x1 = _x2 = _x3 = _x4 = 0; _puntos = 0; _lineasCompletas = 0; //for (int i = 0; i < _intervalosTiempo.Length; i++) //{ // _intervalosTiempo[i] -= (int)(_intervalosTiempo[0] * 0.5); //} _intervaloTiempo = _intervalosTiempo [0]; //INICIAMOS EL INTERVALO PARA LA CAIDA DE LA PIEZA A UN SEGUNDO _tablero = new int[FILAS, COL]; _r = new Random(); _posicion = new Posicion(); _posicion.X = 4; _posicion.Y = 0; _temporizador = new Timer(); _color = new Color[] { Color.Red, Color.Green, Color.Blue, Color.DarkSalmon, Color.Violet, Color.DarkOrange, Color.DeepPink }; _claros = new Color[] { Color.Pink, Color.LightGreen, Color.Cyan, Color.Yellow, Color.Magenta, Color.Orange, Color.Fuchsia }; _figuras = new List <int[, ]>(); //AGREGO TODAS LAS FIGURAS A LA LISTA _figuras.Add(new int[, ] { { 1, 0, 0 }, { 1, 0, 0 }, { 1, 1, 0 } }); _figuras.Add(new int[, ] { { 0, 1, 0 }, { 0, 1, 0 }, { 1, 1, 0 } }); _figuras.Add(new int[, ] { { 0, 0, 0 }, { 0, 1, 0 }, { 1, 1, 1 } }); _figuras.Add(new int[, ] { { 0, 0, 0 }, { 0, 1, 1 }, { 1, 1, 0 } }); _figuras.Add(new int[, ] { { 0, 0, 0 }, { 1, 1, 0 }, { 0, 1, 1 } }); _figuras.Add(new int[, ] { { 1, 1 }, { 1, 1 }, }); _figuras.Add(new int[, ] { { 1, 0, 0, 0 }, { 1, 0, 0, 0 }, { 1, 0, 0, 0 }, { 1, 0, 0, 0 } }); //INDICO EL METODO ASOCIADO AL EVENTO TICK DEL TEMPORIZADOR _temporizador.Tick += new EventHandler(Temporizador_Tick); _temporizador.Interval = _intervaloTiempo; //PARA QUE NO SE NOTEN LOS BARRIDOS CUANDO SE LIMPIA LA PANTALLA SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); }