Example #1
0
        protected override void LoadContent()
        {
            ContentManager Content = GameRef.Content;
            ShipTexture = Content.Load<Texture2D>(@"Sprites\block_64");
            LaserTexture = Content.Load<Texture2D>(@"Sprites\laser");
            Asteriod64 = Content.Load<Texture2D>(@"Sprites\asteriod_64");
            Asteriod32 = Content.Load<Texture2D>(@"Sprites\asteriod_32");
            StarTexture = Content.Load<Texture2D>(@"Sprites\Star_256");
            PlanetBlueTexture = Content.Load<Texture2D>(@"Sprites\Planet_Blue_128");
            PlanetPurpleTexture = Content.Load<Texture2D>(@"Sprites\Planet_Purple_128");
            CreatureTexture = Content.Load<Texture2D>(@"Sprites\Creature_32");
            LaserTurretTexture = Content.Load<Texture2D>(@"Sprites\Weapon_16");
            SpaceTexture = Content.Load<Texture2D>(@"Backgrounds\Nebula_1920X1200");
            fontArial = Content.Load<SpriteFont>(@"Fonts\Arial");

            LaserFireTexture = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            LaserFireTexture.SetData(new[] { Color.Yellow });

            FpsCounter.Font = fontArial;
            RNG = new Random(3); //TODO: Randomize seed

            SolarSystem solarSystem = new SolarSystem();
            solarSystem.Generate(RNG, 1000000);

            Camera2D camera = new Camera2D(ScreenRectangle);
            SceneGraph = new SceneGraph(camera, null);
            SceneGraph.Sky = SpaceTexture;

            foreach (GameObject obj in solarSystem.Stars)
            {
                SceneGraph.Add(obj);
            }
            foreach (GameObject obj in solarSystem.Planets)
            {
                SceneGraph.Add(obj);
            }
            foreach (GameObject obj in solarSystem.Asteroids)
            {
                SceneGraph.Add(obj);
            }

            Ship = GetShip();
            Ship.Position = Vector2.Zero;

            SceneGraph.Add(Ship);
            camera.CameraMode = CameraMode.Follow;
            camera.FollowTarget = Ship;

            SpaceCreature creature = new SpaceCreature();
            creature.Position = new Vector2(600f, 600f);
            creature.AI = new SimpleFollowAI();
            creature.Target = Ship;
            SceneGraph.Add(creature);

            //SpaceCreature creature2 = new SpaceCreature();
            //creature2.Position = new Vector2(400f, 300f);
            //creature2.AI = new SimpleFollowAI();
            //creature2.Target = Ship;
            //SceneGraph.Add(creature2);

            base.LoadContent();
        }
Example #2
0
 private SceneGraph BuildSceneGraph()
 {
     Rectangle viewport = new Rectangle(0, 0, 800, 600);
     Camera2D camera = new Camera2D(viewport);
     TestMap map = new TestMap();
     return new SceneGraph(camera, map);
 }