Need some help....
Author |
Message |
PJ_69
|
Posted: Wed Feb 15, 2006 12:56 pm Post subject: 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:
code: | 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
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Wed Feb 15, 2006 6:38 pm Post subject: (No subject) |
|
|
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 |
|
|
|
|
![](images/spacer.gif) |
Clayton
![](http://compsci.ca/v3/uploads/user_avatars/1718239683472e5c8d7e617.jpg)
|
Posted: Wed Feb 15, 2006 6:52 pm Post subject: (No subject) |
|
|
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 |
|
|
|
|
![](images/spacer.gif) |
tupac
![](http://compsci.ca/v3/uploads/user_avatars/4505289784b82e037a6d87.jpg)
|
Posted: Sat Feb 18, 2006 6:31 pm Post subject: (No subject) |
|
|
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 ![Smile Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
|
|