WPF C# Tutorial – Make a PAC MAN Game in Visual Studio

In this tutorial we will make a fun PAC man game in visual studio using WPF and C# programming. This will be a fun game to make inside of visual studio because we will use all stock components of WPF and we will not be using any third-party libraries to make this game. We will be using lots and lots of rectangles and use C# identify and interact with different ones through out this game. We will custom code all of the elements inside of this game including the Pac man movements, wall collision, collision with ghosts and ghosts’ movements. The main objective of this game is to collect all of the coins inside of it and avoid the ghosts.

We will create solid walls inside of this game so you will not be able to go over them in all 4 directions, so if the player is moving left and hits the wall then it stop, if the player is moving right and hits the wall it stop and so on. Also you we will program the collision between the coins and the ghosts. This will be a fun tutorial so lets get started

Lesson Objectives –

  • Make a simple PAC Man Game in Visual Studio Using WPF and C#
  • Move Pac man character in one direction at a time
  • Stop the pac man character from going over the walls in all 4 direction
  • Collect coins in the game
  • Collide with Ghosts
  • Animate ghosts going left to right inside of the game loop
  • Restart the game when player collides with the ghosts or collects all the coins

Video Tutorial

Download The Images for this game


XAML Code –




C# Code for the game – All the lines are commented and explained inside of the code




Comment on this tutorial and let us know how you got on -