Example #1
0
        public Sounds()
        {
            if (Instance != null) throw new Exception("Sound engine instance doubled!");
            Sounds.Instance = this;

            soundInstances = new Dictionary<string,SoundEffectInstance>();
            sounds = new Dictionary<string,SoundEffect>();
            musicSongs = new Dictionary<string, Song>();
        }
Example #2
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()
        {
            physics = new Physics(new Vector2(0, 200));

            new Shaders();

            random = new Random();
            sounds = new Sounds();

            camera = new Camera();
            camera.position = new Vector3(0.0f, 100.0f, 500.0f);

            player = new Player();
            player.position = new Vector3(100.0f, 400.0f, 0.0f);

            bg = new Background();

            textures = new Dictionary<string, Texture2D>();
            debugTexts = new List<string>();
            bullets = new List<Bullet1>();
            particles = new List<GameObject3D>();
            enemies = new List<Enemy>();
            deadEnemies = new List<Enemy>();
            platforms = new List<Platform>();

            platforms.Add(new Platform(new Vector2(200,-520)));
            platforms.Add(new Platform(new Vector2(310, -490)));
            platforms.Add(new Platform(new Vector2(420, -460)));
            platforms.Add(new Platform(new Vector2(530, -430)));
            platforms.Add(new Platform(new Vector2(420, -400)));
            platforms.Add(new Platform(new Vector2(310, -370)));
            platforms.Add(new Platform(new Vector2(200, -340)));

            for (int i = 0; i < 10; i++)
            {
                enemies.Add(new Enemy(new Vector3(150 + random.Next(450), -100, 0)));
            }

            // Vertex declaration for rendering our 3D model.
            graphics.GraphicsDevice.VertexDeclaration = new VertexDeclaration(graphics.GraphicsDevice, VertexPositionNormalTexture.VertexElements);

            graphics.GraphicsDevice.RenderState.AlphaBlendEnable = true;
            graphics.GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha; // source rgb * source alpha
            graphics.GraphicsDevice.RenderState.AlphaSourceBlend = Blend.One; // don't modify source alpha
            graphics.GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha; // dest rgb * (255 - source alpha)
            graphics.GraphicsDevice.RenderState.AlphaDestinationBlend = Blend.InverseSourceAlpha; // dest alpha * (255 - source alpha)
            graphics.GraphicsDevice.RenderState.BlendFunction = BlendFunction.Add; // add source and dest results

            base.Initialize();
        }