Computer Science Canada Help with a maze program |
Author: | theanimator [ Wed Oct 26, 2005 6:16 pm ] | ||
Post subject: | Help with a maze program | ||
i am trying to make a maze and i am able to make the collision for the first line but then i can't get around a turn. I am just a beginner so bare with me here. Here is my code:
if anyone could help me out on this turn that would be great ![]() |
Author: | MysticVegeta [ Wed Oct 26, 2005 6:32 pm ] |
Post subject: | |
you are doing the turning thing wrong, your bumping procedure retricts on your turning possibilites. What you need to do is instead of doing that kind of collision, check on whatdotcolor collision, in the turing tutorials, because then your ball can stay inside your circles, and can turn! |
Author: | theanimator [ Wed Oct 26, 2005 8:23 pm ] |
Post subject: | |
i'm still confused with the whatdotcolor. maybe it needs to be explained a bit more. |
Author: | Undr_Xposed [ Wed Oct 26, 2005 8:27 pm ] |
Post subject: | |
yes ill agree with theanimator i kno im a n00b and cant really understand a lot of wat were talking about but its really confusing to me as well ![]() |
Author: | TokenHerbz [ Thu Oct 27, 2005 2:17 am ] | ||
Post subject: | |||
whatdotcolor works by taking a x and y chordnant and checking its background color... Effectivly if you are using a snake game, with say BLACK walls you can check collition like so..
Its complicated if you have odd colours in paint, but its very usfull.. Edit::: Also you should use more effective variables... better names, etc: also your varaibles "a,b,x1,y1" dosn't seem you need, as there just premanent lines?? |
Author: | [Gandalf] [ Thu Oct 27, 2005 2:51 pm ] |
Post subject: | |
Better variable names are always good, but x1, x2, y1, y2, etc reflect what you mean in this case. No, the use of variables isn't really bad there since it makes the code more readable, and easier to modify when you are looking back on it after a while. The problem with them is, that in this case they should be constants. |
Author: | Albrecd [ Tue Nov 08, 2005 2:54 pm ] |
Post subject: | y += |
Instead of putting Quote: if chars (KEY_UP_ARROW) then
y:=y+2 you could put if chars (KEY_UP_ARROW) then y+=2 |
Author: | iker [ Tue Nov 08, 2005 5:23 pm ] | ||
Post subject: | |||
try out this code, it has your problems fixed I changed some variables, such as for the lines, I used a..d, and the move to +=1 or -=1 so that you don't skip any lines, but lowered the delay time so you will see no difference heres how it works: [1]it draws the screen and ball [2]checks the colors just to the left, right, top and bottom with lx..uy and col1..col4 [3]if a color is other then white to any side of the ball, it moves it one to the other dirrection
|