public override void Draw()
        {
            ClearPixels();

            if (gameEnded)
            {
                SetPixels(PixelColor.GetSingleColorMap(Program.TableWidth, Program.TableHeight, players[winnerId].GetColor(0.5f)));

                char[] curChar = Convert.ToString((long)CharacterLookup.GetCharUlong((winnerId + 1).ToString()[0]), 2).ToCharArray();
                Array.Reverse(curChar);
                for (int y = 0; y < CharacterLookup.characterHeight; y++)
                {
                    for (int x = 0; x < CharacterLookup.characterWidth; x++)
                    {
                        int index = x + (y * CharacterLookup.characterWidth);
                        if (curChar.Length > index && curChar[index] == '1')
                        {
                            SetPixel(x + 2, y + 1, PixelColor.WHITE);
                        }
                    }
                }

                gameOverScreenTime += updateSpeed;
                if (gameOverScreenTime > 5000)
                {
                    Close();
                }

                return;
            }

            for (int i = 0; i < players.Length; i++)
            {
                players[i].Update();
                SetPixel(players[i].GetPosition(), players[i].color);
            }

            foreach (Projectile p in projectiles)
            {
                p.Update();
                SetPixel(p.position, PixelColor.RED);

                for (int i = 0; i < players.Length; i++)
                {
                    if (p.position.IsTheSame(players[i].GetPosition()))
                    {
                        players[i].Kill(this);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override void Draw()
        {
            ClearPixels();

            for (int i = 0; i < text.Length; i++)
            {
                char[] curChar = Convert.ToString((long)CharacterLookup.GetCharUlong(text[i]), 2).ToCharArray();
                Array.Reverse(curChar);
                for (int y = 0; y < CharacterLookup.characterHeight; y++)
                {
                    for (int x = 0; x < CharacterLookup.characterWidth; x++)
                    {
                        int index = x + (y * CharacterLookup.characterWidth);
                        if (curChar.Length > index && curChar[index] == '1')
                        {
                            SetPixel(x + scrollPosition + i * 7, y + 1, GetColor(index, x, y));
                        }
                    }
                }
            }

            colorFade += 0.01;

            if (nextScroll > scrollSpeed)
            {
                nextScroll = 0;

                scrollPosition -= 1;
                if (scrollPosition < text.Length * -7)
                {
                    scrollPosition = 9;
                }
            }
            else
            {
                nextScroll++;
            }
        }
        public override void Draw()
        {
            ClearPixels();
            DateTime now    = DateTime.Now;
            int      second = now.Second;
            int      minute = now.Minute;
            int      hour   = now.Hour;

            if (toggleTime < 50)
            {
                //Hour
                char[] curChar = Convert.ToString((long)CharacterLookup.GetCharUlong((hour).ToString()[0]), 2).ToCharArray();
                Array.Reverse(curChar);
                for (int y = 0; y < CharacterLookup.characterHeight; y++)
                {
                    for (int x = 0; x < CharacterLookup.characterWidth; x++)
                    {
                        int index = x + (y * CharacterLookup.characterWidth);
                        if (curChar.Length > index && curChar[index] == '1')
                        {
                            SetPixel(x - 1, y + 1, PixelColor.YELLOW);
                        }
                    }
                }

                curChar = Convert.ToString((long)CharacterLookup.GetCharUlong((hour).ToString()[0]), 2).ToCharArray();
                Array.Reverse(curChar);
                for (int y = 0; y < CharacterLookup.characterHeight; y++)
                {
                    for (int x = 0; x < CharacterLookup.characterWidth; x++)
                    {
                        int index = x + (y * CharacterLookup.characterWidth);
                        if (curChar.Length > index && curChar[index] == '1')
                        {
                            SetPixel(x + 4, y + 1, PixelColor.YELLOW);
                        }
                    }
                }
            }
            else
            {
                //Minute
                for (int i = 0; i < minute; i++)
                {
                    SetPixelAtTime(i, PixelColor.WHITE);
                }

                //Second
                if (secondBlink)
                {
                    SetPixelAtTime(second, PixelColor.RED);
                }
                secondBlink = !secondBlink;
            }

            if (toggleTime > 100)
            {
                toggleTime = 0;
            }
            toggleTime++;
        }