Computer Science Canada Maze Game |
Author: | Smarteez [ Wed Nov 29, 2006 5:51 pm ] | ||
Post subject: | Maze Game | ||
Ok, I have a problem here. I have created the first level of my game and then as I go to run it, I try to move the object and it won't move, I don't know if it is because it can't run so much code or if I have done something wrong. Here is the code and could somebody please help me out with it.
If someone could please help me out as soon as possible it would be greatly appreciated, and please don't just steel the code for your own benefit, I have been working on this for a while and don't want someone just to steal it and take credit for something they didn't do. Thank-You, Smarteez |
Author: | Cervantes [ Wed Nov 29, 2006 6:24 pm ] |
Post subject: | |
When you were coding this, were you frustrated at how many variables you had to make? There's a better way. Learn to use arrays. Your code fails because you mismatched an end if. See the end if that comes after the View.Update and cls stuff? It should be moved up. Right now you're only checking for input if that last elsif statement is true, which is silly. Also, you should be using either Input.KeyDown or getch. Not both. In this case, you should be using Input.KeyDown. Hope that helps |
Author: | PiGuy [ Wed Nov 29, 2006 6:31 pm ] | ||||
Post subject: | Re: Maze Game | ||||
Sorry about repeating what Cervantes said 5 mintues ago... I was typing this out when Cervantes posted a reply. You put your movement code within a 'game over' check:
This caused the program to completely overlook the movement of the person's square unless that condition is true, in which case the game is over anyway. You have to bring the code outside that check, and the easiest way to do this is simply to add an 'else'. Therefore, it should look something like this:
|
Author: | Smarteez [ Wed Nov 29, 2006 6:43 pm ] |
Post subject: | |
Ok, I fixed those things but now, It says game over but the thing keeps moving. |
Author: | PiGuy [ Wed Nov 29, 2006 6:57 pm ] |
Post subject: | |
Exit the loop as soon as one of your 'game over' conditions is true. This means that every 'game over' in your loop will be followed by an 'exit.' |
Author: | Smarteez [ Wed Nov 29, 2006 7:03 pm ] | ||
Post subject: | |||
Ok, I tried this but some of the lines don't seem to do anything so I can still go through some for some reason... Could someone please edit this for me? I would greatly appreciate it...
|
Author: | Clayton [ Wed Nov 29, 2006 7:15 pm ] | ||||
Post subject: | |||||
code like this breaks my heart:
this can be made so much easier if you simply go through the Turing Walkthrough and look at the tutorials on arrays (as Cervantes mentioned) and, if you're ambitious, records. With this, the following code could be shortened to:
So much shorter, and only requires a little work on your part to understand whats going on there. |
Author: | Smarteez [ Wed Nov 29, 2006 7:20 pm ] |
Post subject: | |
I don't understand that which is above |
Author: | Clayton [ Wed Nov 29, 2006 7:32 pm ] |
Post subject: | |
So go click on the link I provided to the Turing Walkthrough (there it is again) and read through the tutorials that I said you needed to look through to understand the code that I posted (namely the tutorials on arrays and records) |
Author: | Smarteez [ Wed Nov 29, 2006 8:09 pm ] | ||
Post subject: | |||
Ok, so I read the manuels, tried it out and I ended up with over 21 errors...
|
Author: | Clayton [ Wed Nov 29, 2006 8:40 pm ] | ||||
Post subject: | |||||
okay, read through that again carefully, giving box(1) 30, 0, 30, 250 doesn't work, Turing doesn't know which value goes to where, so insted, you have to tell it which value of Box you want it to inhabit, ie:
The same holds true when you draw your box, instead of giving it box(1), you have to tell it which elements of box(1) you want/need it to use, ie:
Take your time reading through the tutorials, otherwise you will just get yourself confused. |
Author: | uberwalla [ Wed Nov 29, 2006 8:50 pm ] |
Post subject: | |
ok i know this is kind of different from editing your code but why have that if u hit a wall then u lose and it quits? why not just make the walls impassable and instead of ending on collision just have a timer and give ther people a certain time limit to get to the end. |
Author: | PiGuy [ Wed Nov 29, 2006 8:50 pm ] | ||
Post subject: | |||
Also, you didn't declare your x1, y1, x2, y2 variables for the user- controlled box. Finally, just a little correction to the 'game over' conditions:
By the way, an efficient solution, Freakman ![]() |
Author: | Clayton [ Wed Nov 29, 2006 9:14 pm ] |
Post subject: | |
actually, its not all that efficient in terms of computing power, however it does save you a whackload of time when it comes to typing it up ![]() |
Author: | Smarteez [ Wed Nov 29, 2006 10:10 pm ] |
Post subject: | |
Which other way is there to exit without quiting the window so it just says try again or something like that... |
Author: | PiGuy [ Thu Nov 30, 2006 6:45 pm ] |
Post subject: | |
Read up on the looping section of the Turing Walkthrough. Probably the simplest way to do so would be the command 'exit.' This escapes 1 level of loops. Since your program does not have any nested looping, however, this would work just fine. |