
-----------------------------------
BladeOfDeath
Wed Dec 17, 2003 8:33 pm

My ISP, need whatdotcolor help...
-----------------------------------
Well I'm making pacman, now i just need to know how to make him stop moving when he hits the blue (color no.1) walls... I have something for the controls already...

Its something like
process movePac
    getch (reply)
    mthChange := 2
    loop
        if hasch then
            getch (reply)
        else
            reply := reply
        end if
        if reply = chr (200) then
            clrPac (pacX, pacY)
            pacYchange := pacYchange + 2
            pacUp (pacX, pacY) %previously declared procedure for pacman facing upwards.
        elsif reply = chr (208) then
            clrPac (pacX, pacY)
            pacYchange := pacYchange - 2
            pacDown (pacX, pacY)%previously declared procedure for pacman facing downwards.
        elsif reply = chr (205) then
            clrPac (pacX, pacY)
            pacXchange := pacXchange + 2
            pacRgt (pacX, pacY)%previously declared procedure for pacman facing to the right.
        elsif reply = chr (203) then
            clrPac (pacX, pacY)
            pacXchange := pacXchange - 2
            pacLeft (pacX, pacY)%previously declared procedure for pacman facing to the left.
        end if
        delay (10)
        mthCls := mthCls + mthChange
        if mthCls = 30 or mthCls = -6 then
            mthChange *= -1
        end if
    end loop
end movePac

-----------------------------------
Thuged_Out_G
Thu Dec 18, 2003 12:12 am


-----------------------------------
if whatdotcolor(x,y)=1 then
code to stop pacman from moving
end if

where x is the x coordinate of the wall, and y is the y coordinate of the wall

-----------------------------------
BladeOfDeath
Thu Dec 18, 2003 4:45 pm


-----------------------------------
I need to know the code to make him stop. And the  walls are a maze so it would be like 3000 if statements. Please help me I need this for tomorrow.

-----------------------------------
Thuged_Out_G
Thu Dec 18, 2003 5:53 pm


-----------------------------------
maybe paste your code so we can look at it, and im sure someone will know how to make it stop when it hits a wall, although no one will do it for you

-----------------------------------
BladeOfDeath
Thu Dec 18, 2003 8:08 pm


-----------------------------------
here it is...

-----------------------------------
AsianSensation
Thu Dec 18, 2003 9:19 pm


-----------------------------------
well, pacman can only move vertically or horizontally right? Well, then, since you don't need rotation or nothing, just use the most simplest raycasting idea. Make the map, draw pacman, and once during the loop, "cast" a "ray" from pacman and toward the direction he is facing, and since you can only face left, right, up or down, you only have to deal with lines that are either up and down, or left and right, which is easy. Check the distance from pacman to the closest wall, if the distance is 0, than pacman no longer moves forward.

this method is much much better than whatdotcolor. And besides, raycasting is considered advanced programming, so do a simple raycasting and then later on you can do real raycasting.

-----------------------------------
BladeOfDeath
Thu Dec 18, 2003 9:39 pm


-----------------------------------
but for grade 10, I can only use the DOS version of turing. She approved of me using fork and View.Update though. So if any one of you can help me out, it would be greatly appreciated.

-----------------------------------
AsianSensation
Fri Dec 19, 2003 12:33 am


-----------------------------------
when doing raycasting, all the stuff is in your head, you are not actually drawing real lines or anything, you are drawing imaginary lines. Like binary trees, they don't exist like a tree inside your computer, it's how we imagine it to be. 

as I said, just check for the distance of pacman and the closest wall, the distance formula should be easy enough (they do teach that in gr 10, I know, I passed  :D )

-----------------------------------
Andy
Fri Dec 19, 2003 10:13 am


-----------------------------------
Why are you bothering with whatdotcolor?? thats for n00bs

-----------------------------------
BladeOfDeath
Sat Dec 27, 2003 2:17 am


-----------------------------------
because I have to for my ISP or my teacher wont mark it!!! I'm not allowed to use any OOT stuff except for process and fork. Everything else has to be DOS style which means i have to use whatdotcolor...

-----------------------------------
Tony
Sat Dec 27, 2003 2:32 am


-----------------------------------
I think you ment "OOP"... and that has nothing to do with anything else. It's just a style of programming that involves modeling objects and manipulating them.

as for pacman - use math instead of whatdotcolor

-----------------------------------
recneps
Sat Dec 27, 2003 12:28 pm


-----------------------------------
start him off inside a box or something, when he gets to the edge....
if x >maxx then x:=maxx
elsif xmaxy then y:=maxy
elsif y