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

Username:   Password: 
 RegisterRegister   
 isp help - procedure "question" and decoding a lin
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
n00b.skillz




PostPosted: Thu Dec 07, 2006 11:26 am   Post subject: isp help - procedure "question" and decoding a lin

Sad hey fellow programmers i just started turing this year and i'm working on my isp project this site is great it's given me alot of help but i have just two questions (for now Rolling Eyes ) can anyone explain to we what the procedure "question" does and how it is used.... and can someone tell me where the count+1 is in this line (this program is on a counter and where does the counter get the info if it's right or wrong -
Question ("How many dungeons are there in 'The Legend of Zelda: The Ocarina of Time'?", "11", "13", "8", "6", "1", "Link2.jpg", maxx div 2 - 200, maxy div 2 - 200)%%line taken from hackman's nintendo mid term quiz which i am usin as a model to help me build a music trivia
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Dec 07, 2006 11:49 am   Post subject: (No subject)

"Question" is a custom procedure. There should be a definition for it, with all the code in the same file.

Looking at the arguments, it takes in the question, possible answers, image name, location on the screen. And then generates a question to be put there.

I would imagine that count+1 is a part of the if-statement logic that handles user's answer.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Hackmaster




PostPosted: Fri Dec 08, 2006 9:54 pm   Post subject: (No subject)

Hey guys...

WOW! I feel honored! someone...using my code.. for an example? you like me! you really like me!!... enough of that... thanks for giving me credit, BTW.

as for how it works. you are new to coding, and you probably do not know how procedures work. you should have a look at my tutorial on the subject... but then again, there are better out there. that was my first post after all.

Basically, a procedure is a custom command that you make. it takes certain peramiters, and does things with them.

in my game, I used a procedure to call a whole bunch of questions, as you saw from reading my code(which i'm still really excited about). here is the parameters I use:

1. I get question. this essentialy is used later to put a question on the screen, so the user has something to answer.

2. I get a, b, c, and d. these are the answers that will show up for the user to.. well use. it is in that order.

3. I get right. this may be a bit over your head, seeing as you are new, and I don't know how far you are as of right now... I'm assuming you know if statements if your teacher is asking you for a quiz. Basically, I use this variable to designate which answer out of the four I just talked about is right. if right = 1 then 'a' is right. if right = 2, then 'b' is right and so on. if any of these four conditions are not met, then it says that the user is wrong and displays the correct answer.

4. I get the name of the picture I want to use. If you have run my program, you will notice I don't use pictures in every line, so I said that if pic = "n" then do nothing. otherwise, use that name I provided in the Pic.ScreenLoad function.

5. I get an x/y position. I use this to position the picture, and depending on the picture, I change this to accomodate it on the screen.

as for the count:=count +1 thing.

what it does is it looks to see if the user got the correct answer ( as specified by me). if he did, then count goes up by one. I use the count variable at the end to tell the person how many answers they got right.

While I encourage you to try new things, I would also advise that if you don't get this stuff, or your teacher hasn't taught you any of it, you shouldn't use it. your teacher may yell at you for getting someone else to write your code... I don't know how much of a hard-ass your teacher is.

That said, when this project is done, by all means learn procedures. They seriously clean your code up. have a comparison:

my program here got the best in the class.

the next best one was 800 lines of code, and it had (count em') 15 questions. I have 135, and it's only 286. pretty nice, eh?

Also, if you have any other questions about anything in my programs or... anything, PM me... I've been doing this for a while, and am ready and willing to help people just like you! Very Happy
n00b.skillz




PostPosted: Tue Dec 12, 2006 9:45 am   Post subject: (No subject)

Very Happy heyy thanks hackmaster and tony........
and yea i took a look at your procedure tutorial and it seems fairly simple it cleared up alot of my questions but i have two more
firstly hackmaster in your program you have at the begining of every question line you have the procedure question so i am just wondering if i can use font.draw in these lines because i tried it and got completely lost and can you plz explin wut div stands for at the end of maxy and if you want to know my programmin level i just learned pretty much how to draw maple leafs and how to use fill......... that's pretty much it in graphics Rolling Eyes ........ and i appreaciate all u guys takin time to help me wif my isp...... without u guys i'd fail Confused
n00b.skillz




PostPosted: Tue Dec 12, 2006 10:42 am   Post subject: (No subject)

btw when i do put the question procedure infront of the font.draw it says "missing parameters in call to subprogram 'question'" um i put in a a loop and some cls's could that be the problem kk well i'm goin to upload my program but i warn you it is still in it's very very very rough stages so nooooo laughing an instead of have actual questions i just copy and pasted the heading name.........


isp project.t
 Description:

Download
 Filename:  isp project.t
 Filesize:  3.98 KB
 Downloaded:  64 Time(s)

Hackmaster




PostPosted: Tue Dec 12, 2006 2:38 pm   Post subject: (No subject)

Alright, so, some things....

could you possibly tell me the questions you have... on like seprate lines... because, it was kind of one, loooooong run on sentance.

Anyways...suggestion...don't ever, ever use cases!!! they are so cumbersome... and stupid in general.

but ya....I'm glad you liked my tutorial... um.. please, ask your questions again. I can't really help you till then. thanks!
Clayton




PostPosted: Tue Dec 12, 2006 3:54 pm   Post subject: (No subject)

Hackmaster: what exactly is so wrong with cases? In some cases a case structure is much better than doing multiple ifs.

n00b.skillz: your error means that you aren't passing "question" enough arguments. Double-check that you are passing enough parameters to question.
n00b.skillz




PostPosted: Wed Dec 13, 2006 10:41 am   Post subject: (No subject)

here is your non run on sentance...........
1)hackmaster in your program at the begining of every question line you have the procedure question. So i am just wondering if i can use font.draw in these lines because i tried it and got completely lost. When i do put question infront of font.draw it gives me the following error "missing parameters in call to subprogram 'question' " what exactly what does that mean?
2)can you plz explain wut div stands for at the end of maxy?
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Wed Dec 13, 2006 2:00 pm   Post subject: (No subject)

1) answered in my post above this one
2) div is a method of dividing a number and "chopping" off the decimal. It doesn't round, it just 'chops'.

