Posted: Wed Mar 26, 2008 3:22 pm Post subject: Capitals of Canada Quiz
Earlier on I posted a Canada Quiz which with people's help I finaly finished but then my teacher told me that we weren't aloud to use loops and I used a For Loop so I had to rechange my program to fit "his" standards. So this s my new problem that I came accross.
First British Columbia shows up and you have to write the capital and so on. We have to display the amount of tries that they have out of 3. After 3 the program moves on to the next province. Which it doesn but when it moves on to Alberta and the person gets it wrong it keeps counting the number of tries left from 4 instead of going back down to 0.
Turing:
setscreen("graphics:700;500")% Sets the screen to a certain amount of pixels.
proc map
Pic.ScreenLoad("Map.jpg",50, 10, picMerge)%Loads picture of the Canadian map so it can be used through out the program. end map
%All the declarations. var answer :string%the variable for the users answer to the question. var s :int% Score of the user
s :=0%Score = 0 depending on the users correct answer. var c :real:=0
var bname :string%The beaver's name.
var font1 :int%declare font 1 so I can use it anywhere in the program.
font1 :=Font.New("Castellar:18")%Type of font & size of font. assert font1 > 0%Makes sure that the program is true, if not program is terminated.
var font2 :int
font2 :=Font.New("Curlz MT:18") assert font2 > 0
var font3 :int
font3 :=Font.New("Georgia:18") assert font3 > 0
var font4 :int
font4 :=Font.New("Forte:18") assert font4 > 0
var font5 :int
font5 :=Font.New("Castellar:35") assert font5 > 0
var font6 :int
font6 :=Font.New("Georgia:30") assert font6 > 0
var font7 :int
font7 :=Font.New("Arial Black:30") assert font7 > 0
var font8 :int
font8 :=Font.New("Arial:14") assert font8 > 0
%The introduction screen with a set of rules. Canadian flag as the back ground and before starting the actual game you must give mister beaver a name. (kinda lame I know but I couldn't use a GUI so we could click on it.) proc intro
Pic.ScreenLoad("CanadianFlag.jpg", -60, 0, picMerge)%Loads picture of the Canadian Flag. Font.Draw("Are you a TRUE Canadian?",55, 450, font6, 7) delay(1000)% delay for "EH?" Font.Draw("EH?",550, 450, font7, 7) delay(1000)%Delay for sets instrutions. Font.Draw("This is the 'Are you a TRUE Candadian EH?' Quiz",5, 350, font8, 7) Font.Draw("This quiz is on the capitals of the Canadian Provinces and Territories.",5, 330, font8, 7) Font.Draw("You have 3 tries for each province/territory. Your score will be displayed at the end.",5, 310, font8, 7) Font.Draw("Pretty Simple? Good LUCK!",5, 290, font8, 7) Font.Draw("PS. Turn up the volume!",5, 250, font8, 7) Font.Draw("Please give a name to mister beaver before starting!",5, 270, font8, 7) Pic.ScreenLoad("beaver.gif",50, 40, picMerge)%Loads picture of beaver. locatexy(300, 400)%Location for the user's writing. get bname %Gets the name of the beaver. cls%Clears screen for actual game. end intro
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Music.PlayFileLoop("Techno - O Canada.mp3")%Begining of O canada (techno version. %The actual quiz! Shows the Canadian Map as a background, the question with font.draw ontop, the amount of tries the user has left at the bottom right corner and all accompanied by the National Anthem Techno version ;) proc bc
Pic.ScreenLoad("Map.jpg",50, 10, picMerge)
c := c + 1 cls
% British Colombia Pic.ScreenLoad("Map.jpg",50, 10, picMerge) Font.Draw("What is the Capital of British Colombia?",0, 450, font1, 111) locatexy(300, 400)%user enters there answer. get answer %Gets the answer cls Pic.ScreenLoad("Map.jpg",50, 10, picMerge)%Loads the picture of the Canadian Map as a background. if answer ="Victoria"or answer ="victoria"or answer ="VICTORIA"then% I have them in capitals and lower case just to give the user a wider variety. Font.Draw("WOOT -happy dance-",400, 250, font2, 79)%if the answer is correct it puts a happy comment.
s := s + 1%if the asnwer is correct one point is given, the program keeps a tally of the points aside to give out a total at the end.
c :=0 delay(2000) cls elsif c =3then cls Pic.ScreenLoad("Map.jpg",50, 10, picMerge) Font.Draw("The answer is Victoria",300, 400, font2, 55) delay(2000) cls else Font.Draw("YOU ARE SO...NOT RIGHT!",350, 250, font4, 79)%If the asnwer is not correct a comment is put for them to try again. Font.Draw("Number of gueses of 3",420, 10, font2, 38)%Shows the number of guesses they have left decreasing from 2. locatexy(650, 10)% Locates the amount of tries left. put c % Puts the amount of tries left. delay(2000) cls
bc
endif%ends if statement. end bc
% Alberta Pic.ScreenLoad("Map.jpg",50, 10, picMerge) Font.Draw("What is the Capital of Alberta?",0, 450, font1, 111) locatexy(300, 400) get answer
cls Pic.ScreenLoad("Map.jpg",50, 10, picMerge) if answer ="Edmonton"or answer ="edmonton"or answer ="EDMONTON"then Font.Draw("RIGHTO",400, 250, font2, 79)
s := s + 1
c :=0 delay(1000) cls elsif c =3then cls Pic.ScreenLoad("Map.jpg",50, 10, picMerge) Font.Draw("The answer is Edmonton",300, 400, font2, 55) delay(2000) cls else Font.Draw("hahaha... no",350, 250, font4, 79) Font.Draw("Number of gueses left",420, 10, font2, 38) locatexy(650, 10) put c
delay(2000) cls
ab
endif end ab
splash
intro
bc
ab
I would as someone else in my class but they aren't that far yet.
Thanks
Jess
Sponsor Sponsor
Mackie
Posted: Wed Mar 26, 2008 3:25 pm Post subject: RE:Capitals of Canada Quiz
A few things... First off your teacher should be glad you went ahead. Secondly you should really use better variable names. I can't try your program though, you need to package the images with the program.
Jessica359
Posted: Wed Mar 26, 2008 3:57 pm Post subject: RE:Capitals of Canada Quiz
you can just take the images and sound out its just for decaration. Everything else works fine its just the count (variable "c") that won't start over after you change question. It keeps counting from te last question instead of starting over.
Sean
Posted: Wed Mar 26, 2008 3:57 pm Post subject: Re: Capitals of Canada Quiz
You have c, being the chances they took.
You'll want an if statement to check what c is to do the next thing..
Turing:
if c =3and s =0then %Your Next Map endif
If they keep getting wrong, you will want it to check for another interval of 3 every other map. Got it?
And if your teacher doesn't allow for-loops because you are ahead, then tell them off and do it anyways.
Tony
Posted: Wed Mar 26, 2008 4:13 pm Post subject: Re: Capitals of Canada Quiz
Sean @ Wed Mar 26, 2008 3:57 pm wrote:
you will want it to check for another interval of 3 every other map.
That wouldn't work because if I have c == 9, you can't know if I made 3 mistakes on 3 questions or all 9 on the 3rd. Besides, that's not what the question asks. The counter is supposed to start over from 0, so you need to set c to be 0 before starting each question.
Posted: Wed Mar 26, 2008 4:21 pm Post subject: Re: Capitals of Canada Quiz
Ah, re-read the question and saw my mistake.
You can still use the if statement from above, but add in c := 0 inside the statement.
And then each question will check for a 3 counter.
Turing:
if c =3and s =0then
c :=0 %Next Flag Question endif
Insectoid
Posted: Wed Mar 26, 2008 5:34 pm Post subject: RE:Capitals of Canada Quiz
I guess its a good thing my teacher spent 3 days doing 'proper naming of variables, constants, etc.'?
1 letter names are BAD! It makes it confusing for you if you ever leave this project and come back to it later, and difficult for these good people to help you. looking at the code, I don't even know what var : c is, except that it's a number!
Sean
Posted: Wed Mar 26, 2008 5:40 pm Post subject: Re: Capitals of Canada Quiz
Well, your variables are these..
Turing:
var answer :string%the variable for the users answer to the question. var s :int% Score of the user
s :=0%Score = 0 depending on the users correct answer. var c :real:=0 var bname :string%The beaver's name.
You have one variable that is understandable, which is Answer, the others aren't.
You should change your variables to this so you can remember what they are for...
Turing:
var answer, beaver_name :string var score :int:=0 var chances :real:=0
Also, you can click on the beaver without using GUI, look up Mouse.Where
Sponsor Sponsor
Clayton
Posted: Wed Mar 26, 2008 8:13 pm Post subject: RE:Capitals of Canada Quiz
I'm surprised no one has noticed this yet, but what's with that big honking loading procedure? If I had to sit through that, I might have to off myself. Not only does it not take that long to load images, but it's entirely pointless. Don't make your user sit through something they don't have to.
Tony
Posted: Wed Mar 26, 2008 9:56 pm Post subject: Re: RE:Capitals of Canada Quiz
Sean @ Wed Mar 26, 2008 5:40 pm wrote:
You have one variable that is understandable, which is Answer
Actually even that is ambiguous. It could be (and as a comment suggested) a placeholder for user's answer, but taken out of context (such as when only a part of the code is examined), it could be thought of as the answer we are looking for. A better name would be user_response
Clayton @ Wed Mar 26, 2008 8:13 pm wrote:
I'm surprised no one has noticed this yet...
I don't actually run any Turing source anymore.. until someone buys me a copy of VM Fusion. I just read it now, so such parts are skipped over.
Posted: Thu Mar 27, 2008 7:41 am Post subject: RE:Capitals of Canada Quiz
Wow, um ok thanks guys with your help I got it to work.
This was all I was missing
code:
elsif chance = 3 then
cls
Pic.ScreenLoad ("Map.jpg", 50, 10, picMerge)
Font.Draw ("The answer is Edmonton", 300, 400, font2, 55)
delay (2000)
chance := 0
cls
chance =0 to tell it to restart over again.
YAY
Also thanks for the advice on the variables I remaned them and it does make it less confusing.
For the Loading procedure it was part of the project outline, we needed to show that the program was "loading" for a specific period of time. Really useless but its the project outline.
Tallguy
Posted: Thu Mar 27, 2008 8:05 am Post subject: Re: Capitals of Canada Quiz
sup jess. you should really zip your folder so we can get the pics. and my program is better then urs check it out in the submissions pge, called 'Capitols Quiz'
Clayton wrote:
I'm surprised no one has noticed this yet, but what's with that big honking loading procedure? If I had to sit through that, I might have to off myself. Not only does it not take that long to load images, but it's entirely pointless. Don't make your user sit through something they don't have to.
we had to have a loading or a splash screen in out program (i'm in her class ) it is pointless but always do what the teacher wants if you want to pass
Tony
Posted: Thu Mar 27, 2008 9:48 am Post subject: Re: RE:Capitals of Canada Quiz
Jessica359 @ Thu Mar 27, 2008 7:41 am wrote:
For the Loading procedure it was part of the project outline...
Could somebody please forward a link to the above blog article on Loading Bar Anti-Pattern to that teacher?