
-----------------------------------
P-Nut311
Tue Dec 14, 2004 11:11 pm

Randomizing/If Statement Help
-----------------------------------
I'm making a game similar to 'Who Wants To Be A Millionaire'. First, the player inputs his/her name, then the program asks what subject they want the game to be based on (1. History, 2. Science....). How do I make it so that if the user inputs '1' for history, the game will display only the history questions. If the user inputs '2', then the game will only show science questions....

Also, in this game there are 2 milestones, which are like checkpoints (indicators that once you pass a milestone, the questions will be more difficult). Questions 1 - 5 will be beginner questions, 6 - 10 will be moderate, and 11 - 15 will be difficult. Now, how do I make it so that questions 1 - 5 will be randomized, 6 - 10 will be randomized, and 11 - 15 will be randomized? I want them to be in their own difficulty range (example: question 2 cannot be found at question 12.) How would I do this if my program covers several different subjects (history, science...) but depends on what the user inputs for his/her subject.

I'm bad at explaining things, so maybe you'd get a better idea if I just post the code I have so far. Note that the resolution is kinda off, so ignore that for now.

  
%Declares graphics 
setscreen ("graphics") 
setscreen ("graphics:vga") 
setscreen ("graphics:788;502") 
setscreen ("nocursor") 
%Declaring Variables 
var name : string 
var subject, history : int 
%Set background and color of font 
colorback (black) 
color (white) 
cls 
delay (1000) 
%Asks name 
var fontname : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("Please Enter Your Name", 265, 300, fontname, yellow) 
locate (14, 45) 
put "" .. 
get name 
delay (200) 
cls 
%Asks for subject 
delay (200) 
var fontsubject : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("Please Choose a Subject:", 235, 300, fontsubject, yellow) 
%Font for "1. History" 
delay (200) 
var fonthistory : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("1. History", 265, 280, fonthistory, yellow) 
%Font for "2. Science" 
delay (200) 
var fontscience : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("2. Science", 265, 260, fontscience, yellow) 
%Font for "3. Sports" 
delay (200) 
var fontsports : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("3. Sports", 265, 240, fontsports, yellow) 
%Font for "4. TV" 
delay (200) 
var fontTV : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("4. TV", 265, 220, fontTV, yellow) 
delay (200) 
locate (13, 61) 
put "" .. 
get subject 
delay (200) 
cls 
%Line on right hand side 
drawline (505, 0, 505, 400, red) 
delay (1000) 
%Font for $100 
var font50 : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("1.              $100", 650, 10, font50, red) 
delay (30) 
%Font for $200 
var font100 : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("2.              $200", 650, 30, font100, red) 
delay (30) 
%Font for $200 
var font200 : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("3.              $300", 650, 50, font200, red) 
delay (30) 
%Font for $300 
var font300 : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("4.              $400", 650, 70, font300, red) 
delay (30) 
%Font for $500 
var font500 : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("5.              $500", 650, 90, font500, green) 
delay (30) 
%Font for $1,000 
var font1000 : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("6.           $1,000", 649, 110, font1000, red) 
delay (30) 
%Font for $2,000 
var font2000 : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("7.           $2,000", 649, 130, font2000, red) 
delay (30) 
%Font for $4,000 
var font4000 : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("8.           $4,000", 649, 150, font4000, red) 
delay (30) 
%Font for $8,000 
var font8000 : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("9.           $8,000", 649, 170, font8000, red) 
delay (30) 
%Font for $16,000 
var font16000 : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("10.       $16,000", 648, 190, font16000, green) 
delay (30) 
%Font for $32,000 
var font32000 : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("11.       $32,000", 648, 210, font32000, red) 
delay (30) 
%Font for $64,000 
var font64000 : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("12.       $64,000", 648, 230, font64000, red) 
delay (30) 
%Font for $125,000 
var font125000 : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("13.     $125,000", 647, 250, font16000, red) 
delay (30) 
%Font for $500,000 
var font500000 : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("14.     $500,000", 647, 270, font500000, red) 
delay (30) 
%Font for $1 Million 
var font1million : int := Font.New ("Cooperplate Gothic Bold:14:bold") 
Font.Draw ("15.  $1,000,000", 646, 290, font1million, yellow) 
delay (1000) 
%Font for "Mr. Millionaire" 
%var fontMr : int := Font.New ("Engravers MT:14:bold") 
%Font.Draw ("Mr.", 556, 380, fontMr, yellow) 
%var fontMillionaire : int := Font.New ("Engravers MT:10:bold") 
%Font.Draw ("Millionaire", 506, 340, fontMillionaire, yellow) 
%delay (2000) 
%Randomizing History Quesstions 1 - 5  


-----------------------------------
Cervantes
Tue Dec 14, 2004 11:37 pm


-----------------------------------
[url=http://www.compsci.ca/v2/viewtopic.php?t=5]Files will be your friend for this undertaking.

-----------------------------------
wtd
Wed Dec 15, 2004 1:39 pm


-----------------------------------
You might notice that you're repeating this a lot:

var font50 : int := Font.New ("Cooperplate Gothic Bold:14:bold")

Don't.

-----------------------------------
P-Nut311
Wed Dec 15, 2004 2:13 pm


-----------------------------------
y???

-----------------------------------
Mazer
Wed Dec 15, 2004 3:05 pm


-----------------------------------
Because you only need to do it once. You create the font with that line (probably nearer to the beginning of the code) and you just use that variable each time you're using Font.Draw. You can only make up to 1000 fonts (might be a different number but that's what it is for pictures). After that the program will crash.

-----------------------------------
Tony
Wed Dec 15, 2004 3:06 pm


-----------------------------------
y???
Well when every 4th line of code creates another instance of the same font... that is just beyond redundant :?
