
-----------------------------------
w00t
Sun Oct 23, 2005 5:30 pm

Pac-Man
-----------------------------------
Yes, If you do remember I have asked this question before, but i need some assistance with whatdotcolor in pacman. I know of Math.Distance and all but my teacher doesn't want us to use that yet. Does it make sense? No, but It's how im being marked. The kicker is that i have to learn whatdotcolor again and I forget it. For now pac-man is just a yellow circle that moves up down left right and the level is all drawn out in paint to save lines. When i use whatdotcoluor i check 1 px outside of pac-man for red or color 4 and he stops somewhat but then he moves to the side and i can't get my head around why it isn't working.

setscreen ("graphics:500;500")
setscreen ("nocursour;noecho")

var background : int := Pic.FileNew ("C:/Documents and Settings/Thom/Programs/pacman.bmp")
Pic.Draw (background, 0, 0, picMerge)
var key : string (1)
var x, y : int
x := 250
y := 200


drawfilloval (x, y, 7, 7, 14)
loop
    if whatdotcolour (x, y + 8) = 4 then
        y := y - 8
    elsif whatdotcolour (x, y - 8) = 4 then
        y := y + 8
    elsif whatdotcolour (x + 8, y) = 4 then
        x := x - 8
    elsif whatdotcolour (x - 8, y) = 4 then
        x := x + 8
    end if
    getch (key)
    if ord (key) = 205 then
        drawfilloval (x, y, 7, 7, 7)
        x := x + 7
    elsif ord (key) = 203 then
        drawfilloval (x, y, 7, 7, 7)
        x := x - 7
    elsif ord (key) = 200 then
        drawfilloval (x, y, 7, 7, 7)
        y := y + 7
    elsif ord (key) = 208 then
        drawfilloval (x, y, 7, 7, 7)
        y := y - 7
    end if
    drawfilloval (x, y, 7, 7, 14)
end loop


AS you can see it's pretty simple and short which i like but the whatdotcolor seems to be logical but im obviously missing something, maybe it's because im tired and im lacking red bull but any help would be nice. Pac man just hits the wall and stops but then goes right thru


- W00t

http://i7.photobucket.com/albums/y266/murdoc8888888/pacman.jpg


here is the level pic, sorry forgot to uplaod :)

-----------------------------------
beard0
Sun Oct 23, 2005 5:52 pm


-----------------------------------
Without your bmp, we can't test....

-----------------------------------
jamonathin
Sun Oct 23, 2005 6:01 pm


-----------------------------------
First of all, all i see is a white screen with a yellow pacman with a trail of black turd droppings.  Im guessing the image is the map.  There are several things that can be fixed with your coding, but we can worry about that later.  What it seems that your program does is check if the player is in red, then if he his, move his ass back.  Well why did he get there in the first place, why not check before we allow him to move there?


So what you can do is: (using moving right)

You have::

if ord (key) = 205 then 
        drawfilloval (x, y, 7, 7, 7) 
        x := x + 7 
Well first of all we only need one 'drawfilloval (x, y, 7, 7, 7)' and that can go before the whole if statement.  Secondly you can just do something like this.


if ord (key)=205 and whatdotcolor(x+7,y) not=4 then
x+=7 %same as x:=x+7
end if

try that out ;)

-----------------------------------
Mr. T
Sun Oct 23, 2005 6:31 pm

Alex's Opinion
-----------------------------------
I'd suggest making pacman's movements correspond to a grid.

-----------------------------------
w00t
Sun Oct 23, 2005 7:36 pm


-----------------------------------
You have::

if ord (key) = 205 then 
        drawfilloval (x, y, 7, 7, 7) 
        x := x + 7 
Well first of all we only need one 'drawfilloval (x, y, 7, 7, 7)' and that can go before the whole if statement.  Secondly you can just do something like this.


if i dont have it a yellow dot just appears behind pac man

-----------------------------------
jamonathin
Sun Oct 23, 2005 7:57 pm


-----------------------------------
This is what i ment by that
drawfilloval (x, y, 7, 7, 7)
    if ord (key) = 205 then
        x := x + 7
    elsif ord (key) = 203 then
        x := x - 7
    elsif ord (key) = 200 then
        y := y + 7
    elsif ord (key) = 208 then
        y := y - 7
    end if
    drawfilloval (x, y, 7, 7, 14)

And here's one main reason as to why pacman doesn't stop a t a wall and he bounces from side to side.  HE'S BIGGER THAN THE WALL!!!11 lol.  You needa bigger map man.  Or you can every sit 6 inches away from the screen and you can shrink pacman to fit the map.  Work on what i said earlier, and map pacman able to fit into the map :P

-----------------------------------
w00t
Sun Oct 23, 2005 8:00 pm


-----------------------------------
lol. i just saw that, it isn't that small, pac man does fit it's just my is smaller on photobucket
 
he does fit though,
