//constructor, sets all variables for a planet public Planet(Random random, int minradius, int maxradius, int ylayer, bool isEarth=false) { //color color = Color.FromArgb((byte)0xff,(byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255)); //radius radius = random.Next(minradius, maxradius); //position position = new Vector(random.Next(-(int)Window.Current.Bounds.Width + (int)maxradius * 2, (int)Window.Current.Bounds.Width) - (int)maxradius * 2, -(int)Window.Current.Bounds.Height + maxradius * (ylayer + 1)); //position = new Vector(random.Next(-(int)Window.Current.Bounds.Width, (int)Window.Current.Bounds.Width), random.Next(-(int)Window.Current.Bounds.Height + maxradius * 2, (int)Window.Current.Bounds.Height - maxradius * 2)); //mass mass = radius * 5000000; //earth? this.isEarth = isEarth; if (isEarth) { image = new Image(); BitmapImage myBitmapImage = new BitmapImage(); myBitmapImage.UriSource = new Uri("ms-appx:///Assets/earth2.png"); myBitmapImage.DecodePixelWidth = (int)radius; image.Source = myBitmapImage; image.Margin = new Thickness(position.x, position.y, 0, 0); image.IsHitTestVisible = true; //Canvas.SetLeft(image, position.x); //Canvas.SetTop(image, position.y); image.Stretch = Stretch.Fill; image.Height = (int)radius; image.Width = (int)radius; } else { image = new Image(); BitmapImage myBitmapImage = new BitmapImage(); string name = images[random.Next(0, images.Count())]; myBitmapImage.UriSource = new Uri("ms-appx:///Assets/" + name); myBitmapImage.DecodePixelWidth = (int)radius; image.Source = myBitmapImage; image.Margin = new Thickness(position.x, position.y, 0, 0); // Canvas.SetLeft(image, position.x); // Canvas.SetTop(image, position.y); image.Stretch = Stretch.Fill; image.Height = (int)radius; image.Width = (int)radius; } /*ellipse = new Ellipse(); ellipse.Width = 2 * radius; ellipse.Height = 2 * radius; ellipse.Margin = new Thickness(position.x, position.y, 0, 0); ellipse.StrokeThickness = 7.0; ellipse.Stroke = new SolidColorBrush(color);*/ // position.plus(new Vector(radius, radius)); }
public Vector plus(Vector v) { return new Vector(x + v.x, y + v.y); }
public void setPosition(Vector p) { position = p; }
public Vector minus(Vector v) { return new Vector(x - v.x, y - v.y); }