Computer Science Canada 4 in a row check |
Author: | cycro1234 [ Sun Jan 16, 2005 10:38 pm ] |
Post subject: | 4 in a row check |
How would I make a procedure that checks in my connect 4 game if there are 4 of the same colour in a row? Do I use whatdotcolour? |
Author: | cycro1234 [ Sun Jan 16, 2005 10:42 pm ] | ||
Post subject: | |||
I have something like this :
However, there are many possibilities, since the player can get 4 in a row left to right, diagonally, and up and down. Is there a shorter way than this? Or more effective? |
Author: | Bacchus [ Sun Jan 16, 2005 11:19 pm ] |
Post subject: | |
instead of always checking them, when the token you watever you use to mark a space when the player chooses it, i would set an array to the color. then all you have to do is compare arrays |
Author: | cycro1234 [ Sun Jan 16, 2005 11:44 pm ] |
Post subject: | |
How would I do that? An example please? I'm still kinda new to arrays. |
Author: | cycro1234 [ Thu Jan 20, 2005 12:33 pm ] |
Post subject: | |
*Sigh* One day left til it's due, and I'm STILL stuck. I haven't figured out how to make my program work with arrays. ANy help at all would be greatly appreciated. ![]() |
Author: | eNc [ Thu Jan 20, 2005 4:24 pm ] | ||
Post subject: | |||
cycro1234 wrote: *Sigh* One day left til it's due, and I'm STILL stuck. I haven't figured out how to make my program work with arrays. ANy help at all would be greatly appreciated.
![]()
I don't kno it that will help |
Author: | cycro1234 [ Thu Jan 20, 2005 4:43 pm ] | ||||
Post subject: | |||||
Ok, I found out where my problem is exactly, but now i need to know how to fix it. I'll describe the problem: One of my very first pieces of code is:
I need this y value to use later on in my code to control the drop of my piece. The drop always starts at 540. I also have a procedure before this called "check" that checks if there are 4 pieces of the same colour in a row. Now here is my procedure (shortened up) that controls the drop:
Any ideas on how I could possible fix this? My ISP is due tomorrow and I really need help! |
Author: | Cervantes [ Thu Jan 20, 2005 5:00 pm ] | ||
Post subject: | |||
How about adding a line to your check procedure, at the end. Add:
And take out the y := 540 in your dropBall procedure. |
Author: | cycro1234 [ Thu Jan 20, 2005 5:20 pm ] |
Post subject: | |
I would, but my check procedure has a y as its variable. procedure check (x, y: int) |
Author: | cycro1234 [ Thu Jan 20, 2005 6:06 pm ] |
Post subject: | |
What do I do if the procedure has y as one of its parameters? |