Esempio n. 1
0
        public void Update(PickupManager pickups, PlanetColecction planets)
        {
            ship.Update(pickups);

            pDock = null;
            foreach (var planet in planets.Planets)
            {
                if (Tool.distance2(ship.Locaion, planet.Position) < planet.Size)
                {
                    pDock = planet;
                }
            }
        }
Esempio n. 2
0
        public void update(PickupManager pickUps, Ship player, PlanetColecction planets)
        {
            for (int i = 0; i < roids.Count; i++)
            {
                roids[i].Update();

                // calculate force of gravity
                roids[i].setAcceleration(new Vector2(0, 0));
                float disPlanet = float.MaxValue; // distance to closest planet;
                foreach (var planet in planets.Planets)
                {
                    float disP = Tool.distance(roids[i].Locaion, planet.Position);
                    if (disPlanet > disP)
                    {
                        disPlanet = disP;
                    }
                    if (Tool.magnitude(roids[i].Acceleration) < 10f)
                    {
                        Vector2 planetAcel = Tool.getPlanetGravity(planet, roids[i].Locaion, roids[i].Mass);
                        roids[i].addAcceleration(planetAcel);
                    }
                }

                float distancePlayer = Tool.distance(roids[i].Locaion, player.Locaion);

                // test damage
                if (distancePlayer < 1000f)
                {
                    for (int j = 0; j < player.Shot.Count; j++)
                    {
                        float distanceShot = Tool.distance(roids[i].Locaion, player.Shot[j].Location);

                        if (distanceShot < roids[i].Size * roids[i].CellSize * 1.5f)
                        {
                            if (roids[i].testHit(player.Shot[j].Location, player.Shot[j].Damage, pickUps))
                            {
                                player.removeShot(j);
                                j--;
                            }
                        }
                    }
                }

                if (!roids[i].Live || disPlanet > 80000f)
                {
                    roids.RemoveAt(i);
                    i--;
                    continue;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            screenHeight = 800;
            screenWidth  = 1600;
            graphics.PreferredBackBufferHeight = screenHeight;
            graphics.PreferredBackBufferWidth  = screenWidth;
            graphics.ApplyChanges();
            this.IsMouseVisible = true;

            station = new Station(new Vector2(0, 0));
            planets = new PlanetColecction();

            player = new Player(planets.Planets[0], screenWidth, screenHeight, 200);
            player.startBuild(screenWidth * .5f, screenHeight * .5f);

            pickups = new PickupManager();
            camera  = new Camera(screenWidth * 0.5f, screenHeight * .5f, 0.75f, screenWidth, screenHeight);

            astroroids = new AstroroidManager();
            stars      = new StarManager(camera);
            screen     = Screen.build;
            base.Initialize();
        }
Esempio n. 4
0
 public void DrawHud(int x, int y, SpriteBatch spriteBatch, Texture2D fill, Texture2D sphere, SpriteFont font, AstroroidManager astroroids, PlanetColecction planets)
 {
     DrawRadar(spriteBatch, fill, sphere, ship.Locaion, x, y, astroroids.GetAstroroidList(), planets.Planets);
     spriteBatch.DrawString(font, "Credits: " + credits, new Vector2(20, 20), Color.Green);
 }