private void bntNewgame_Click(object sender, EventArgs e) { if (loadNiveau.ShowDialog() == DialogResult.OK) { string filename = loadNiveau.FileName; try { eatbrick = Utils.make_eatbrick(filename); } catch (Exception ex) { MessageBox.Show("Erreur: " + ex.ToString(), "Error new game", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void bntDemo_Click(object sender, EventArgs e) { try { eatbrick = Utils.make_eatbrick_demo(); } catch (Exception mfe) { Conception.t_pad pad = new Conception.t_pad(new FSharpRef <double>(Constantes.SCREEN_WIDTH / 2), new FSharpRef <int>(Constantes.PAD_DEFAULT_SIZE)); Conception.t_ball ball = Utils.make_ball(Constantes.SCREEN_WIDTH / 2, Constantes.SCREEN_HEIGHT / 2); FSharpList <Conception.t_ball> listBall = FSharpList <Conception.t_ball> .Cons(ball, FSharpList <Conception.t_ball> .Empty); eatbrick = new Conception.t_eatbrick(pad, new FSharpRef <FSharpList <Conception.t_ball> >(listBall), new FSharpRef <FSharpList <Conception.t_brick> >(FSharpList <Conception.t_brick> .Empty), new FSharpRef <int>(123)); } }
private void globalTimer_Tick(object sender, EventArgs e) { gamepanel.Invalidate(); if (eatbrick != null && running) { lblScore.Text = "Score: " + padding(eatbrick.score.contents); lblNbBall.Text = "Nb balle(s): " + eatbrick.balls.contents.Length; lblNbBricks.Text = "Nb brique(s): " + eatbrick.bricks.contents.Length; lblTaillePad.Text = "Taille pad: " + eatbrick.pad.width.contents; // Callbacks.animate(eatbrick); int nbBall = eatbrick.balls.contents.Length; foreach (Conception.t_ball ball in eatbrick.balls.contents) { Callbacks.animate_ball(eatbrick, ball); Collision.bounce_bound_screen(ball); Collision.collision_ball_pad(eatbrick, ball); Collision.collision_ball_bricks(ball, eatbrick.bricks.contents, eatbrick); } eatbrick.balls.contents = Callbacks.remove_dead_balls(eatbrick.balls.contents); if (Callbacks.check_gameover(eatbrick)) { running = false; try { MessageBox.Show("Fin de partie avec " + eatbrick.score.contents + " points"); running = true; } finally { eatbrick = null; } } speedBar.Value = Math.Max(Math.Min(600, (int)(Constantes.COEF_SPEED.contents * 10.0)), 0); } }