示例#1
0
文件: Form1.cs 项目: jonstad/MOO
 public Form1()
 {
     InitializeComponent();
     MooRandom.Init();
     a = new Bitmap(pictureBox1.Size.Width, pictureBox1.Size.Height);
     Galaxy.Init();
     Galaxy.Update();
     shipViewControl1.UpdateList();
     DrawGalaxy();
 }
示例#2
0
文件: Ship.cs 项目: jonstad/MOO
        public void Update()
        {
            Location dest = Galaxy.stars[Destination.IDHomeStar].Location;

            CurrentLocation.X = (dest.X >= CurrentLocation.X) ? CurrentLocation.X + Speed: CurrentLocation.X - Speed;
            CurrentLocation.Y = (dest.Y >= CurrentLocation.Y) ? CurrentLocation.Y + Speed : CurrentLocation.Y - Speed;

            //  if (CurrentLocation.X==dest.X && CurrentLocation.Y == dest.Y)
            if (Math.Abs(CurrentLocation.X - dest.X) < 2 && Math.Abs(CurrentLocation.Y - dest.Y) < 2)
            {
                Random r               = new Random(Environment.TickCount);
                int    rnd             = MooRandom.GetRnd(0, Galaxy.stars.Count);
                Star   destinationstar = Galaxy.stars[rnd];
                Destination            = destinationstar.Planets[0];
                Destination.IDHomeStar = destinationstar.ID;
            }
        }