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
  • Final
    • Pacman Death
    • Level Flash
    • More Fruit
    • More Mazes
    • The End
  • 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
    • Final
      • Pacman Death
      • Level Flash
      • More Fruit
      • More Mazes
      • The End
    • 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
  • Final
    • Pacman Death
    • Level Flash
    • More Fruit
    • More Mazes
    • The End
  • Contact

Graphical Mazes Part 2

Basics

In the last section we got all of the maze sprites in their correct locations.  Problem is some of the sprites didn't look right because we need to rotate some of them.  Once we get those sprites rotated, we'll be able to turn off the nodes and then reposition Pacman and the ghosts.  

Maze Sprite Rotation File

The only way we can specify which maze sprite needs to be rotated we'll create another text file where it looks more or less like the maze1.txt file but this time it will contain values 0-3 which is what we'll use to know how much to rotate a sprite.  


This file tells how to rotate each sprite.  

0: no rotation

1: rotate 90 degrees

2: rotate 180 degrees

3: rotate 270 degrees

Maze Sprites

We'll modify the MazeSprites class so that we can rotate the sprites according to the file above.

GameController

All we need to do in the GameController class is include the maze1_rotation.txt file.

Remove the nodes

Now if you run the game you'll get something similar to what we see on the right.  Just like magic all of the maze sprites are oriented correctly.  We can go ahead and get rid of the nodes and lines now.  We won't actually get rid of them, we just won't draw them.  They're still there because they need to be for the game to work.  We just don't need to see them anymore. 

Position Adjustments

Now that looks a lot better.  Only thing now is that Pacman, the ghosts, and the pellets look off.  This is to be expected though, so we just need to adjust their positions.


Remember in a previous section I explained why they'll appear off when we start to use sprites?  I also explained how we were going to fix it.  So let's fix it now.  We need to fix Pacman, the ghosts, the fruit, and the pellets.

There!  Everything looks really good now.  You'll also notice that I reduced the size of the pellets.  They were too large before.  We had to make them that large because we wouldn't have been able to see them otherwise when we were drawing the nodes and the lines.  


It almost looks like our game is complete doesn't it?  There is one issue though.  Nothing animates.  Sure we can move Pacman around and the ghosts move around on their own as well, but we need to see Pacman actually opening and closing his mouth as he's moving around and also facing the direction he's moving.  That's all taken care of in the next section.

Downloads

5-Graphical_Mazes_2 (zip)Download
spritesheet_nopink (png)Download

Copyright © 2024 Pacmancode - All Rights Reserved.


Powered by GoDaddy Website Builder