using System; using System.Timers; using Gtk; using Cairo; namespace frame { /*+++++++++++++++++++++++++++Main++++++++++++++++++++++++++++++++*/ class MainClass { public static void Main (string[] args) { Application.Init (); new Victor(); Application.Run (); } } /*+++++++++++++++++++Use of gtk and cairo++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++Program itself++++++++++++++++++++++++++++++++++*/ public class game{ public blob bob=new blob(); public Lsystem tree = new Lsystem(); public LTree Stree = new LTree(""); public game(){ tree = new Lsystem(); tree.iterate(); Console.WriteLine(tree.Tree); tree.iterate(); Console.WriteLine(tree.Tree); tree.iterate(); Stree = new LTree(tree.Tree); } public void play(Context cr,int w, int h){ cr.Save (); //clear screen cr.Color = new Color (1, 1, 1); cr.Rectangle (3, 3, w-3, h-3); cr.Fill (); //faire bouger le triangle foreach(ball tmp in bob.balls){ tmp.wall(w,h); tmp.vy += 0.618; } //dessiner le triangle foreach(spring tmp in bob.springs){ cr.Color = new Color(0,125,0); cr.MoveTo(tmp.b1.x,tmp.b1.y); cr.LineTo(tmp.b2.x, tmp.b2.y); cr.Stroke(); } // cr.Color = new Color(125,0,0); // cr.CurveTo(bob.balls[0].x,bob.balls[0].y,bob.balls[1].x,bob.balls[1].y,bob.balls[2].x,bob.balls[2].y); // cr.Stroke(); cr.Restore (); //appliquer la force des springs bob.bouge(); //les springs de l'arbre foreach(spring tmp in Stree.springs){ //cr.Color=new Color(0,0,125); //cr.MoveTo(tmp.b1.x,tmp.b1.y); //cr.LineTo(tmp.b2.x,tmp.b2.y); //cr.Stroke(); tmp.tire(); } //les points de l'arbre foreach(ball tmp in Stree.balls){ tmp.bouge(); tmp.vy += 0.00618; } //le rendu graphic de l'arbre foreach(ball[] tmp in Stree.bezlst){ cr.Color=new Color(0,255,0); if (tmp[2]!= null){ cr.CurveTo(tmp[0].x,tmp[0].y,tmp[1].x,tmp[1].y,tmp[2].x,tmp[2].y); cr.Stroke(); } } ((IDisposable)cr.Target).Dispose(); ((IDisposable)cr).Dispose(); } } /*++++++++++++++++++++++object++++++++++++++++++++++++++++++++++*/ /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ }