Exemplo n.º 1
0
        public void Draw()
        {
            String pMsg = this.msg;

            float x = this.xStart;
            float y = this.yStart;

            for (int i = 0; i < pMsg.Length; i++)
            {
                int key = Convert.ToByte(pMsg[i]);

                Glyph pGlyph = GlyphMan.Find(key);
                Debug.Assert(pGlyph != null);

                Azul.Sprite pAzulSprite = new Azul.Sprite(pGlyph.pFont,
                                                          new Azul.Rect(pGlyph.x, pGlyph.y, pGlyph.width, pGlyph.height),
                                                          new Azul.Rect(x, y, pGlyph.width, pGlyph.height),
                                                          new Azul.Color(1.0f, 1.0f, 1.0f));

                pAzulSprite.Update();
                pAzulSprite.Render();

                x += pGlyph.width;
            }
        }
Exemplo n.º 2
0
        //-----------------------------------------------------------------------------
        // Game::LoadContent()
        //		Allows you to load all content needed for your engine,
        //	    such as objects, graphics, etc.
        //-----------------------------------------------------------------------------
        public override void LoadContent()
        {
            //---------------------------------------------------------------------------------------------------------
            // Audio
            //---------------------------------------------------------------------------------------------------------

            /*
             * // Create the Audio Engine
             * AudioEngine = new IrrKlang.ISoundEngine();
             *
             * // Play a sound file
             * music = AudioEngine.Play2D("theme.wav", true);
             * music.Volume = 0.2f;
             *
             * // Resident loads
             * srcShoot = AudioEngine.AddSoundSourceFromFile("shoot.wav");
             * sndShoot = AudioEngine.Play2D(srcShoot, false, false, false);
             * sndShoot.Stop();
             */

            soundEngine.themeSong();
            soundEngine.init();
            //---------------------------------------------------------------------------------------------------------
            // Setup Font
            //---------------------------------------------------------------------------------------------------------

            // Font - texture
            pFont = new Azul.Texture("consolas20pt.tga");
            Debug.Assert(pFont != null);

            GlyphMan.AddXml("Consolas20pt.xml", pFont);

            //---------------------------------------------------------------------------------------------------------
            // Load the Textures
            //---------------------------------------------------------------------------------------------------------

            // Red bird texture
            pText = new Azul.Texture("unsorted.tga");
            Debug.Assert(pText != null);

            //---------------------------------------------------------------------------------------------------------
            // Create Sprites
            //---------------------------------------------------------------------------------------------------------

            pRedBird = new Azul.Sprite(pText, new Azul.Rect(903.0f, 797.0f, 46.0f, 46.0f), new Azul.Rect(300.0f, 100.0f, 30.0f, 30.0f));
            Debug.Assert(pRedBird != null);

            //---------------------------------------------------------------------------------------------------------
            // Demo variables
            //---------------------------------------------------------------------------------------------------------

            stats = new GameStats();

            if (startgame)
            {
                active_piece = generateRandomShape();
                active_piece.setToPlay();
                future_piece = generateRandomShape();
            }
        }
Exemplo n.º 3
0
        private static GlyphMan privGetInstance()
        {
            if (pInstance == null)
            {
                pInstance = new GlyphMan();
            }

            // Safety - this forces users to call Create() first before using class
            Debug.Assert(pInstance != null);

            return(pInstance);
        }
Exemplo n.º 4
0
        public static Glyph Find(int key)
        {
            GlyphMan pMan = GlyphMan.privGetInstance();

            Glyph pNode = pMan.pHead;

            while (pNode != null)
            {
                if (pNode.key == key)
                {
                    // found it
                    break;
                }

                pNode = pNode.pNext;
            }

            return(pNode);
        }
Exemplo n.º 5
0
        public static void AddXml(String assetName, Azul.Texture pFont)
        {
            // Singleton
            GlyphMan pMan = GlyphMan.privGetInstance();

            System.Xml.XmlTextReader reader = new XmlTextReader(assetName);

            int key    = -1;
            int x      = -1;
            int y      = -1;
            int width  = -1;
            int height = -1;

            // I'm sure there is a better way to do this... but this works for now
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:     // The node is an element.
                    if (reader.GetAttribute("key") != null)
                    {
                        key = Convert.ToInt32(reader.GetAttribute("key"));
                    }
                    else if (reader.Name == "x")
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Text)
                            {
                                x = Convert.ToInt32(reader.Value);
                                break;
                            }
                        }
                    }
                    else if (reader.Name == "y")
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Text)
                            {
                                y = Convert.ToInt32(reader.Value);
                                break;
                            }
                        }
                    }
                    else if (reader.Name == "width")
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Text)
                            {
                                width = Convert.ToInt32(reader.Value);
                                break;
                            }
                        }
                    }
                    else if (reader.Name == "height")
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Text)
                            {
                                height = Convert.ToInt32(reader.Value);
                                break;
                            }
                        }
                    }
                    break;

                case XmlNodeType.EndElement:     //Display the end of the element
                    if (reader.Name == "character")
                    {
                        // have all the data... so now create a glyph
                        //  Debug.WriteLine("key:{0} x:{1} y:{2} w:{3} h:{4}", key, x, y, width, height);
                        pMan.Add(pFont, key, x, y, width, height);
                    }
                    break;
                }
            }
        }