Eg. 12 div 2 = 6
13 div 2 = 6 (6.5 minus the decimal)
Hackmaster




PostPosted: Wed Dec 13, 2006 8:06 pm   Post subject: (No subject)

Freakman:

I don't use cases very often, and I find that I don't like them all that much when I do. the structure in them is less simple, especially from a begginer's standpoint. I do agree that absoultly sometimes they can be better than an if statment tree. but not often. the reason I said never to use them... well. it might have been an over statement, but the way I see it, when n00b.skillz grows up a bit as a programmer, he can choose his own prefrences. for now, and in the program, he should probably stick to ifs.

n00b.skillz:

div does what freakman says it does.

As for Font.Draw and such like that, you can use it. however, it would be stupid to do it at the beggining of every line. the way to do it is to make a new font and such, and then inside the function, use Font.Draw to write the question. this should all be done within the prcedure. afterall, procedures are made to DECREASE the amount of programming you do, not make you copy paste the smae command 135 times.

does that answer your question?
Clayton




PostPosted: Wed Dec 13, 2006 8:44 pm   Post subject: (No subject)

well look at it this way, you have a potential if, it is going to be checking the same variable over and over to check a condition, that means typing out the variable name over and over again, an equal sign over and over again, and then over and over again. Eg.

code:

var foo : int := 0
put "Input a #"
get foo

if foo = 1 then
...
elsif foo = 2 then
...
elsif foo = 3 then
...
elsif foo = 4 then
...


and so on and so forth, whereas with a case statement, you do the variable name one time, and you simply type in the value after each label : statement Eg.

code:

var foo : int
put "Please enter a #"
get foo

case foo of
    label : 1
        ...
    label : 2
        ...
    label : 3
        ...
    label : 4
        ...
end case


much nicer to read, less typing to do too Wink
n00b.skillz




PostPosted: Thu Dec 14, 2006 11:34 am   Post subject: (No subject)

well since you guys are talking about me i personally prefer case construct because i learned it in class and am comfortable with it, plus it makes everything much more organized. Anways i just wanted to ask you how i can put font draw into the procedure i tried everything but that's the only problem i'm having right now. i think if i can get that i might be well on my way to finishing my isp. can someone please make me a model or use my old program and just stick it in there..... if that ouldn't be asking too much..
Hackmaster




PostPosted: Thu Dec 14, 2006 9:13 pm   Post subject: (No subject)

n00b.skillz:

I actually did answer that question and give you advice. look 2 posts (not including this one) above this one.

to re-iterate, though:

yes, you can. all you need to do is within the procedure, change it so that it has a font.draw before the put statement that outputs the variable question. Alright?

Freakman:

I get your point. and, like n00b.skillz said, I grew up with ifs, so maybe i'm just attached too much. I see how it would save space, and the RPG I'm working on is gonna be huge, so space is a good thing.

It's funny actually. When you start programming, you look at your first big programming assignment, and you say "Whoa! 100 lines! that's awesome!" then, your next milestone is 500. then 1000. around that point, however, you begin to optimize your code, and your next program is only 400. then, you make one absoulutly enormus one. say, anywhere from 1500-10000 lines, and you breath a sigh of relif. "Wow! I actually made a really kick -ass program!" at that point, you forever wnat to make your code smaller.
n00b.skillz




PostPosted: Fri Dec 15, 2006 10:19 am   Post subject: (No subject)

hackmaster i tried stickin font.draw in and it just wouldn't work i asked my teacher and he said that he doesn't think you can .......... can anyone help?
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: