Пример #1
0
 static void Main(string[] args)
 {
     Galaxy gal = new Galaxy(20000,15000);
     Game game = new Game(1000, 1000,gal);
     //Cluster shuttle = new Cluster(Resources.IO.LoadMultiBlock(@"\Shuttle.TMX"), new OpenTK.Vector2(0, 0), new OpenTK.Vector2(-0.00f, -0.00f), 0.00f);
     Block[,] grid = new Block[1, 3];
     grid[0, 0] = new Block(Resources.BlockRegistry.BlockTypes.Collector, grid, 0, 0);
     grid[0, 1] = new Block(Resources.BlockRegistry.BlockTypes.SolarPanel, grid, 0, 1);
     grid[0, 2] = new Block(Resources.BlockRegistry.BlockTypes.ThrusterIon, grid, 0, 2);
     float value = 0;
     Cluster Probe = new Cluster(grid, new OpenTK.Vector2(value,value),OpenTK.Vector2.Zero,0,new ushort[] {2,2 },gal);
     Controller player = new Controller(Controller.ControlType.Human);
     ShipLogistics ship = new ShipLogistics(Probe,grid, player);
     game.ObjHandler.AddCluster(Probe);
     game.ObjHandler.AddShipLogistics(ship);
     //game.ObjHandler.AddCluster(new Cluster(Cluster.Shape.Rectangle, Resources.BlockRegistry.BlockTypes.WingMid, new OpenTK.Vector2(0, -1000), new OpenTK.Vector2(0,0),(float)Math.PI/(60*10), 50,250));
     new Task(() =>
     {
         while (1 == 1 )
         {
             System.Threading.Thread.Sleep(2000);
             Console.WriteLine("FramesPerSec = " + game.TICK/2.0);
             game.TICK = 0;
         }
     }).Start();
     game.Run();
     Console.ReadLine();
 }
Пример #2
0
 public Game(int width,int height,Galaxy gal)
     :base(width,height)
 {
     GL.Enable(EnableCap.Texture2D);
     GL.Enable(EnableCap.Blend);
     GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
     GL.BlendEquation(BlendEquationMode.Max);
     View = new View(Vector2.Zero, 0, 1);
     Resources.Master.Initualize();
     Input.Initialize(this);
     Gal = gal;
 }
Пример #3
0
 /// <summary>
 /// hasPlaceHolder
 /// </summary>
 /// <param name="level"></param>
 public void Update(View view,System.Drawing.RectangleF windowFrame,Galaxy gal)
 {
     ShipLogistics[] ships = Ships.ToArray();
     for (int i = 0; i < ships.Length; i++)
     {
         ships[i].Update(view);//placeHolder
     }
     Cluster[] clusters = Clusters.ToArray();
     for (int i = 0; i < clusters.Length; i++)
     {
         clusters[i].Update(view,gal,ref windowFrame);//placeHolder
     }
     //Render();
 }
Пример #4
0
 public Cluster(Block[,] grid,Vector2 positionTopLeft, Vector2 velocity, float rotation,ushort[] sectorBlock,Galaxy gal)
 {
     
     Grid = grid;
     Rotation = rotation;
     this.Velocity = velocity;
     this.positionTopLeft = positionTopLeft;
     short[] centerCoords = new short[2];
     RefreshMass();
     RefreshCenterOfMass();
     RefreshRenderFrame(1,16);
     Radius = (float)Math.Sqrt(Math.Pow(Height, 2) + Math.Pow(Width, 2));
     CurrentSectorBlock = sectorBlock;
     CurrentSector = SectorBlock.GetNearestSectorCoords(ref positionTopLeft);
     gal.SetSectorBlock(this);
 }
Пример #5
0
 public void Update(View view,Galaxy gal,ref RectangleF windowFrame)
 {
     positionTopLeft += Velocity;
     CurrentRotation += Rotation;
     const float circle = 2 * (float)Math.PI;
     if (CurrentRotation >= circle)
     {
         CurrentRotation -= circle;
     }
     else if(CurrentRotation < 0)
     {
         CurrentRotation += circle;
     }
     RefreshTooFarAway(view,ref windowFrame);
     UpdateGalacticLocation(gal);
     if (!TooFarAway)
     {
         RefreshPreciseLocation();
     }
 }
Пример #6
0
        private void UpdateGalacticLocation(Galaxy gal)
        {
                bool OutOfSectorBounds = SectorBlock.OutOfSectorBounds(ref CurrentSector[0], ref CurrentSector[1], ref positionTopLeft);

            if (OutOfSectorBounds)
                gal.RefreshCurrentSector(this, ref positionTopLeft);
                  
        }