Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 My ISP, need whatdotcolor help...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
BladeOfDeath




PostPosted: Wed Dec 17, 2003 8:33 pm   Post subject: 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
code:
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
Sponsor
Sponsor
Sponsor
sponsor
Thuged_Out_G




PostPosted: Thu Dec 18, 2003 12:12 am   Post subject: (No subject)

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




PostPosted: Thu Dec 18, 2003 4:45 pm   Post subject: (No subject)

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




PostPosted: Thu Dec 18, 2003 5:53 pm   Post subject: (No subject)

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




PostPosted: Thu Dec 18, 2003 8:08 pm   Post subject: (No subject)

here it is...
AsianSensation




PostPosted: Thu Dec 18, 2003 9:19 pm   Post subject: (No subject)

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




PostPosted: Thu Dec 18, 2003 9:39 pm   Post subject: (No subject)

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




PostPosted: Fri Dec 19, 2003 12:33 am   Post subject: (No subject)

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 Very Happy )
Andy




PostPosted: Fri Dec 19, 2003 10:13 am   Post subject: (No subject)

Why are you bothering with whatdotcolor?? thats for n00bs
BladeOfDeath




PostPosted: Sat Dec 27, 2003 2:17 am   Post subject: (No subject)

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




PostPosted: Sat Dec 27, 2003 2:32 am   Post subject: (No subject)

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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
recneps




PostPosted: Sat Dec 27, 2003 12:28 pm   Post subject: (No subject)

start him off inside a box or something, when he gets to the edge....
code:
if x >maxx then x:=maxx
elsif x<0 then x:=0
end if
if y >maxy then y:=maxy
elsif y<0 thne y:=0
end if

that makes it, so that if x is past maxx, then it becomes maxx (stops at the edge) and same with 0, and the same for y at the top and bottom.
you can go from there... just make simple walls, like a broken box or something. (make another box inside , but leave out the corners, or middles of each side)
hope this helps you a bit.
BladeOfDeath




PostPosted: Sat Dec 27, 2003 2:24 pm   Post subject: (No subject)

thats gonna end up as a lot of if statements with my maze... alright I dont want to start over and possibly get a 0.
AsianSensation




PostPosted: Sat Dec 27, 2003 3:54 pm   Post subject: (No subject)

as I stated previously, just check the how far pacman is from a wall in the direction that he is facing. Not very hard, and if whatdotcolor is DOS based, then this is even more so.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 14 Posts ]
Jump to:   


Style:  
Search: