Original Post
Hello,
I have a map made out of 16x16 tiles. The game character is 32x32. Here's a screenshot to give you an idea:
http://img442.images.../i/pacmant.jpg/
I also use an 2d array to store the walls=0 and coins=1, (a part of it looks like this)
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1
0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1
0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1
0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1
0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,0
0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,0
Here are some of my methods that I use for pacman movement:
http://pastie.org/pr...dy3ddldep7ic9sq
(Its written in Ruby, but it should be easy to understand I guess)
PROBLEM:
When I have the @vel instance variable set to 16, Pacman moves correctly (16 pixels per move). He never bumps too far into any of the walls, but the downside is that he moves WAY too fast.
I decided to allow movement per 1 pixel, but with the current code, he can eat into the bottom and right walls like this:
http://img545.images...s/i/paceat.jpg/
I solved it partially: before checking if the new coordinates are correct, I changed the can_move_to? method to this:
http://pastie.org/pr...0zw4vm759bb9i5a //uglyness alert
He wouldn't eat the right and bottom walls anylonger, but still, he wasn't as precise as he was when he moved by 16 pixels each. I still could manage to eat a few pixels here and there (especially on corners).
What should I to to slow him down? And at the same time, how to make him as precise as he was when he moved 16 pixels each step?
Thanks
I have a map made out of 16x16 tiles. The game character is 32x32. Here's a screenshot to give you an idea:
http://img442.images.../i/pacmant.jpg/
I also use an 2d array to store the walls=0 and coins=1, (a part of it looks like this)
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1
0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1
0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1
0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1
0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,0
0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,0
Here are some of my methods that I use for pacman movement:
http://pastie.org/pr...dy3ddldep7ic9sq
(Its written in Ruby, but it should be easy to understand I guess)
PROBLEM:
When I have the @vel instance variable set to 16, Pacman moves correctly (16 pixels per move). He never bumps too far into any of the walls, but the downside is that he moves WAY too fast.
I decided to allow movement per 1 pixel, but with the current code, he can eat into the bottom and right walls like this:
http://img545.images...s/i/paceat.jpg/
I solved it partially: before checking if the new coordinates are correct, I changed the can_move_to? method to this:
http://pastie.org/pr...0zw4vm759bb9i5a //uglyness alert
He wouldn't eat the right and bottom walls anylonger, but still, he wasn't as precise as he was when he moved by 16 pixels each. I still could manage to eat a few pixels here and there (especially on corners).
What should I to to slow him down? And at the same time, how to make him as precise as he was when he moved 16 pixels each step?
Thanks