private void Tick(object sender, TickEventArgs e) { while (times < MAXCOUNT) { circle = new Circle( (short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(20, 100)); surf.Draw(circle, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255)), false, true); circle = new Circle( (short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(20, 100)); surf.Draw(circle, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); while (times < MAXCOUNT) { ellipse = new Ellipse( (short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(20, 100), (short)rand.Next(20, 100)); surf.Draw(ellipse, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); ellipse = new Ellipse( (short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(20, 100), (short)rand.Next(20, 100)); surf.Draw(ellipse, Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255)), false, true); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); while (times < MAXCOUNT) { line = new Line( (short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(0, width), (short)rand.Next(0, height)); surf.Draw(line, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); while (times < MAXCOUNT) { triangle = new Triangle( (short)rand.Next(0, width / 2), (short)rand.Next(0, height / 2), (short)rand.Next(0, width / 2), (short)rand.Next(0, height / 2), (short)rand.Next(0, width / 2), (short)rand.Next(0, height / 2)); surf.Draw(triangle, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255) , rand.Next(255))); triangle = new Triangle( (short)rand.Next(0, width / 2), (short)rand.Next(0, height / 2), (short)rand.Next(0, width / 2), (short)rand.Next(0, height / 2), (short)rand.Next(0, width / 2), (short)rand.Next(0, height / 2)); surf.Draw(triangle, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255)), false, true); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); while (times < MAXCOUNT) { short[] x = { (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width) }; short[] y = { (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height) }; polygon = new Polygon(x, y); surf.Draw(polygon, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); short[] a = { (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width) }; short[] b = { (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height) }; polygon = new Polygon(a, b); surf.Draw(polygon, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255)), false, true); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); try { while (times < MAXCOUNT) { short[] x = { (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width) }; short[] y = { (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height) }; texturedPolygon = new TexturedPolygon(new Surface(file), x, y, 10, 10); surf.Draw(texturedPolygon, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); short[] a = { (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width) }; short[] b = { (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height) }; //short[] a = { // 0, 200, 200, 0 // }; //short[] b = { // 0, 0, 200, 200 // }; texturedPolygon = new TexturedPolygon(new Surface(file), a, b, 10, 20); surf.Draw(texturedPolygon, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255)), false, true); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } } catch (EntryPointNotFoundException ex) { Console.WriteLine("Using old version of SDL_gfx. Please upgrade to >=2.0.16"); Console.WriteLine(ex); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); while (times < MAXCOUNT) { pie = new Pie((short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(20, 100), (short)rand.Next(0, 360), (short)rand.Next(0, 360)); surf.Draw(pie, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); pie = new Pie((short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(20, 100), (short)rand.Next(0, 360), (short)rand.Next(0, 360)); surf.Draw(pie, Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255)), false, true); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); while (Events.Poll()) { // handle events till the queue is empty } while (times < MAXCOUNT) { short[] c = { (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width), (short)rand.Next(0, width) }; short[] d = { (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height), (short)rand.Next(0, height) }; bezier = new Bezier(c, d, 0); surf.Draw(bezier, Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); while (times < MAXCOUNT) { box = new Box( (short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(0, width), (short)rand.Next(0, height)); surf.Draw(box, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255))); box = new Box( (short)rand.Next(0, width), (short)rand.Next(0, height), (short)rand.Next(0, width), (short)rand.Next(0, height)); surf.Draw(box, Color.FromArgb( rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255)), false, true); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); Thread.Sleep(SLEEPTIME); } Thread.Sleep(SLEEPTIME); times = 0; surf.Fill(new Rectangle(new Point(0, 0), surf.Size), Color.Black); int xpixel; int ypixel; int rpixel; int gpixel; int bpixel; while (times < 100) { xpixel = rand.Next(10, width); ypixel = rand.Next(10, height); rpixel = rand.Next(255); gpixel = rand.Next(255); bpixel = rand.Next(255); surf.GetColorValue(Color.FromArgb(rpixel, gpixel, bpixel)); //colorValue = screen.MapColor(Color.FromArgb(254, 0, 0)); //screen.DrawPixel(x, y, Color.Red); //Console.WriteLine("colorValue: " + colorValue.ToString(CultureInfo.CurrentCulture)); surf.Draw(new Point(xpixel, ypixel), Color.FromArgb(rpixel, gpixel, bpixel)); //screen.DrawPixel(x, y, Color.Red); //Console.WriteLine("GetPixel: " + screen.GetPixel(xpixel, ypixel).ToString()); //Console.WriteLine("GetPixel: " + screen.GetColorValue(screen.GetPixel(xpixel, ypixel)).ToString(CultureInfo.CurrentCulture)); times++; screen.Update(); screen.Blit(surf, new Rectangle(new Point(0, 0), screen.Size)); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { base.Initialize(); polygon = gxtGeometry.CreateCirclePolygon(100.0f, 3); //gxtGeometry.CreateCirclePolygon(75.0f, 5); texturedPolygon = new TexturedPolygon(polygon, gxtRoot.Singleton.Graphics, -0.5f); texturedPolygon.ColorOverlay = new Color(255, 0, 0, 100); grassTexture = Content.Load<Texture2D>("Textures\\grass"); texturedPolygon.Texture = grassTexture; texturedPolygon.TextureEnabled = false; texturedPolygon.CalculateUVCoords(); polygon2 = gxtGeometry.CreateCirclePolygon(100.0f, 7); texturedPolygon2 = new TexturedPolygon(polygon2, gxtRoot.Singleton.Graphics); texturedPolygon2.Texture = grassTexture; texturedPolygon2.TextureEnabled = false; texturedPolygon2.CalculateUVCoords(); texturedPolygon2.Position = new Vector2(-50, -50); //texturedPolygon.Scale(1.5f, 1.5f); //referenceCircle = new gxtCircle(Vector2.Zero, 200.0f, Color.Blue, 0.0f); sceneGraph = new gxtSceneGraph(); sceneGraph.Initialize(); if (gxtDebugDrawer.SingletonIsInitialized) { debugDrawId = gxtDebugDrawer.Singleton.GetNewId(); gxtDebugDrawer.Singleton.AddSceneGraph(debugDrawId, sceneGraph); gxtDebugDrawer.Singleton.SetId(debugDrawId); } //manager.Add(referenceCircle); camera = new gxtCamera(Vector2.Zero, 0.0f, 0.0f, gxtDisplayManager.Singleton); }