Exemplo n.º 1
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            //Playground.CreateGraphics().Clear(Color.FromArgb(60, 0, 0, 0));
            //Playground.CreateGraphics().Clear(Color.Transparent); //narazie nie jestem w stanie zmusic go do przezroczytsosci po czyszczeniu

            //Playground.Invalidate();
            //Playground.Controls.Clear();
            Playground.CreateGraphics().Clear(Color.ForestGreen);
            //Playground.BackgroundImage = Properties.Resources.grassSmall;
            theSnake.move();
            theSnake.drawSnake(Playground.CreateGraphics(), Properties.Resources.snakepart);

            theFood.drawFood(Playground.CreateGraphics(), imageFood);
            if (theFood.needFood(theSnake.x[0], theSnake.y[0]))
            {
                theSnake.grow();
            }
            if (theSnake.isSnakeLife() == false)
            {
                is_start = false;
                Playground.CreateGraphics().Clear(Color.Black);
                timer1.Enabled = true;
                timer2.Enabled = false;
            }
        }
Exemplo n.º 2
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (is_start == false)
     {
         timer2.Enabled = false;
         FontFamily myFontFamily = new FontFamily("Arial");
         Font       myFont       = new Font(myFontFamily, 16);
         Brush      myBrush      = new SolidBrush(Color.Red);
         Playground.CreateGraphics().DrawString("Click START", myFont, myBrush, 80, 135);
     }
     else
     {
         Playground.CreateGraphics().Clear(Color.Transparent);
         Playground.BackgroundImage = Properties.Resources.grassSmall; //dodajemy tlo ze zrodla, zrodlo mozna zobaczyc w eksploratorze rozwiazan
         timer1.Enabled             = false;
         timer2.Enabled             = true;
     }
 }