
-----------------------------------
PJ_69
Wed Feb 15, 2006 12:56 pm

Need some help....
-----------------------------------
I need some help in Pacman  I have this code on how to make him move by himelf, the animation of him moving basically wihout commands. Now, what I want to do is: make the pacman move by the arrow keys. Currentyl the pacman moves from left to right. I also need help in makeing him move up down with his mouth facing the direction he is traveling. So basically I need the pacman to move in all directions, with his mouth facing the direction of him traveling by using his arrow keys.

Thank you for helping me with this. Any help that you provide will be greatley appreciated by me and my friends who need this.

THANK YOU!

This is the code that I have btw:

var x, y : int := 20                    % x and y of Pacman's centre
var dx, dy : int                        % direction Pacman moves
dx := 1                                 % Pacman will move to the right
dy := 0                                 % Pacman will not be going up or down
var mouth : int := 0                    % size of mouth
var dir : int := 0                      % mouth direction, 0=right, 90=up, etc.
loop
   mouth := mouth mod 45 + 1            % change size of the mouth
   drawfillarc(x, 240, 20, 20, mouth + dir, -mouth + dir, yellow)
   delay(10)
   drawfillarc(x, 240, 20, 20, mouth+dir, -mouth + dir, white)
   x := x + dx                          % move Pacman's centre, depending on
   y := y + dy                          % the values of dx and dy
   exit when hasch                      % quit when user presses a key
end loop


-----------------------------------
MysticVegeta
Wed Feb 15, 2006 6:38 pm


-----------------------------------
1: Use Input.KeyDown rather than getch. 
2: Look up Pic.Rotate for the rotation of the pacman pic to make him look where hes heading

-----------------------------------
Clayton
Wed Feb 15, 2006 6:52 pm


-----------------------------------
ok 1 thing dont post "i need help...." titles, you are in the help forum so its obvious that you need the help dont do this again plz

-----------------------------------
tupac
Sat Feb 18, 2006 6:31 pm


-----------------------------------
k, wat u wana do is declare a variable called "go" or something, it will be an integer. then u make "go := 0". So now every time you press up or whatever, make go := 1. Then make an if statement that will say "if go = 1 then pacY{or whatever it is} += 1 end if" and so on. so now when you press a button the "go" variable will change, and it will keep being the same value until the pacman hits a wall (for example).
And also use "arra char of boolean" -- that is probably the best way to detect keystrokes.
Hope this was helpful for you  :)
