PACMANCODE

PACMANCODEPACMANCODEPACMANCODE
  • Home
  • Start
    • Vectors
    • Stacks
    • Blank Screen
    • Basic Movement
  • Level 1
    • Nodes
    • Node Movement (Part 1)
    • Node Movement (Part 2)
    • Node Movement (Part 3)
  • Level 2
    • Maze Basics
    • Pacman Maze
    • Portals
    • Pellets
    • Eating Pellets
  • Level 3
    • Ghosts Intro
    • Ghost Setup
    • Ghost AI
    • Modes
    • Ghost Home
    • Freight Mode
    • Spawn Mode
  • Level 4
    • More Ghosts
    • Start Positions
    • Fruit
    • Pausing
    • Level Advancing
    • Death to Pacman
    • Node Restrictions
  • Level 5
    • Text
    • Sprites
    • Life Icons
    • Graphical Mazes
    • Graphical Mazes Part 2
    • Animate Pacman
    • Animate Ghosts
  • Level 6
    • Pacman Death
    • Level Flash
    • More Fruit
    • More Mazes
  • Level 7
    • Add Title Screen
    • Add Buttons
    • Add Sound/Music
  • Contact
  • More
    • Home
    • Start
      • Vectors
      • Stacks
      • Blank Screen
      • Basic Movement
    • Level 1
      • Nodes
      • Node Movement (Part 1)
      • Node Movement (Part 2)
      • Node Movement (Part 3)
    • Level 2
      • Maze Basics
      • Pacman Maze
      • Portals
      • Pellets
      • Eating Pellets
    • Level 3
      • Ghosts Intro
      • Ghost Setup
      • Ghost AI
      • Modes
      • Ghost Home
      • Freight Mode
      • Spawn Mode
    • Level 4
      • More Ghosts
      • Start Positions
      • Fruit
      • Pausing
      • Level Advancing
      • Death to Pacman
      • Node Restrictions
    • Level 5
      • Text
      • Sprites
      • Life Icons
      • Graphical Mazes
      • Graphical Mazes Part 2
      • Animate Pacman
      • Animate Ghosts
    • Level 6
      • Pacman Death
      • Level Flash
      • More Fruit
      • More Mazes
    • Level 7
      • Add Title Screen
      • Add Buttons
      • Add Sound/Music
    • Contact

PACMANCODE

PACMANCODEPACMANCODEPACMANCODE
  • Home
  • Start
    • Vectors
    • Stacks
    • Blank Screen
    • Basic Movement
  • Level 1
    • Nodes
    • Node Movement (Part 1)
    • Node Movement (Part 2)
    • Node Movement (Part 3)
  • Level 2
    • Maze Basics
    • Pacman Maze
    • Portals
    • Pellets
    • Eating Pellets
  • Level 3
    • Ghosts Intro
    • Ghost Setup
    • Ghost AI
    • Modes
    • Ghost Home
    • Freight Mode
    • Spawn Mode
  • Level 4
    • More Ghosts
    • Start Positions
    • Fruit
    • Pausing
    • Level Advancing
    • Death to Pacman
    • Node Restrictions
  • Level 5
    • Text
    • Sprites
    • Life Icons
    • Graphical Mazes
    • Graphical Mazes Part 2
    • Animate Pacman
    • Animate Ghosts
  • Level 6
    • Pacman Death
    • Level Flash
    • More Fruit
    • More Mazes
  • Level 7
    • Add Title Screen
    • Add Buttons
    • Add Sound/Music
  • Contact

Adding a Title Screen

Most, if not all, games have some form of title screen.  This is basically just a screen that shows up when you start the game.  There may be a few options to select from before starting the game as well.  To keep things simple, we'll simply add a screen that just says "PACMAN" at the top.  Then when we press the "Return" key on the keyboard the Pacman game will start.  If/when we lose all of our lives in the game, then we'll automatically be returned to the title screen.  We can then press the "Return" key again to have another go, or just quit the game.  

In the next section we'll add a button that we can press instead of pressing the "Return" key.  

Everything we'll be doing in this section will be in the run.py file.  First of all, you may notice that the code is not highlighted like in the previous code snippets.  That's because it seems that I have lost the program that I wrote to wrap up my code in all of these "span" tags in order to apply the CSS to them.  If I find it then I'll update, but at this point in time I'm not going to rewrite that.  There's probably a simpler way to do this.  


Anyways, we will only have 2 screens, the title screen and the game screen.  So we're going to create a variable called "title_screen" and set it to True.  That way the rest of our code will know what to display based on this variable.  

Next we're calling a method we have not created as of yet.  We'll do that next.  

Finally, we'll create the title text that we want to appear at the top.  Be aware, that the position values here are "hard-coded".  You can place the title wherever you want on the screen by modifying the last two numbers since they represent that x and y positions respectively.  I'm just using these values because it looks good enough for demo purposes.

Here's the other new method that we're calling from the previous method.  There's nothing new here, just setting the background to Black.

Now you just need to make all of the changes below.  I know that it may be hard to read.  I'm trying to find the code that I had written a long time ago to color code everything for easier reading.  I'll swap this out as soon as I find it though.  In the meantime, just check what you have and add anything that is missing from here.



Downloads

0-Start_Screen (zip)Download

Copyright © 2025 Pacmancode - All Rights Reserved.


Powered by