Ejemplo n.º 1
0
        /// <summary>
        /// Renders Info screen
        /// </summary>
        private void RenderBackground()
        {
            uint tileIndex;

            // Background.
            if (m_fadingBgCounter < 0.0f)
            {
                tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexBackground, (uint)m_bgIndex1, 0);
                m_renderer.RenderTile(0, 0, m_areaWidth, m_areaHeight, 0, 0, tileIndex, 0);
            }
            else
            {
                uint a = (uint)(m_fadingBgCounter * 256.0f);

                if (a > 255)
                {
                    a = 255;
                }

                tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexBackground, (uint)m_bgIndex1, a);

                m_renderer.RenderTile(0, 0, m_areaWidth, m_areaHeight, 0, 0, tileIndex, 0);

                tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexBackground, (uint)m_bgIndex2, (255 - a));

                m_renderer.RenderTile(0, 0, m_areaWidth, m_areaHeight, 0, 0, tileIndex, 0);
            }

            tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexBackground, 2, 200);

            m_renderer.RenderTile(-m_areaWidth / 2.0f, -m_areaWidth / 2.0f, m_areaWidth * 2.0f, m_areaWidth * 2.0f,
                                  m_bgAngle / 4.0f, 1, tileIndex, 0);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="rend">ITileRenderer which is used for rendering and as an engine.</param>
 /// <param name="x">Game area X begin</param>
 /// <param name="y">Game area Y begin</param>
 /// <param name="width">Game area width</param>
 /// <param name="height">Game area height</param>
 public ITileGame(ITileRenderer rend, float x, float y, float width, float height)
 {
     m_state     = TileGameState.eTILEGAMESTATE_NOTSET;
     m_renderer  = rend;
     m_logoState = 0.0f;
     m_hudState  = 0.0f;
     m_pengine   = new ParticleEngine(rend);
     SetGameArea(x, y, width, height);
 }
Ejemplo n.º 3
0
        public ParticleEngine(ITileRenderer renderer)
        {
            m_renderer = renderer;
            m_cp       = 0;

            // initialize particles inactive
            for (int f = 0; f < MAX_PARTICLES; f++)
            {
                m_particles[f]          = new Particle();
                m_particles[f].LifeTime = 0;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Write a string.
        /// </summary>
        /// <param name="x">Target X position</param>
        /// <param name="y">Target Y position</param>
        /// <param name="text">Text to be rendered</param>
        /// <param name="fade">Fade for the render</param>
        /// <param name="charSize">Size of a single character</param>
        /// <param name="charSpace">Space between characters</param>
        protected void WriteText(float x, float y, string text, int fade, float charSize, float charSpace)
        {
            int length = text.Length;

            char[] str = text.ToCharArray();

            uint tileIndex;

            for (int i = 0; i < length; i++)
            {
                uint ch = (uint)str[i] - 32;
                tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexFont, ch, (uint)fade);
                m_renderer.RenderTile(x, y, charSize, charSize, 0, 0, tileIndex, 0);
                x += charSpace;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="rend">ITileRenderer which is used for rendering and as an engine.</param>
        /// <param name="x">Game area X begin</param>
        /// <param name="y">Game area Y begin</param>
        /// <param name="width">Game area width</param>
        /// <param name="height">Game area height</param>
        public TileNpc(ITileRenderer renderer, float x, float y, float width, float height)
            : base(renderer, x, y, width, height)
        {
            m_level = new NpcLevel(renderer, m_pengine, TILE_GRIDWIDTH, TILE_GRIDHEIGHT);
            m_infoScreenDisplayCounter = -1;
            m_effectAngle     = 0;
            m_bgIndex1        = 1;
            m_bgIndex2        = 0;
            m_fadingBgCounter = -1;
            m_menuCounter     = -1;
            m_menuModeCounter = -1;

            m_timeSinceLastScore = 0;
            m_gameIsOn           = 0;
            m_timer                = 0;
            m_gameOverCounter      = -1;
            m_pauseCounter         = -1;
            m_levelCompletedPoem   = null;
            m_timeTimerEffect      = 65535;
            m_completedTextAngle   = 0;
            m_completedTextCounter = -21;

            m_eventCounter  = 0;
            m_bgAngle       = 0;
            m_logoWobble    = 0;
            m_logoWobbleInc = 0;

            m_currentLevel     = 0;
            m_blockTimerEffect = 0;
            m_targetTimer      = 0;

            m_levelCompletedCounter = 0;
            m_highScore             = 0;
            m_timer        = 0;
            m_score        = 0;
            m_displayScore = 0;
            m_difficulty   = 1;                 // adults, 0 for kids ?
            m_level.SetGameArea(x, y - 0.12f, width, height + 0.1f);

            for (int f = 0; f < 7; f++)
            {
                m_scoreRollPos[f]         = 0.0f;
                m_scoreRollTargetPos[f]   = 0.0f;
                m_scoreRollExTargetPos[f] = 0.0f;
                m_scoreRollInc[f]         = 0.0f;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Writes a string with an effect used in the game.
        /// </summary>
        /// <param name="y">Y position of the render</param>
        /// <param name="text">Text to be rendered</param>
        /// <param name="charSize">Size of a single character</param>
        /// <param name="fade">Fade (and effect strength) for the text.</param>
        protected void WriteEffectText(float y, string text, float charSize, int fade)
        {
            if (fade < 0)
            {
                return;
            }
            else if (fade > 255)
            {
                fade = 255;
            }

            int length   = text.Length;
            int totcount = 0;

            float[] cosin = m_level.CosineTable;
            float   yadd;
            float   xadd;
            float   charSpace = charSize * 5 / 8;
            float   x         = 0.5f - (float)length * charSpace / 2;

            char[] str = text.ToCharArray();

            uint tileIndex;

            for (int i = 0; i < length; i++)
            {
                uint ch = (uint)str[i];
                if (ch >= 'a' && ch <= 'z')
                {
                    ch = ch - 'a' + 'A';        // to high-case
                }
                ch -= 32;

                yadd  = (cosin[(totcount * 850 + (int)(m_effectAngle * 65536.0f / 70.0f)) & 4095] * (float)fade / 50.0f * charSize);
                yadd += cosin[(1000 + (int)(m_effectAngle * 65536 / 10.0f) + totcount * 600) & 4095] / 50.0f * charSize;
                xadd  = cosin[((int)(m_effectAngle * 400.0f) + totcount * 800) & 4095] / 50.0f * charSize;

                tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexFont, ch, (uint)fade);

                m_renderer.RenderTile(x + xadd, y + yadd, charSize, charSize, fade * 0.1f, 0, tileIndex, 0);

                totcount++;
                x += charSpace;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Renders logo
        /// </summary>
        private void RenderLogo()
        {
            float mx = 0.5f;
            float my = (-1.0f + m_logoState * 2);

            float w    = (1.0f - m_logoWobble * 2);
            float h    = (1.0f + m_logoWobble * 2);
            int   fade = 255 - (int)(m_logoState * 255.0f);

            if (fade < 0)
            {
                fade = 0;
            }

            uint tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexLogo, 0, (uint)fade);

            m_renderer.RenderTile(mx - w / 2, my - h, w, h, 0, 0, tileIndex, 0);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Renders Hud
        /// </summary>
        private void RenderHud()
        {
            // draw the meter, clocklike here
            float x = -3000 / 65536.0f;
            float w = (65536 + 7000) / 65536.0f; //65536/2;
            float h = 19000 / 65536.0f;

            float y = -(1.0f - m_hudState) / 3 - 0.05f;

            uint tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexMeterBase, 1, 0);

            m_renderer.RenderTile(2000 / 65536.0f, y, 15000 / 65536.0f, h, 0, 0, tileIndex, 0);
            m_renderer.RenderTile(29000 / 65536.0f, y, 35000 / 65536.0f, h, 0, 0, tileIndex, 0);


            for (int f = 0; f < 7; f++)
            {
                tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexMeter, 0, 0);
                m_renderer.RenderTile(scoreRollXPos[f] - rollWidth / 2,
                                      y + h / 2 - (h * 7 / 32),
                                      rollWidth,
                                      h * 14 / 32,
                                      0, 0, tileIndex, 0);
            }

            for (int yroll = -2; yroll <= 1; yroll++)
            {
                for (int f = 0; f < 7; f++)
                {
                    int num = (((int)(m_scoreRollPos[f] * 65536.0f) >> 16) - 1 - yroll) % 10;

                    if (num < 0)
                    {
                        num = 10 + num;
                    }

                    float yofs = ((m_scoreRollPos[f] + 100.0f) - (float)System.Math.Floor(m_scoreRollPos[f] + 100.0f));

                    yofs += ((float)yroll);
                    yofs -= 100.0f;

                    float ypos = (float)System.Math.Sin((float)yofs * 3.14159f / 4.0f) * (float)h / 3.3f;

                    float numheight = h / 2 - System.Math.Abs(ypos) * 13 / 8;

                    tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexMeter, (uint)(1 + num), 0);

                    m_renderer.RenderTile(scoreRollXPos[f] - rollWidth / 2,
                                          y + h / 2 - (numheight / 2) + ypos,
                                          rollWidth,
                                          numheight,
                                          0, 0, tileIndex, 0);
                }
            }

            tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexMeterBase, 0, 0);
            m_renderer.RenderTile(x, y, w, h, 0, 0, tileIndex, 0);

            const float pauseButtonXPos = 0.302f;

            // render pausebutton
            if (m_state == TileGameState.eTILEGAMESTATE_PAUSED)
            {
                tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexExtra1, 1, 0);
                m_renderer.RenderTile(x + pauseButtonXPos, y - 1.0f + m_hudState, h * 2 / 3,
                                      h * 2 / 3 * m_areaHeight / m_areaWidth, 0, 0, tileIndex, 0);
            }
            else
            {
                tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexExtra1, 0, 0);
                m_renderer.RenderTile(x + pauseButtonXPos, y - 1.0f + m_hudState, h * 2 / 3, h * 2 / 3 * m_areaHeight / m_areaWidth, 0, 0, tileIndex, 0);
            }

            tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexParticle, 0, 0);
            m_renderer.RenderTile(14000 / 65536.0f, 6000 / 65536.0f - 1.0f + m_hudState, 14000 / 65536.0f, 14000 / 65536.0f * m_areaWidth / m_areaHeight,
                                  0, 0, tileIndex, 0);

            int n = ((m_currentLevel + 1) / 10);

            if (n == 0)
            {
                n = 10;
            }

            tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexMeter, (uint)n, 0);
            m_renderer.RenderTile(14200 / 65536.0f, 6200 / 65536.0f - 1.0f + m_hudState, 13000 / 65536.0f, 13000 / 65536.0f * m_areaWidth / m_areaHeight,
                                  0, 0, tileIndex, 0);

            tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexParticle, 0, 0);
            m_renderer.RenderTile(20000 / 65536.0f, 9000 / 65536.0f - 1.0f + m_hudState, 14000 / 65536.0f, 14000 / 65536.0f * m_areaWidth / m_areaHeight,
                                  0, 0, tileIndex, 0);

            n = ((m_currentLevel + 1) % 10);

            if (n == 0)
            {
                n = 10;
            }

            tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexMeter, (uint)n, 0);
            m_renderer.RenderTile(20200 / 65536.0f, 9200 / 65536.0f - 1.0f + m_hudState, 13000 / 65536.0f, 13000 / 65536.0f * m_areaWidth / m_areaHeight,
                                  0, 0, tileIndex, 0);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Write the level completed string with an effect.
        /// </summary>
        protected void WriteLevelCompletedString()
        {
            if (m_levelCompletedPoem == null)
            {
                return;
            }

            float  x         = 0;
            float  y         = levelCompletedStringBeginY;
            string text      = m_levelCompletedPoem;
            float  charSize  = levelCompletedStringCharSize;
            float  charSpace = levelCompletedStringCharSize * 5 / 8;
            int    fade      = 0;

            float[] cosineTable = m_level.CosineTable;
            int     totCount    = 0;
            int     f;
            float   g;
            string  testr    = null;
            string  cur_line = null;

            float sizeinc;

            char[]   splitSeparators = new char[] { ' ', '\n' };
            string[] words           = text.Split(splitSeparators);
            int      wordCount       = 0;

            while (true)            // Loop until all words are processed
            {
                if (wordCount < words.Length)
                {
                    testr = words[wordCount];
                    wordCount++;
                }
                else
                {
                    testr = null;
                }

                if (cur_line != null &&
                    (testr == null || wordCount >= words.Length ||
                     (cur_line.Length + testr.Length) * charSpace > 0.95f))
                {
                    // Curline must be drawn
                    f = 0;
                    int j = cur_line.Length;
                    x  = 0.5f - j * charSpace / 2;
                    x -= charSpace / 4;
                    // Loop through each character

                    char[] str = cur_line.ToCharArray();

                    for (int i = 0; i < j; i++)
                    {
                        uint ch = (uint)str[i];
                        if (ch >= 'a' && ch <= 'z')
                        {
                            ch = ch - 'a' + 'A';                                // to high-case
                        }
                        ch -= 32;

                        g = totCount - m_completedTextCounter;

                        if (g < -128)
                        {
                            g = g + 128;
                        }
                        else if (g < 0)
                        {
                            g = 0;
                        }

                        sizeinc = -System.Math.Abs(g) / 256;
                        fade    = (int)(g * 32.0f);

                        if (fade > 255)
                        {
                            return;
                        }

                        fade = (int)System.Math.Abs(fade);

                        if (ch != 255 && fade < 255)
                        {
                            uint tileIndex = ITileRenderer.BuildTileIndex(TextureID.TexFont, ch, (uint)fade);

                            m_renderer.RenderTile(x - sizeinc / 2 + cosineTable[(1000 + (int)(m_completedTextAngle / 20) + f * 600) & 4095] / 64.0f,
                                                  g / 64 + y - sizeinc / 2 + cosineTable[((int)(m_completedTextAngle / 30) + f * 800) & 4095] / 128.0f,
                                                  charSize + sizeinc,
                                                  charSize + sizeinc,
                                                  -(sizeinc * 8),
                                                  0,
                                                  tileIndex,
                                                  0);
                        }

                        totCount++;
                        x += charSpace;
                    }

                    cur_line = null;
                    x        = 0;
                    y       += charSpace * 4 / 3;
                }

                if (testr != null)
                {
                    if (cur_line == null)
                    {
                        cur_line = testr;
                    }
                    else
                    {
                        cur_line += " " + testr;
                    }
                }

                if (cur_line == null && wordCount >= words.Length)
                {
                    break;
                }
            }
        }