Example #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            map = Content.Load<Map>("desert");

            // Create a new simple point light texture to use for the lights
            this.lightTexture = LightTextureBuilder.CreatePointLight(this.GraphicsDevice, 512);

            // Load sprites
            playerImage = Content.Load<Texture2D>("player");
            gemImage = Content.Load<Texture2D>("gem");

            //Test Sprite
            testSprite = new Sprite(playerImage, new Vector2(100, -100), krypton);
            testSprite.Position = new Vector2(200, 20);
            testSprite.Velocity = new Vector2(0.2f, 0f);

            //Dont add it cuase
            sprites.Add(testSprite);

            //Create player
            player = new Player(Vector2.Zero,testSprite);
            // Load the player resources
            Animation playerAnimation = new Animation();
            Texture2D playerTexture = Content.Load<Texture2D>("shipAnimation");
            playerAnimation.Initialize(playerTexture, Vector2.Zero, 115, 69, 8, 45, Color.White, 1f, true, this.GraphicsDevice);
            player.Position = new Vector2(200, 200);
            //player.Velocity = new Vector2(0f, 0f);

            testSprite2 = new Sprite(playerImage, new Vector2(100, -100), krypton);
            testSprite2.Position = new Vector2(100, 20);
            testSprite2.Velocity = new Vector2(0f, 0.1f);
            sprites.Add(testSprite2);

            // Create a light we can control
            torch = new Light2D()
            {
                Texture = this.lightTexture,
                X = 0,
                Y = 0,
                Range = 600,
                Intensity = 0.5f,
                Color = Color.White,
                ShadowType = ShadowType.Illuminated,
                Fov = MathHelper.PiOver2 * (float)(0.5)
            };

            this.krypton.Lights.Add(this.torch);

            /*
            // Make some random lights!
            for (int i = 0; i < 9; i++)
            {
                byte r = (byte)(this.random.Next(255 - 32) + 32);
                byte g = (byte)(this.random.Next(255 - 32) + 32);
                byte b = (byte)(this.random.Next(255 - 32) + 32);

                Light2D light = new Light2D()
                {
                    Texture = lightTexture,
                    Range = (float)(this.random.NextDouble() * 200 + 100),
                    Color = new Color(r, g, b),
                    //Intensity = (float)(this.mRandom.NextDouble() * 0.25 + 0.75),
                    Intensity = 0.8f,
                    Angle = MathHelper.TwoPi * (float)this.random.NextDouble(),
                    X = (float)(this.random.NextDouble() * 500),
                    Y = (float)(this.random.NextDouble() * 500),
                };

                // Here we set the light's field of view
                if (i % 2 == 0)
                {
                    light.Fov = MathHelper.PiOver2 * (float)(this.random.NextDouble() * 0.75 + 0.25);
                }

                this.krypton.Lights.Add(light);
            }
             */

            /*
            int x = 10;
            int y = 10;
            float w = 1000;
            float h = 1000;

            // Make lines of lines of hulls!
            for (int j = 0; j < y; j++)
            {
                // Make lines of hulls!
                for (int i = 0; i < x; i++)
                {
                    var posX = (((i + 0.5f) * w) / x) - w / 2 + (j % 2 == 0 ? w / x / 2 : 0);
                    var posY = (((j + 0.5f) * h) / y) - h / 2; // +(i % 2 == 0 ? h / y / 4 : 0);

                    var hull = ShadowHull.CreateRectangle(Vector2.One * 10f);
                    hull.Position.X = posX;
                    hull.Position.Y = posY;
                    hull.Scale.X = (float)(this.random.NextDouble() * 2.75f + 0.25f);
                    hull.Scale.Y = (float)(this.random.NextDouble() * 2.75f + 0.25f);

                    krypton.Hulls.Add(hull);
                }
            }
            */ //Test lights
        }
Example #2
0
        public void Intialise(List<Platform> platforms,List<Sprite> sprites,KryptonEngine krypton,ContentManager content,GraphicsDevice graphicsDevice, ScreenDebuger screenDebuger, Level level)
        {
            if (EntityType == "Player")
            {
                Texture2D playerImage = content.Load<Texture2D>("player");
                Sprite testSprite = new Sprite(playerImage, new Vector2(0,0), false, krypton);
                Player aPlayer = new Player(new Vector2(EntityBounds.X, EntityBounds.Y), testSprite,screenDebuger,content,graphicsDevice,level);
                level.setPlayer(aPlayer);
            }

            if (EntityType == "Hazard")
            {

            }

            if (EntityType == "Platform")
            {
                TileCollision tileCollision = TileCollision.Platform;
                if (Properties["CollisionType"] == "Platform") {tileCollision = TileCollision.Platform;}
                if (Properties["CollisionType"] == "Passable") { tileCollision = TileCollision.Passable; }
                if (Properties["CollisionType"] == "Impassable") { tileCollision = TileCollision.Impassable; }
                Platform platform = new Platform(EntityBounds, tileCollision, Convert.ToBoolean(Properties["IsShadowCaster"]), krypton);
                platforms.Add(platform);
            }

            if (EntityType == "Light")
            {
                Color color = new Color();
                color.R = (byte)Convert.ToInt32(Properties["R"]);
                color.G = (byte)Convert.ToInt32(Properties["G"]);
                color.B = (byte)Convert.ToInt32(Properties["B"]);
                color.A = 255;

                /*
                    X = EntityBounds.X,
                    Y = EntityBounds.Y,
                    Range = (float)Convert.ToInt32(Properties["Range"]),
                    Intensity = (float)Convert.ToDouble(Properties["Intensity"]),
                    Color = color,
                    ShadowType = ShadowType.Illuminated,
                    Fov = MathHelper.PiOver2 * (float) (0.5)
                 * */

                    Light2D light = new Light2D
                    {
                        Texture = LightTextureBuilder.CreatePointLight(graphicsDevice, 1024),
                        X = EntityBounds.X,
                        Y = EntityBounds.Y,
                        Range = (float)Convert.ToInt32(Properties["Range"]),
                        Intensity = (float)Convert.ToDouble(Properties["Intensity"]),
                        Color = color,
                        ShadowType = ShadowType.Illuminated,
                        Fov = MathHelper.PiOver2 * (float)Convert.ToDouble(Properties["Fov"])
                    };

                //Optional Properties
                    if(Properties.ContainsKey("Flicker")){ light.Flicker = (bool)Convert.ToBoolean(Properties["Flicker"]);}

                    krypton.Lights.Add(light);
            }
        }
Example #3
0
 public void setPlayer(Player player)
 {
     this.player = player;
 }