예제 #1
0
 public TableAppDraw()
 {
     updateSpeed = 10;
     drawMap     = PixelColor.GetSingleColorMap(Program.TableWidth, Program.TableHeight, PixelColor.BLACK);
 }
        public override void Draw()
        {
            if (raising)
            {
                amount += speed;
            }
            else
            {
                amount -= speed;
            }


            SetPixels(PixelColor.GetSingleColorMap(Program.TableWidth, Program.TableHeight, PixelColor.LerpRGB(PixelColor.BLACK, color, Mathf.Clamp01(amount))));

            if (raising)
            {
                if (amount >= 1.5f)
                {
                    raising = false;
                }
            }
            else if (amount <= -0.5f)
            {
                ClearPixels();
                Reset();
            }
        }
예제 #3
0
        // Given H,S,L in range of 0-1
        // Returns a Color (RGB struct) in range of 0-255
        public static PixelColor FromHSL(double h, double sl, double l)

        {
            double v;

            double r, g, b;



            r = l;   // default to gray

            g = l;

            b = l;

            v = (l <= 0.5) ? (l * (1.0 + sl)) : (l + sl - l * sl);

            if (v > 0)

            {
                double m;

                double sv;

                int sextant;

                double fract, vsf, mid1, mid2;



                m = l + l - v;

                sv = (v - m) / v;

                h *= 6.0;

                sextant = (int)h;

                fract = h - sextant;

                vsf = v * sv * fract;

                mid1 = m + vsf;

                mid2 = v - vsf;

                switch (sextant)

                {
                case 0:

                    r = v;

                    g = mid1;

                    b = m;

                    break;

                case 1:

                    r = mid2;

                    g = v;

                    b = m;

                    break;

                case 2:

                    r = m;

                    g = v;

                    b = mid1;

                    break;

                case 3:

                    r = m;

                    g = mid2;

                    b = v;

                    break;

                case 4:

                    r = mid1;

                    g = m;

                    b = v;

                    break;

                case 5:

                    r = v;

                    g = m;

                    b = mid2;

                    break;
                }
            }

            if (r < 0f || g < 0f || b < 0f || r > 1f || g > 1f || b > 1f)
            {
                return(PixelColor.BLACK);
            }

            PixelColor color = new PixelColor(Convert.ToByte(r * 255.0f), Convert.ToByte(g * 255.0f), Convert.ToByte(b * 255.0f));

            return(color);
        }
 public void RandomizedNewColor()
 {
     color = PixelColor.FromHSL(Program.random.NextDouble(), 1.0, 0.5);
 }
 public PixelColor GetColor(float amount)
 {
     return(PixelColor.FromHSL(id == 0 ? 0.25 : 0.6, 1.0, amount));
 }
        public override void Draw()
        {
            if (!gameOver)
            {
                ClearPixels();

                SetPixel(ship.position.x, ship.position.y, ship.color);
                bool hitEdge = false;
                foreach (Invader i in invaders)
                {
                    if (i.Update())
                    {
                        if (i.position.x >= Program.TableWidth - 1 || i.position.x <= 0)
                        {
                            hitEdge = true;
                        }
                        if (i.position.y >= Program.TableHeight - 1)
                        {
                            gameOver = true;
                            GameOver("Die Aliens haben dich zerstört!", score, "space_invaders");
                            ClearPixels();
                            return;
                        }
                    }
                    SetPixel(i.position.x, i.position.y, i.color);
                }

                if (hitEdge)
                {
                    foreach (Invader i in invaders)
                    {
                        i.ShiftDown();
                    }
                }

                foreach (Projectile p in projectiles)
                {
                    if (p.position.y < 0)
                    {
                        projectiles.Remove(p);
                        return;
                    }

                    p.Update();
                    int hitIndex = p.Hit(invaders);
                    if (hitIndex >= 0)
                    {
                        invaders = invaders.Where((val, idx) => idx != hitIndex).ToArray();
                    }
                    SetPixel(p.position.x, p.position.y, p.color);
                }
            }
            else
            {
                for (int i = 0; i < Program.TableWidth; i++)
                {
                    SetPixel(i, flameWallRange, PixelColor.FromHSL(Math.Abs(flameWallRange / 50f - 0.10), 0.5, 0.5));
                }
                flameWallRange--;
                if (flameWallRange < -4)
                {
                    Close();
                }
            }
        }
        public override void Draw()
        {
            ClearPixels();

            for (int x = 0; x < 3; x++)
            {
                SetPixel(padPos + x, 0, PixelColor.FromHSL(curPadHue, 1f, 0.5f));
            }

            MoveBall();
            SetPixel(ballPos, PixelColor.FromHSL(hueBall, 1f, 0.5f));

            if (hueSpeed > 0.0001f)
            {
                hueSpeed -= 0.00001f;
            }
            else if (hueSpeed < 0.0001f)
            {
                hueSpeed = 0.0001f;
            }

            if (lostTime > 0f)
            {
                SetPixels(PixelColor.GetSingleColorMap(Program.TableWidth, Program.TableHeight, PixelColor.Random(new Random())));
                lostTime += 0.001f;

                if (lostTime > 1f)
                {
                    GameOver("Du hast wohl nicht genügend Zielwasser getrunken...", score, "pong");
                    Program.tableAppManager.LaunchApp(TableAppManager.GetAppById(new TableAppIdle().GetName()));
                }
            }


            hueBall += hueSpeed;
            if (hueBall > 1f)
            {
                hueBall -= 1f;
            }
        }
 public Projectile(Position startPosition, PixelColor color)
 {
     position   = startPosition;
     this.color = color;
 }
 public Invader(Position startPosition, PixelColor color)
 {
     position   = startPosition;
     this.color = color;
 }
 public Ship(PixelColor color)
 {
     position   = new Position(4, Program.TableHeight - 1);
     this.color = color;
 }
 private void SetPixelAtTime(int time, PixelColor color)
 {
     SetPixel(circlePositions[(int)Math.Round((time / 60f) * 35)], color);
 }
        public override void Draw()
        {
            if (isOn)
            {
                SetPixels(PixelColor.GetSingleColorMap(Program.TableWidth, Program.TableHeight, PixelColor.Random(Program.random)));
            }
            else
            {
                ClearPixels();
            }

            isOn = !isOn;
        }
 protected void SetPixel(Position pos, PixelColor c)
 {
     SetPixel(pos.x, pos.y, c);
 }
 protected void ClearPixels()
 {
     colorMap = PixelColor.GetSingleColorMap(Program.TableWidth, Program.TableHeight, PixelColor.BLACK);
 }