public static void Main(String[] args) { RenderWindow window = new RenderWindow(new VideoMode(1000, 700), "title"); RenderTexture tex = new RenderTexture(1000, 700); Sprite texSprite = new Sprite(tex.Texture); Fractal fractal = new Fractal(); fractal.CreateTreeFractal(500, 700, 3, 100, 0); Console.WriteLine(fractal.Nodes.Count); while (window.IsOpen()) { window.Clear(); tex.Clear(new Color(0, 0, 0, 200 )); foreach (Shape s in fractal.Nodes) { window.Draw(s); } tex.Display(); window.Draw(texSprite); window.Display(); Image img = window.Capture(); img.SaveToFile("C:/i.png"); Console.ReadLine(); } }
//MAIN() static void Main(string[] args) { dominosposition = new List<Vector2f>(); GameDomino = new Domino_NormalRules(); GameDomino.start_game(); dominoAi.DominoAI DominoAi = new dominoAi.DominoAI(); DominoAi.set_game(GameDomino); renderalldominos = new MySFML.RenderAllDominos(); path_ImageBlockDomino = "resources/blockdomino.png"; if (!File.Exists(path_ImageBlockDomino)) { Console.WriteLine("ImageBlockDomino not founded"); return; } renderalldominos.set_image(new Image(path_ImageBlockDomino)); String path_ImageBackground = "resources/background.png"; if (!File.Exists(path_ImageBackground)) { Console.WriteLine("background not founded"); return; } Image imagebackground = new Image(path_ImageBackground); Texture texturebackground = new Texture(imagebackground); texturebackground.Repeated = true; Sprite background = new Sprite(texturebackground, new IntRect(0,0,(int)WidthWindow, (int)HeightWindow)); String path_icon = "resources/icon.png"; if (!File.Exists(path_icon)) { Console.WriteLine("path_icon not founded"); return; } Image image_icon = new Image(path_icon); path_Font = "resources/font.ttf"; if (!File.Exists(path_Font)) { Console.WriteLine("Font not founded"); return; } Text score = new Text("Dupa", new Font(path_Font)); path_image_button = "resources/button151x54.png"; if (!File.Exists(path_image_button)) { Console.WriteLine("Image button not founded"); return; } //left BUTTON left = new MySFML.MyButton(); left.load_image(new Image(path_image_button), "left side", new Font(path_Font)); left.set_position(new Vector2f(WidthWindow - 200, 350)); //right BUTTON right = new MySFML.MyButton(); right.load_image(new Image(path_image_button), "right side", new Font(path_Font)); right.set_position(new Vector2f(WidthWindow - 200, 404)); //draw BUTTON draw = new MySFML.MyButton(); draw.load_image(new Image(path_image_button), "draw domino", new Font(path_Font)); draw.set_position(new Vector2f(WidthWindow - 200, 458)); //restart BUTTON restart = new MySFML.MyButton(); restart.load_image(new Image(path_image_button), "restart" , new Font(path_Font)); restart.set_position(new Vector2f(WidthWindow - 200, 512)); score.Color = Color.Black; score.CharacterSize = 20; score.Position += new Vector2f(WidthWindow - 200, 100); ContextSettings contextSettings = new ContextSettings(); contextSettings.DepthBits = 32; RenderWindow window = new RenderWindow(new VideoMode((uint)WidthWindow, (uint)HeightWindow), "Domino Game", Styles.Default, contextSettings); window.SetVerticalSyncEnabled(true); window.SetIcon(32, 32, image_icon.Pixels); window.Closed += new EventHandler(closed_action); window.KeyPressed += new EventHandler<KeyEventArgs>(key_pressed); window.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(mouse_pressed); window.SetFramerateLimit(60); bool openWindow = new bool(); openWindow = true; windowcapture = new Texture(window.Capture()); score.Color = Color.White; while (window.IsOpen() && openWindow) { try { DominoAi.play(); } catch (Exception e) { //break; } if (GameDomino.test_game() == -2) { openWindow = false; }; window.DispatchEvents(); //Points and infromation; score.DisplayedString = String.Format("Time game left: {0} \nScore Player1: {1}\nScore Player2: {2}", GameDomino.get_global_time_end(), GameDomino.get_points_player1(), GameDomino.get_points_player2()); /////////////Draw a dominos player and computer////////// window.Clear(Color.Yellow); window.Draw(background); draw_player1(window); draw_player2(window); draw_onboard(window); window.Draw(left.draw()); window.Draw(right.draw()); window.Draw(draw.draw()); window.Draw(restart.draw()); window.Draw(score); window.Display(); if (openWindow == false) { windowcapture = new Texture(window.Capture()); } } //window.Close(); //window = new RenderWindow(new VideoMode((uint)WidthWindow, (uint)HeightWindow), "Domino Game", Styles.Default, contextSettings); //window.Closed += new EventHandler(closed_action); //window.KeyPressed += new EventHandler<KeyEventArgs>(key_pressed); //window.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(mouse_pressed); System.Diagnostics.Stopwatch start = new System.Diagnostics.Stopwatch(); start.Start(); Text winner = new Text(GameDomino.Type_Winner().ToString(),new Font(path_Font), 30); winner.Color = Color.Red; while (window.IsOpen()) { window.DispatchEvents(); window.Draw(new Sprite(windowcapture)); if (start.ElapsedMilliseconds > 100) { winner.Position += new Vector2f(1, 4); if(winner.Position.Y > HeightWindow) winner.Position = new Vector2f(-1, -4); } window.Draw(winner); window.Display(); } }