Movement for pacman

This forum is currently in read-only mode.
0 favourites
From the Asset Store
Explore and retrieve all Magical Books from the hidden Orc's Lair in this "PacMan-styled" game.
  • I am trying to make a pacman game. How do I get my ghosts to move in straight lines and then moves up or down if they hit a wall. When I used bullet, they went through all the solid walls.

    Is there a manual page that describes all the behaviour options?

  • use an "on collision with wall" event to change the ghosts direction.

    No manual yet, just the wiki, the forums and chat.

  • Bullet always moves forward, and forward is dependent on the sprite's angle. By default, sprites face 90 degrees, or right. 0 is up, 180 is down, and 270 is left.

    You can keep bullet on the ghost, and manually do this with events. On collision with wall:

    If current angle is 90 or 270, randomly change angle to 0 or 180.

    Else if current angle is 0 or 180, randomly change angle to 90 or 270.

    That's all. Please keep that else in mind, it is important. If you start at 90 degrees and go through this block without the else, the first event would change you to 0, and the second would change you back to 90, the else makes sure only one of them fires, instead of the possibility of them both firing in sequence like that.

  • How would I set an angle to a random option of 90 or 270?

  • You could always try Rojohounds pathmovement plugin.It's ideal for a pacman type game.

  • Thanks for that but I am doing this for a school lab and I want to use only the default install.

    I've basically got the ghost movement right but have a problem when it moves alongside a wall. Even though I've aligned the blocks for the wall the Ghost appears to collide with it and then make a random turn i.e. it won't travel next to a wall for long.

    This will make more sense if you run my file a few times: http://www.rosmini.school.nz/downloads/pacman.cap

  • How would I set an angle to a random option of 90 or 270?

    90+(Random(2)*180)

    I believe Random(2) will give you 0 or 1, unless they changed the indexing on me, so that will either give you 90 + 0 or 90 + 180. 90 or 270 respectively.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks, that's great... I've made the change but now if you run my program for a while you will see that the ghost sometimes goes through the wall.

    [quote:2527u6h2]This will make more sense if you run my file a few times: http://www.rosmini.school.nz/downloads/pacman.cap

  • You are missing two things that the AI needs to function properly. Also, it would really help if the ghost was the same size as the tiles.

    First of all, you need to keep track of the angle of the ghost, so you know which direction it's moving in. Second of all, you need to check in the direction you're about to move with an overlap at offset check, before you move in that direction. Right now you change directions at random without making sure there's a wall in that direction first.

  • random(2) will give you 0,1 or 2 from what I've seen so far. Maybe that requires a little messing around with .caps.

  • [quote:ikm9x27w]random(2) will give you 0,1 or 2 from what I've seen so far. Maybe that requires a little messing around with .caps.

    Ok then would this be better? random(1)+1

    [quote:ikm9x27w]First of all, you need to keep track of the angle of the ghost, so you know which direction it's moving in. Second of all, you need to check in the direction you're about to move with an overlap at offset check, before you move in that direction. Right now you change directions at random without making sure there's a wall in that direction first.

    I'm now tracking the direction but the offset doesn't appear to work.... or more correctly, I don't seem to understand it.

    I've updated http://www.rosmini.school.nz/downloads/pacman.cap

  • In Construct Random(2) will return 0 or 1, but not 2.

    A way that's simpler than checking for overlap at offset, just check for overlap. If it's true, undo the last movement and rotate 90 or -90.

    + Ghost: Ghost overlaps Wall
    -> Ghost: Move 0-Ghost[Bullet].Speed*TimeDelta pixels at Ghost.Angle degrees
    -> Ghost: Rotate {90,-90} @ (Random(2)+1) degrees clockwise
    [/code:33czl20k]
  • [cut]

    You could enhance the AI developing a wall detection engine, using Custom Movement behavior.

    For example:

    http://www.box.net/shared/dyhh7oadnf

  • Proper arcade pacman movement

    http://dl.dropbox.com/u/6134248/pacmanmovemen.cap

  • Hi, when I try and open it, I get an out of memory error.

    Cheers

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)