GAM456-SpaceInvaders / SpaceInvaders / Game.cs
Game.cs
Raw
using System;
using System.Diagnostics;

namespace SpaceInvaders
{
    class SpaceInvaders : Azul.Game
    {
        //-----------------------------------------------------------------------------
        // Game::Initialize()
        //		Allows the engine 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. 
        //-----------------------------------------------------------------------------
        public override void Initialize()
        {
            // Game Window Device setup
            this.SetWindowName(" ");
            this.SetWidthHeight(896, 1024);
            this.SetClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        }


        //-----------------------------------------------------------------------------
        // Game::LoadContent()
        //		Allows you to load all content needed for your engine,
        //	    such as objects, graphics, etc.
        //-----------------------------------------------------------------------------
        public override void LoadContent()
        {
            // LOAD UNIVERSAL GAME RESOURCES

            //-------------------------------------------------------------------------
            // LOAD MANAGERS
            //-------------------------------------------------------------------------
            {
                TextureMan.Create();
                ImageMan.Create();
                SpriteMan.Create();
                SpriteBoxMan.Create();
                SpriteProxyMan.Create();
                SoundManager.Create();
                GlyphMan.Create();
            }


            //-------------------------------------------------------------------------
            // LOAD TEXTURES & FONT
            //-------------------------------------------------------------------------
            {
                TextureMan.AddTexture(Texture.TextureName.Shield, "Brick.tga");

                TextureMan.AddTexture(Texture.TextureName.Aliens, "SpaceInvaders.tga");
                GlyphMan.AddXml(Glyph.GlyphName.InvaderFont, "SpaceInvaders.xml", Texture.TextureName.Aliens);

                TextureMan.AddTexture(Texture.TextureName.Consolas36pt, "Consolas36pt.tga");
                GlyphMan.AddXml(Glyph.GlyphName.Consolas36pt, "Consolas36pt.xml", Texture.TextureName.Consolas36pt);
            }


            //-------------------------------------------------------------------------
            // LOAD IMAGES
            //-------------------------------------------------------------------------
            {
                //Aliens
                ImageMan.AddImage(Image.ImageName.Octopus_Closed, Texture.TextureName.Aliens, 3.0f, 3.0f, 12.0f, 8.0f);
                ImageMan.AddImage(Image.ImageName.Octopus_Open, Texture.TextureName.Aliens, 18.0f, 3.0f, 12.0f, 8.0f);

                ImageMan.AddImage(Image.ImageName.Crab_Open, Texture.TextureName.Aliens, 33.0f, 3.0f, 11.0f, 8.0f);
                ImageMan.AddImage(Image.ImageName.Crab_Closed, Texture.TextureName.Aliens, 47.0f, 3.0f, 11.0f, 8.0f);

                ImageMan.AddImage(Image.ImageName.Squid_Closed, Texture.TextureName.Aliens, 61.0f, 3.0f, 8.0f, 8.0f);
                ImageMan.AddImage(Image.ImageName.Squid_Open, Texture.TextureName.Aliens, 72.0f, 3.0f, 8.0f, 8.0f);

                ImageMan.AddImage(Image.ImageName.UFO, Texture.TextureName.Aliens, 99.0f, 3.0f, 16.0f, 8.0f);

                //Bombs
                ImageMan.AddImage(Image.ImageName.Bomb_Straight, Texture.TextureName.Aliens, 65.0f, 26.0f, 3.0f, 7.0f);
                ImageMan.AddImage(Image.ImageName.Bomb_Cross, Texture.TextureName.Aliens, 47.0f, 29.0f, 5.0f, 6.0f);
                ImageMan.AddImage(Image.ImageName.Bomb_Zigzag0, Texture.TextureName.Aliens, 18.0f, 24.0f, 3.0f, 7.0f);

                //Ship & missile
                ImageMan.AddImage(Image.ImageName.Ship, Texture.TextureName.Aliens, 3.0f, 14.0f, 13.0f, 8.0f);
                ImageMan.AddImage(Image.ImageName.Missile, Texture.TextureName.Aliens, 3.0f, 29.0f, 1.0f, 4.0f);

                //Shields
                ImageMan.AddImage(Image.ImageName.Brick, Texture.TextureName.Shield, 174.0f, 110.0f, 10.0f, 5.0f);
                ImageMan.AddImage(Image.ImageName.BrickLeft_Top0, Texture.TextureName.Shield, 153.0f, 94.0f, 10.0f, 5.0f);
                ImageMan.AddImage(Image.ImageName.BrickLeft_Top1, Texture.TextureName.Shield, 153.0f, 99.0f, 10.0f, 5.0f);
                ImageMan.AddImage(Image.ImageName.BrickLeft_Bottom, Texture.TextureName.Shield, 173.0f, 129.0f, 10.0f, 5.0f);
                ImageMan.AddImage(Image.ImageName.BrickRight_Top0, Texture.TextureName.Shield, 213.0f, 94.0f, 10.0f, 5.0f);
                ImageMan.AddImage(Image.ImageName.BrickRight_Top1, Texture.TextureName.Shield, 213.0f, 99.0f, 10.0f, 5.0f);
                ImageMan.AddImage(Image.ImageName.BrickRight_Bottom, Texture.TextureName.Shield, 193.0f, 129.0f, 10.0f, 5.0f);
            }


            //-------------------------------------------------------------------------
            // LOAD SPRITES
            //-------------------------------------------------------------------------
            {
                //Sprite Box
                SpriteBoxMan.AddBox(SpriteBox.SpriteBoxName.Box1, 550.0f, 500.0f, 50.0f, 150.0f, SpriteBase.pRed);
                SpriteBoxMan.AddBox(SpriteBox.SpriteBoxName.Box2, 550.0f, 100.0f, 50.0f, 100.0f);

                //Aliens
                SpriteMan.AddSprite(Sprite.SpriteName.Squid, Image.ImageName.Squid_Closed, 100.0f, 650.0f, 33.0f, 30.0f);
                SpriteMan.AddSprite(Sprite.SpriteName.Crab, Image.ImageName.Crab_Closed, 100.0f, 584.0f, 45.0f, 30.0f);
                SpriteMan.AddSprite(Sprite.SpriteName.Octopus, Image.ImageName.Octopus_Closed, 100.0f, 452.0f, 48.0f, 33.0f);
                SpriteMan.AddSprite(Sprite.SpriteName.UFO, Image.ImageName.UFO, 400.0f, 500.0f, 58.0f, 28.0f, SpriteBase.pRed);

                //Bombs
                SpriteMan.AddSprite(Sprite.SpriteName.Bomb_Straight, Image.ImageName.Bomb_Straight, 100.0f, 100.0f, 10.0f, 20.0f);
                SpriteMan.AddSprite(Sprite.SpriteName.Bomb_Cross, Image.ImageName.Bomb_Cross, 100.0f, 100.0f, 5.0f, 20.0f);
                SpriteMan.AddSprite(Sprite.SpriteName.Bomb_Zigzag, Image.ImageName.Bomb_Zigzag0, 200.0f, 200.0f, 10.0f, 20.0f);

                //Ship & Missile
                SpriteMan.AddSprite(Sprite.SpriteName.Ship, Image.ImageName.Ship, 400.0f, 40.0f, 50.0f, 30.0f, SpriteBase.pGreen);
                SpriteMan.AddSprite(Sprite.SpriteName.Missile, Image.ImageName.Missile, 400.0f, 70.0f, 4.0f, 14.0f);

                //Shields
                SpriteMan.AddSprite(Sprite.SpriteName.Brick, Image.ImageName.Brick, 50.0f, 25.0f, 12.0f, 6.0f);
                SpriteMan.AddSprite(Sprite.SpriteName.BrickLeft_Top0, Image.ImageName.BrickLeft_Top0, 50.0f, 25.0f, 12.0f, 6.0f);
                SpriteMan.AddSprite(Sprite.SpriteName.BrickLeft_Top1, Image.ImageName.BrickLeft_Top1, 50.0f, 25.0f, 12.0f, 6.0f);
                SpriteMan.AddSprite(Sprite.SpriteName.BrickLeft_Bottom, Image.ImageName.BrickLeft_Bottom, 50.0f, 25.0f, 12.0f, 6.0f);
                SpriteMan.AddSprite(Sprite.SpriteName.BrickRight_Top0, Image.ImageName.BrickRight_Top0, 50.0f, 25.0f, 12.0f, 6.0f);
                SpriteMan.AddSprite(Sprite.SpriteName.BrickRight_Top1, Image.ImageName.BrickRight_Top1, 50.0f, 25.0f, 12.0f, 6.0f);
                SpriteMan.AddSprite(Sprite.SpriteName.BrickRight_Bottom, Image.ImageName.BrickRight_Bottom, 50.0f, 25.0f, 12.0f, 6.0f);
            }


            //-------------------------------------------------------------------------
            // LOAD INITIAL GAME STATE
            //-------------------------------------------------------------------------

            GameContext.Create();

        }


        //-----------------------------------------------------------------------------
        // Game::Update()
        //      Called once per frame, update data, tranformations, etc
        //      Use this function to control process order
        //      Input, AI, Physics, Animation, and Graphics
        //-----------------------------------------------------------------------------
        public override void Update()
        {
            GlobalTimer.Update(this.GetTime());
            GameContext.Update(this.GetTime());
        }


        //-----------------------------------------------------------------------------
        // Game::Draw()
        //		This function is called once per frame
        //	    Use this for draw graphics to the screen.
        //      Only do rendering here
        //-----------------------------------------------------------------------------
        public override void Draw()
        {
            GameContext.Draw();
        }


        //-----------------------------------------------------------------------------
        // Game::UnLoadContent()
        //       unload content (resources loaded above)
        //       unload all content that was loaded before the Engine Loop started
        //-----------------------------------------------------------------------------
        public override void UnLoadContent()
        {
            //call destroy blah blah here
        }


    }
}