YILAN OYUNU | C#
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Yilan_Oyunu__Yazilimcik_Com
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            lblPuan.Text = "0";
            Oyun.Load_Graphic();
            Oyun.uz = 17;
            Oyun.j = 17;
            Oyun.x = 10;
            Oyun.y = 10;
            Oyun.yem.X = -1;
            Oyun.yem.Y = -1;
            if (Oyun.bmp != null)
            {
                Oyun.yilanrengi = Brushes.Navy;
                Oyun.background = Brushes.Black;
                Oyun.yilanderirengi = Brushes.LightBlue;
                pbResim.Image = Oyun.bmp;
                pbResim.Refresh();
            }
            Oyun.rota = 2;
            Oyun.yemvar = false;
            Oyun.yemrengi = Brushes.DarkRed;
            Oyun.yemderirengi = Brushes.LightYellow;
            Oyun.puan = 0;
            Oyun.bekleint = 5;
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (Oyun.rota == 1) Oyun.move_yilan_left();
            if (Oyun.rota == 2) Oyun.move_yilan_rigth();
            if (Oyun.rota == 3) Oyun.move_yilan_up();
            if (Oyun.rota == 4) Oyun.move_yilan_down();
            Oyun.Draw_Yilan(Oyun.x, Oyun.y);
            Oyun.alanX[Oyun.j] = Oyun.x;
            Oyun.alanY[Oyun.j] = Oyun.y;
            Oyun.j++;
            Oyun.Bos_Draw_Yilan(Oyun.alanX[Oyun.j - Oyun.uz], Oyun.alanY[Oyun.j - Oyun.uz]);
            if (Oyun.j > 899)
            {
                Oyun.j = Oyun.uz;
                for (int z = 0; z 
                {
                    Oyun.alanX[Oyun.uz - z] = Oyun.alanX[900 - z];
                    Oyun.alanY[Oyun.uz - z] = Oyun.alanY[900 - z];
                }
            }
            if ((Oyun.yilan_esit_yem() == false) && (Oyun.yemvar == false))
            {
                Oyun.yem_koord_yerlestir();
                Oyun.yem_koy(Oyun.yem.X, Oyun.yem.Y);
            }
            if (Oyun.yilan_esit_yem() == true)
            {
                Oyun.yem.X = -1;
                Oyun.yem.Y = -1;
                Oyun.yemvar = false;
                Oyun.puan += 1;
                lblPuan.Text = Oyun.puan.ToString();
                Oyun.uz += 1;
            }
            pbResim.Image = Oyun.bmp;
            pbResim.Refresh();
            if (Oyun.yilan_kendisine_carptimi() == true)
            {
                timer1.Enabled = false;
                timer2.Enabled = true;
                if (Oyun.bekleint 
                {
                }
                else
                {
                    Oyun.bekleint = 20;
                }
            }
            if (Oyun.x > 40) Oyun.x = 0;
            if (Oyun.x < 0) Oyun.x = 40;
            if (Oyun.y > 40) Oyun.y = 0;
            if (Oyun.y 
        }
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Left) Oyun.rota = 1;
            if (e.KeyCode == Keys.Right) Oyun.rota = 2;
            if (e.KeyCode == Keys.Up) Oyun.rota = 3;
            if (e.KeyCode == Keys.Down) Oyun.rota = 4;
            if (e.KeyCode == Keys.Escape) Application.Exit();
            Oyun.bekleint = 20;
            timer2.Enabled = false;
            timer1.Enabled = true;
        }
        private void baslatToolStripMenuItem_Click(object sender, EventArgs e)
        {
            timer1.Interval = 100;
            timer1.Enabled = true;
        }
        private void bitirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;
        }
        private void timer2_Tick(object sender, EventArgs e)
        {
            Oyun.bekleint--;
            if (Oyun.bekleint == 0)
            {
                timer2.Enabled = false;
                Oyun_Bitir();
            }
        }
        public void Oyun_Bitir()
        {
            timer1.Interval = 100;
            timer1.Enabled = false;
            MessageBox.Show("Oyun Bitti.. Puan :" + lblPuan.Text, "Bilgi:");
            Oyun.Oyun_reset();
            Oyun.Load_Graphic();
            Oyun.yemvar = false;
            timer1.Enabled = true;
        }
    }
}
Oyun.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
namespace Yilan_Oyunu__Yazilimcik_Com
{
    class Oyun
    {
        public static int[] alanX = new int[1000];
        public static int[] alanY = new int[1000];
        public static int[] yilanX = new int[1000];
        public static int[] yilanY = new int[1000];
        public static System.Drawing.Bitmap bmp;
        public static System.Drawing.Graphics gfx;
        public static System.Drawing.Rectangle rect;
        public static System.Drawing.Brush yilanrengi;
        public static System.Drawing.Brush yilanderirengi;
        public static System.Drawing.Brush yemrengi;
        public static System.Drawing.Brush yemderirengi;
        public static System.Drawing.Brush background;
        public static int uz, j;
        public static int x, y;
        public static System.Drawing.Point yem = new System.Drawing.Point();
        public static bool yemvar;
        public static int puan;
        public static int rota;
        public static int bekleint;
        public static void Draw_Yilan(int x, int y)
        {
            gfx.FillRectangle(yilanrengi, x * 10, y * 10, 10, 10);
            gfx.FillRectangle(yilanderirengi, x * 10, y * 10, 8, 8);
        }
        public static void Bos_Draw_Yilan(int x, int y)
        {
            gfx.FillRectangle(background, x * 10, y * 10, 10, 10);
        }
        public static void Load_Graphic()
        {
            bmp = new System.Drawing.Bitmap(400, 400);
            gfx = System.Drawing.Graphics.FromImage(bmp);
            rect = new System.Drawing.Rectangle(0, 0, 400, 400);
            gfx.FillRectangle(System.Drawing.Brushes.Black, rect);
        }
        
