Q: Check pacman movement I am making pacman game but this is something that I don't know how to do:
When the pacman hits the food, the food should disappear. My code is not working. Here is the function for initializing the food world:
 namespace pacman
{
public partial class Form1 : Form
{
    Timer timer;
    Pacman pacman;
    static readonly int TIMER_INTERVAL = 250;
    static readonly int WORLD_WIDTH = 15;
    static readonly int WORLD_HEIGHT = 10;
    Image foodImage;
    bool[][] foodWorld;

    public Form1()
    {
        InitializeComponent();

        foodImage = Properties.Resources.foodImage;
        DoubleBuffered = true;
        newGame();
    }

    public void newGame()
    {
        pacman = new Pacman();
        this.Width = Pacman.radius * 2 * (WORLD_WIDTH + 1);
        this.Height = Pacman.radius * 2 * (WORLD_HEIGHT + 1);
         // овде кодот за иницијализација на матрицата foodWorld

        foodWorld = new bool[WORLD_WIDTH][];
        for (int i = 0; i < WORLD_WIDTH;i++ )
        {
            foodWorld[i] = new bool[WORLD_HEIGHT];
        }

        for (int i = 0; i < WORLD_WIDTH; i+=2) {
            for (int j = 0; j < WORLD_HEIGHT; j++) {

                foodWorld[i][j] = true;

            }
        }

        // овде кодот за иницијализација и стартување на тајмерот
        timer = new Timer();
        timer.Interval = TIMER_INTERVAL;
        timer.Tick += new EventHandler(timer_Tick);
        timer.Start();
    }

    void timer_Tick(object sender, EventArgs e)
    {
        // овде вашиот код
        timer.Interval = TIMER_INTERVAL - 1;
        if (TIMER_INTERVAL == 0)
        {
            timer.Stop();
        }

        for (int i = 0; i < WORLD_WIDTH; i++) {

            for (int j = 0; j < WORLD_HEIGHT; j++) {

                if (pacman.x == i && pacman.y == j && foodWorld[i][j])
                {

                    foodWorld[i][j] = false;
                    this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
                    pacman.open = true;
                }
                else {

                    pacman.open = false;
                }
            }
        }

        pacman.Move(WORLD_WIDTH, WORLD_HEIGHT);
        Invalidate();
    }

    private void Form1_KeyUp(object sender, KeyEventArgs e)
    {
        // не заборавајте да го додадете настанот на самата форма
        // вашиот код овде
        if (e.KeyCode == Keys.Up) {

            pacman.ChangeDirection("UP");
        }
        if (e.KeyCode == Keys.Down)
        {

            pacman.ChangeDirection("DOWN");
        }
        if (e.KeyCode == Keys.Left)
        {

            pacman.ChangeDirection("LEFT");
        }
        if (e.KeyCode == Keys.Right)
        {

            pacman.ChangeDirection("RIGHT");
        }

        Invalidate();
    }

    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        Graphics g = e.Graphics;
        g.Clear(Color.White);
        for (int i = 0; i < foodWorld.Length; i++)
        {
            for (int j = 0; j < foodWorld[i].Length; j++)
            {
                if (foodWorld[i][j])
                {
                    g.DrawImageUnscaled(foodImage, j * Pacman.radius * 2 + (Pacman.radius * 2 - foodImage.Height) / 2, i * Pacman.radius * 2 + (Pacman.radius * 2 - foodImage.Width) / 2);
                }
            }
        }
        pacman.Draw(g);

    }

}
   }

What should I change so the picture that is touched by the pacman disappears?

A: When pacman eats the food, you have this:
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);

This syntax is a subscription to the Paint event. You should have done that once and only once. Instead, use:
this.Invalidate();

The call to Invalidate tell the operating system, "Hey, I need to be re-painted!". The operating system will then generate the event which ultimately triggers the Paint event and executes your paint code.
