User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Please help me with creating this Pac-Man movement

  1. #1
    Clicker Multimedia Fusion 2

    Join Date
    Jul 2010
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Please help me with creating this Pac-Man movement

    Hi everyone!

    I just recently finished reading through the manual of the Games Factory 2 and have just started my first project. It's a sort of Pac-Man game, but with different features. Anyway, I have been trying to create the movement for the player since two days now, and its still not working. I want to achive the following things:

    - The game-field is entirely made of 64x64 pixel squares. When the player presses a directional button, Pac-Man should start moving towards that direction until he either hits an obstacle or the player presses a fifferent directional button. However, when a different directional button is pressed, Pac-Man must wait until he is aligned to the grid before he starts moving in a different direction. This means that the player does not need to press the button in the exact right moment. Pacman just moves in the direction of the lastly pressed button as soon as he is aligned to the grid.

    - If the player presses a directional button, after being aligned to the grid, Pac-Man must first check if he can move in the pressed direction or if there is an obstacle. If there is an obstacle, pacman must ignore the fact that the player just pressed that button and must continue moving in the direction he was moving in so far.

    I haven't attempted achieving my second goal so far, but I actually haven't even been able to achive my first goal yet. I am going to describe now exactly how I have programmed the movement so far and hope that someone can tell me soon what I am doing wrong:

    10 if "left arrow" is pressed, start loop "wait" for 64 times, set the internal flag 1 of "player" to on and set the other flags to off

    20 if "right arrow" is pressed, start loop "wait" for 64 times, set the internal flag 2 of "player" to on and set the other flags to off

    30 if "up arrow" is pressed, start loop "wait" for 64 times, set the internal flag 3 of "player" to on and set the other flags to off

    40 if "down arrow" is pressed, start loop "wait" for 64 times, set the internal flag 4 of "player" to on and set the other flags to off

    loop "wait" start

    50 if (counter = 0), stop loop "wait" and activate group "decidepath"

    60 otherwise, add 0 to the counter every 00"-20 (this is just to make the loop wait for the current movement to finish)

    loop "wait" end

    group "decidepath" start

    70 if internal flag 1 of "player" is on, activate group "Move Left" and deactivate all other groups

    80 if internal flag 2 of "player" is on, activate group "Move Right" and deactivate all other groups

    90 if internal flag 3 of "player" is on, activate group "Move Up" and deactivate all other groups

    100 if internal flag 4 of "player" is on, activate group "Move Down" and deactivate all other groups

    group "decidepath" end

    group "Move Left" start

    110 if internal flag 1 of "player" is on, start loop "left" for 64 times

    120 if (counter = 64), stop loop "left" and set the counter to 0

    loop "left" start

    130 if "player" is overlapping a backdrop, stop loop "left", move "player" 1 pixel to the right and set the counter to 0

    140 Every 00"-20, move "player" 1 pixel to the left and add 1 to the counter

    loop "left" end

    group "Move Left" end

    I'm not gonna write down the other groups, because you can already get the idea. I'd really like to upload my MFA-file, so you can have a closer look at what I have done and test it for yourself, but I can't find any upload button here.

    I hope it is understandable what I was trying to achieve in the above code. I know that some extra explanation would definitely be useful, but unfortunately I have to go now. If there is anything unclear, then I'm gonna explain it later. I hope nonetheless, that at least someone can help me with my problem as soon as possible, because I desperately need a solution!

    Thank you very much!

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Please help me with creating this Pac-Man movement

    I can't understand your code at all, that is not even how the event system works or how fastloops work. You should watch the fastloop tutorial (Tutorial link on the sidebar to the right --->) and also write the code as you see it in the event editor.

    You can upload files to the "File Archive" forum by using a little link under the post form that says "File Manager"
    Working as fast as I can on Fusion 3

  3. #3
    Clicker Multimedia Fusion 2

    Join Date
    Jul 2010
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Please help me with creating this Pac-Man movement

    Thank you LB!

    OK, here is the download-link for the MFA-file: http://www.clickteam.com/epicenter/ubbthreads.php?ubb=download&Number=5203&filename=p ac_family_copy02.mfa

    Sorry for my incomprehencive previous post. I know that thats not how the event system or fast loops work, but I tried to write my code here in a way that is easier to read. For example, instead of grouping the fast loops, I could have started each of the lines of each of the loops with "On loop "name of the loop"", or instead of writing "move "player" 1 pixel to the left", I could have written "Set X position to X("player")-1", but I just thought writing "move one pixel to the left" or grouping loops would make reading the code easier.

    I'm now gonna try to explain my code:

    Each time a directional button is pressed, a group of events must be executed for that direction. However, if the player presses a directional button while a group of events is being executed for the previously pressed direction, the program must wait until all the events for the previous direction have been executed before executing the events for the lastly pressed direction. This is why I have used the "wait" loop. The "wait" loop is supposed to do the following thing:

    - If the counter is equal to 0, it is an indication that executing the events for the lastly pressed direction is allowed. So, in case the counter is equal to 0, the loop "wait" can be stopped and the according group for the lastly pressed directional button must be executed.

    - If the counter is NOT equal to 0, it means that the program must wait until the counter becomes 0. So, in this case, the program should wait for 20 centiseconds and then repeat the loop "wait".

    After the loop "wait" is stopped, it must be checked in which direction the player wants to move. This is what the group "decidepath" is supposed to do. It starts the oppropriate group of events according to the internal flag that is set to "on" by the lastly pressed button.

    When Pac-Man starts to move, he is supposed to move 64px, then check if a different directional button is pressed or not, and if not, he must continue moving another 64px in the current direction. The moment when it is checked whether a different directional button is pressed or not, is when the counter equals 0. This check is done by the "wait" loop, which is explained above. If the counter is NOT equal to 0, Pac-Man continues his 64px movement. This is how I have tried to achieve this goal in the group of events for the according direction:

    - At the start of this group of events, start the loop for this direction for 64 times.

    - If the counter is equal to 64, stop the loop for this direction and set the counter to 0.

    - On loop: If Pac-Man is overlapping with an obstacle, stop the loop for this direction, move Pac-Man one pixel to the opposite direction (so that he is no more overlapping with the obstacle) and set the counter to 0.

    - On loop: After 20 centiseconds, move Pac-Man one pixel in this direction and add 1 to the counter. (This is how I have tried to make Pac-Man move 64px each time. It's with the help of the counter.)

    OK, I hope my code is more understandable now. :P But actually, what I really want to know, is how to create the Pac-Man movement. I have looked through the tutorials on this web-site and I was surprised to find that there is no tutorial for creating a Pac-Man game (or at least I coudn't find it). If you have any suggestions for creating the Pac-Man movement, even if it is totally different from the method that I have tried here, PLEASE tell me! I welcome any type of coding, as long as my Pac-Man gets to move like the real Pac-Man! So actually you can completely ignore the above code and suggest to me something completely different.

    Many thanks in advance to anyone for any help!

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleSWF Export ModuleXNA Export Module

    Join Date
    Jun 2007
    Posts
    480
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Please help me with creating this Pac-Man movement

    WOW nice, you are big story writer

    no working with fastloop please

  5. #5
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Please help me with creating this Pac-Man movement

    Yeah in your case you don't even need to have fastloops the way you think at all

    I'll check your MFA and see if I can modify it or make another example for you.

    EDIT: I ended up making an example. It will take some work but here is the basic idea for you.
    http://mfa.aquadasoft.com/view/1278524227-PacmanMovement
    Working as fast as I can on Fusion 3

  6. #6
    Clicker Multimedia Fusion 2

    Join Date
    Jul 2010
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Please help me with creating this Pac-Man movement

    Thank you very much for your help, LB! But I still got one problem: In your example, the active object jumps from place to place. How could I achieve this same movement, but having my active object seemingly move smoothly?

  7. #7
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Please help me with creating this Pac-Man movement

    You can make the jumpy object invisible and make the real one follow it instead
    Working as fast as I can on Fusion 3

  8. #8
    Clicker Multimedia Fusion 2

    Join Date
    Jul 2010
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Please help me with creating this Pac-Man movement

    Aaaaah, thats a very cool idea! Thank you very much, you've been a great help!

  9. #9
    Clicker

    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jun 2006
    Location
    Killeen, TEXAS
    Posts
    1,038
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Please help me with creating this Pac-Man movement

    i wrote a pacman tutorial:
    http://www.acoders.com/acsite/forums_readtopic.php?id=2879

  10. #10
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,731
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Re: Please help me with creating this Pac-Man movement

    danjo, that is a nice tutorial.

    Marv
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Movement synchronization issues (physics spaceship movement)
    By SecondSons in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 24th January 2014, 11:52 PM
  2. Platform movement on Active objects using Nifflas' basic movement widget
    By ac3raven in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 18th October 2012, 03:16 AM
  3. Spaceship movement left and right trought bouncing ball movement instead 8 direction?
    By daryuss in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 22nd May 2012, 10:33 PM
  4. Creating Simple Movement
    By Newbie56 in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 29th December 2010, 08:47 AM
  5. Creating river city ransom/double dragon movement
    By Ransom in forum Multimedia Fusion 2 - Technical Support
    Replies: 13
    Last Post: 29th December 2008, 08:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •