 Timestamp:
 20170731 21:54:23 (4 years ago)
 Location:
 2017/30/MikkoH/Sq/Sq/Sq
 Files:

 5 edited
Legend:
 Unmodified
 Added
 Removed

2017/30/MikkoH/Sq/Sq/Sq/Sq.cs
r9288 r9289 5 5 public class Sq : PhysicsGame 6 6 { 7 List<Vector> ps, crc; 8 int dist = 5, pts = 150, mag = 100, minmag = 10, maxmag = 300, magc = 4, minrad = 1, maxrad = 100; 9 double rad = 50, radc = 0.01; 7 //List<Vector> ps, crc; 8 //int initsqmag = 50, initsqdist = 2; //killSwitch = 1; 9 //double rad = 50, radc = 0.01; 10 11 List<Square> sqs = new List<Square>(); 10 12 11 13 public override void Begin() 12 14 { 13 Window.Width = 1200;Window.Height = 800;15 Level.Width = Level.Height = Window.Width = Window.Height = 800; 14 16 Mouse.IsCursorVisible = true; 15 17 Level.Background.Color = Color.Black; 16 18 17 ps = CreateSquare(mag, dist);18 crc = CreateCircle(rad, pts);19 sqs.Add(new Square(100, 5)); 20 //crc = CreateCircle(rad, pts); 19 21 } 20 21 // s = length of side, d = distance between pts22 List<Vector> CreateSquare(int s, int d)23 {24 List<Vector> sq = new List<Vector>();25 for (int i = s; i <= s; i += d) sq.Add(new Vector(s, i));26 for (int i = s; i <= s; i += d) sq.Add(new Vector(i, s));27 for (int i = s; i >= s; i = d) sq.Add(new Vector(s, i));28 for (int i = s; i >= s; i = d) sq.Add(new Vector(i, s));29 return sq;30 }31 22 32 23 // r = radius, n = number of pts … … 52 43 c.BrushColor = Color.Red; 53 44 54 // draws and squeezes the square 55 for (int i = 0; i < ps.Count; i++) 45 // checks if squeeze direction should be reversed 46 // merging this into the above loop will fuck everything up 47 // also tries to create new squares 48 for (int i = 0; i < sqs.Count; i++) 56 49 { 57 c.DrawLine(ps[i % ps.Count], ps[(i + ps.Count / 4) % ps.Count]); 58 ps[i] = Vector.FromLengthAndAngle(ps[i].Magnitude + magc, ps[i].Angle); 50 for (int j = 0; j < sqs[i].Count; j++) 51 if (sqs[i][j].Magnitude < sqs[i].minmag) 52 { 53 Square newsq = new Square(sqs[i].Count  1, sqs[i].dist + 1); 54 //newsq.mag = sqs[i][j].Magnitude; 55 sqs.Add(newsq); 56 sqs.Remove(sqs[i]); 57 //sqs[i].magc = sqs[i].magc; 58 break; 59 } 60 else if (sqs[i][j].Magnitude > sqs[i].maxmag) 61 { 62 sqs[i].magc = sqs[i].magc; 63 break; 64 } 59 65 } 60 66 61 // checks if squeeze direction should be reversed 62 // merging this to the above loop will fuck everything up 63 for (int i = 0; i < ps.Count; i++) 64 if (ps[i].Magnitude < minmag  ps[i].Magnitude > maxmag) { magc = magc; break; } 67 // draws and squeezes the square 68 foreach (Square sq in sqs) 69 for (int i = 0; i < sq.Count; i++) 70 { 71 c.DrawLine(sq[i % sq.Count], sq[(i + sq.Count / 4) % sq.Count]); 72 sq[i] = Vector.FromLengthAndAngle(sq[i].Magnitude + sq.magc, sq[i].Angle); 73 } 65 74 75 76 66 77 c.BrushColor = Color.Blue; 67 78 68 79 // draws and squeezes the circle 69 for (int i = 0; i < crc.Count; i++)70 {71 c.DrawLine(crc[i % crc.Count], crc[(i + 2) % crc.Count]);72 crc[i] = new Vector(Math.Sin(i) * rad, Math.Cos(i) * rad);73 if (rad < minrad  rad > maxrad) radc = radc;74 rad = radc;75 }80 //for (int i = 0; i < crc.Count; i++) 81 //{ 82 // c.DrawLine(crc[i % crc.Count], crc[(i + 2) % crc.Count]); 83 // crc[i] = new Vector(Math.Sin(i) * rad, Math.Cos(i) * rad); 84 // if (rad < minrad  rad > maxrad) radc = radc; 85 // rad = radc; 86 //} 76 87 77 Rotate(ps); Rotate(crc, true);88 foreach (List<Vector> ps in sqs) Rotate(ps);/* Rotate(crc, true);*/ 78 89 79 90 base.Paint(c); 80 91 } 81 92 } 93 94 class Square : List<Vector> 95 { 96 public double dist = 5, mag = 100, minmag = 5, maxmag = 300, magc = 2; 97 98 public Square(double s, double d) 99 { 100 for (double i = s; i <= s; i += d) Add(new Vector(s, i)); 101 for (double i = s; i <= s; i += d) Add(new Vector(i, s)); 102 for (double i = s; i >= s; i = d) Add(new Vector(s, i)); 103 for (double i = s; i >= s; i = d) Add(new Vector(i, s)); 104 mag = s; dist = d; minmag = 5; maxmag = mag * 2; 105 } 106 }
Note: See TracChangeset
for help on using the changeset viewer.