I'm making a pacman game and at the moment my pacman is moving within the allowed coordinates of the map when I press the right, left, up or down arrow key. It is only moving when I hold the key down. I was wondering how I could do this so that he moves automatically on the key press until he hits the wall in the map, so that I don't need to hold the arrow down.
This is
if (e.KeyCode == Keys.Down)
{
if (coordinates[(pac.xPosition + 16) / 20, (pac.yPosition + 20) / 20].CellType == 'o'
|| coordinates[(pac.xPosition + 16) / 20, (pac.yPosition + 20) / 20].CellType == 'd'
|| coordinates[(pac.xPosition + 16) / 20, (pac.yPosition + 20) / 20].CellType == 'p')
{
pac.setPacmanImage();
pac.setPacmanImageDown(currentMouthPosition);
checkBounds();
}
The cell types o, p and d are the only cells he is allowed to move on within the map. These cells are being drawn within a textfile.
Sorry if it is hard to understand what I am asking but I am sure it is a fairly simple explanation.
Thank you in advance.