        public static void move_yilan_rigth()
        {
            Oyun.x += 1;
        }
        public static void move_yilan_left()
        {
            Oyun.x -= 1;
        }
        public static void move_yilan_up()
        {
            Oyun.y -= 1;
        }
        public static void move_yilan_down()
        {
            Oyun.y += 1;
        }
        public static void yem_koy(int x, int y)
        {
            gfx.FillRectangle(yemrengi, x * 10, y * 10, 10, 10);
            gfx.FillRectangle(yemderirengi, x * 10, y * 10, 8, 8);
        }
        public static bool yilan_esit_yem()
        {
            bool b = false;
            for (int s = 0; s 
            {
                if ((yem.X == alanX[Oyun.j - s]) && (yem.Y == alanY[Oyun.j - s]))
                    b = true;
                else b = false;
            }
            return b;
        }
        public static void yem_koord_yerlestir()
        {
            Random rndX = new Random();
            yem.X = rndX.Next(38) + 1;
            Thread.Sleep(25);
            Random rndY = new Random();
            yem.Y = rndY.Next(38) + 1;
            yemvar = true;
        }
        public static bool yilan_kendisine_carptimi()
        {
            bool b = false;
            int x = Oyun.x * 10;
            int y = Oyun.y * 10;
            try
            {
                if (rota == 1)
                    if (bmp.GetPixel(x + 5, y + 5) == bmp.GetPixel(x - 5, y + 5))
                    {
                        b = true;
                    }
                    else b = false;
                if (rota == 2)
                    if (bmp.GetPixel(x + 5, y + 5) == bmp.GetPixel(x + 15, y + 5))
                    {
                        b = true;
                    }
                    else b = false;
                if (rota == 3)
                    if (bmp.GetPixel(x + 5, y + 5) == bmp.GetPixel(x + 5, y - 5))
                    {
                        b = true;
                    }
                    else b = false;
                if (rota == 4)
                    if (bmp.GetPixel(x + 5, y + 5) == bmp.GetPixel(x + 5, y + 15))
                    {
                        b = true;
                    }
                    else b = false;
            }
            catch (Exception e) { string str = e.Message.ToString(); return false; }
            return b;
        }
        public static void Oyun_reset()
        {
            alanX = null;
            alanY = null;
            alanX = new int[1000];
            alanY = new int[1000];
            Oyun.puan = 0;
        }
    }
}