i want make program simulate planets moving in solar system planet going out of orbit.
here try move planets around sun.
planetday
number of days on planet reported day of earth
the planets not following orbit , think here problem i'm not sure, when modify location of planet convert x , y int , when round numbers
private void moveplanets() { double x; double y; int k = 0; foreach (picturebox pic in picturebox1.controls) { if (pic.name == "sun") { continue; } x = sun.location.x + (rectangle[k].width / 2 * math.cos(planetday[k] + alpha)); y = sun.location.y + (rectangle[k].height / 2 * math.sin(planetday[k] + alpha)); pic.location = new point(convert.toint32(x), convert.toint32(y)); k++; if (k == 8) { k = 0; } } alpha += 0.1; }
here generate rectangle use draw ellipses
private void orbit() { int x1 = 30; foreach (picturebox pic in picturebox1.controls) { if (pic.name == "sun") { continue; } rectangle r = new rectangle ( pic.location.x + pic.size.width / 2, (sun.location.y + sun.size.width / 2) - x1, ((sun.location.x + sun.size.width / 2) - (pic.location.x + pic.size.width / 2)) * 2, x1 * 2 ); rectangle.add(r); x1 += 36; } }
and here draw ellipses
private void picturebox1_paint(object sender, painteventargs e) { pen p = new pen(color.white, 1f); foreach (rectangle rec in rectangle) { e.graphics.drawellipse(p, rec); } }
can me problem ?
Comments
Post a Comment