Sorry I want to delete my post
Not sure what your question is here, I just see a few fragments of code.
Nobody is going to retype a Pac Man tutorial for you in this little box.
I suggest either finding a good tutorial for Pac Man (which may not exist), or else working on it one step at a time, exactly like this guy:
Imphenzia: How Did I Learn To Make Games: