Here are the answers to the challenges described in tutorial one. They can be solved many ways, these are just the ways I solved them. If you solved these in a different way (especially with the survey or text adventure) email them to me! I'll post them on my site! My email is: pete_berg@yahoo.com -Pete ------------------------------------------- Challenge #1: This was to PRINT this pattern or X's X XX XXX XXXX XXXXX ------------------------------------------- FOR t=1 TO 5 x=x+1 PRINT FOR b=1 TO x PRINT "X" NEXT b NEXT t ------------------------------------------- Challenge #2: This was to make a simple survey. ------------------------------------------- 'Question Number One: PRINT " Welcome to the Automatic Survey Machine!" PRINT PRINT "1.) What is your name";: INPUT nm$ PRINT PRINT "Hello, "; nm$ 'Question #2 PRINT PRINT "2.) How much do you weigh";: INPUT weight IF weight > 180 THEN PRINT "You better cut down on those jelly rolls!" IF weight < 80 THEN PRINT "You're VERY skinny!" ELSE PRINT "You're not too fat (but you're not too skinny either!)" 'Question #3 PRINT PRINT "3.) How much wood could a wood chuck chuck if a wood chuck could chuck wood";: INPUT wood IF wood > 500 THEN PRINT "I'm sorry, you're a little too high. :)" : m = m + 1 IF wood < 100 THEN PRINT "Come on, they eat more than that!!" ELSE PRINT "You got it!" : m = m + 2 'Insert #4-10 here! Get the general idea? 'At the end: 'end PRINT "Processing"; FOR t= 1 TO 15 PRINT "."; NEXT t PRINT PRINT "According to this automatic poll, you are:" PRINT nm$ PRINT weight; "pounds" IF m = 1 THEN PRINT "Averagely Smart" IF m = 2 THEN PRINT "A genius!" ELSE PRINT "A retard!" 'Insert the rest of the variables' info here. ------------------------------------------- Challenge #3: This was to make "Guess The Number" Harder or easier. You do this by making the number's choices have lower and higher limits. It would look something like this: ------------------------------------------- REM ***Guess The Number*** CLS PRINT "What is your name";:INPUT nm$ PRINT 100 PRINT "What level would you like (1-5)";: INPUT lev IF lev > 5 THEN 100 IF lev < 1 THEN 100 IF lev = 1 THEN top = 5 IF lev = 2 THEN top = 10 IF lev = 3 THEN top = 20 IF lev = 4 THEN top = 30 IF lev = 5 THEN top = 50 110 RANDOMIZE TIMER IF lev=1 THEN N=INT(RND*4) + 1 IF lev=2 THEN N=INT(RND*9)+1 IF lev=3 THEN N=INT(RND*19)+1 IF lev=4 THEN N=INT(RND*29)+1 IF lev=4 THEN N=INT(RND*49)+1 PRINT PRINT nm$;", I'm thinking of a" PRINT "number between 1 and";lev;"." 138 PRINT PRINT "What is my number";:INPUT g IF g<>n THEN 300 PRINT PRINT "Hurray, ";nm$;"!" PRINT "You Guessed my number!" FOR t=1 to 10000:NEXT t 200 PRINT PRINT nm$;", Do you want to" PRINT "play again";:INPUT a$ IF a$="Y" OR a$="y" or a$="YES" or a$="yes" THEN 110 IF a$<>"N" or a$<>"n" or a$<>"NO" or a$<>"no" THEN 200 PRINT:END 300 PRINT IF g>n THEN 350 PRINT "Sorry, ";NM$;". Too Small!" GOTO 138 350 PRINT "Sorry, ";nm$;". Too Big!" GOTO 138 'This is the end of the program! ------------------------------------------- Challenge #4: This was to make a simple text adventure with ONLY commands you had learned so far. You can make your own text adventure with this method. Do whatever you want to the source, use the code, I don't care :) This is the best program on this answers sheet thingy. ------------------------------------------- 1 HP = 30 RANDOMIZE TIMER CLS PRINT " Crystal Wars" PRINT " (C) Pete's QBASIC Site, 1998" PRINT PRINT " ~~~~~~~~~~~~~~~~~~~~~~~~~Main Menu~~~~~~~~~~~~~~~~~~~~~~~~~" PRINT PRINT "1.) Play Game" PRINT "2.) Quit" PRINT "3.) Instructions" PRINT "Type in the number of the one you choose." INPUT choice IF choice = 2 THEN END IF choice = 3 THEN 1000 CLS PRINT PRINT "You Wake up, and you don't know where you are." PRINT "After you look around, you decide that you're in the" PRINT "Woods...Somewhere..." PRINT "You decide that you better go somewhere, but where?" PRINT PRINT "Press enter to continue." INPUT abcd$ 10 room = 1 CLS PRINT "You are in the forest." PRINT "There are paths going north, south, east and west." IF knife = 0 THEN PRINT "There is a knife on the ground." INPUT a$ IF a$ = "n" THEN 20 IF a$ = "s" THEN 30 IF a$ = "e" THEN 40 IF a$ = "w" THEN 50 IF a$ = "t" THEN knife = 1: GOTO 10 IF a$ = "h" THEN GOTO 1000 IF a$ = "i" THEN 900 IF a$ = "q" THEN 1 IF a$ = "secret" THEN 100 GOTO 10 20 room = 2 CLS PRINT "You are in a small cave. There is no exit except to the south." IF cup <> 1 THEN PRINT "In the front is a cup. The cup is very beautiful!" INPUT a$ IF a$ = "n" THEN 1500 IF a$ = "s" THEN 10 IF a$ = "e" THEN 1500 IF a$ = "w" THEN 1500 IF a$ = "t" THEN cup = 1: GOTO 20 IF a$ = "h" THEN GOTO 1000 IF a$ = "i" THEN 900 IF a$ = "q" THEN 1 GOTO 20 30 room = 3 CLS PRINT "You are on a north-south path. There are exits to the north and south." IF bomb = 0 THEN PRINT "There is a bomb on the ground." PRINT INPUT a$ IF a$ = "n" THEN 10 IF a$ = "s" THEN 60 IF a$ = "e" THEN 1500 IF a$ = "w" THEN 1500 IF a$ = "t" THEN bomb = 1: GOTO 30 IF a$ = "h" THEN GOTO 1000 IF a$ = "i" THEN 900 IF a$ = "q" THEN 1 GOTO 30 40 room = 4 CLS PRINT "You are next to a clear stream. The water is healthy." PRINT "If you have the cup, fill it (type f) to regain your" PRINT "HP. The only exit is west." IF ky = 0 THEN PRINT "There is a key on the ground" PRINT INPUT a$ IF a$ = "n" THEN 1500 IF a$ = "s" THEN 1500 IF a$ = "e" THEN 1500 IF a$ = "w" THEN 10 IF a$ = "f" THEN PRINT "You fill your cup and drink!": HP = 30: PRINT "Press enter continue.": INPUT abcd$: GOTO 40 IF a$ = "t" THEN ky = 1 IF a$ = "h" THEN GOTO 1000 IF a$ = "i" THEN 900 IF a$ = "q" THEN 1 GOTO 40 50 room = 5 CLS PRINT "You are on a small east-west path. there are exits to the east and west." PRINT IF monstor = 0 THEN PRINT "An orc attacks!": INPUT abcd$: GOTO 3000 IF monstor = 1 THEN PRINT "A dead and bloody orc lays dead on the ground!" IF monstor = 1 THEN PRINT "There is only one way out - and that's east." IF monstor = 1 AND sword = 0 THEN PRINT "The orc's sword is laying next to him. Go head and take it!" INPUT a$ IF a$ = "n" THEN 1500 IF a$ = "s" THEN 1500 IF a$ = "e" THEN 10 IF a$ = "w" THEN 1500 IF a$ = "t" THEN sword = 1: GOTO 50 IF a$ = "h" THEN GOTO 1000 IF a$ = "i" THEN 900 IF a$ = "q" THEN 1 GOTO 50 60 room = 6 CLS PRINT "You are in the front yard of a castle. To your north is an open" PRINT "drawbridge, and the west and east are covered with a moat." PRINT INPUT a$ IF a$ = "n" THEN 30 IF a$ = "s" THEN 70 IF a$ = "e" THEN 1500 IF a$ = "w" THEN 1500 IF a$ = "h" THEN GOTO 1000 IF a$ = "i" THEN 900 IF a$ = "q" THEN 1 GOTO 60 70 room = 7 CLS IF ky = 0 THEN PRINT "The door is locked! Go find a key!": INPUT abcd$: GOTO 60 IF ky = 1 THEN PRINT "As you walked forward, you put your key in the door." PRINT "You're in the front room of the castle." PRINT "To the left and right are big doors. One leads you to instant death," PRINT "The other to riches beyond belief!" IF monster <> 0 THEN PRINT "A dead orc lays on the floor." IF monster = 0 THEN PRINT : PRINT "An orc attacks!": INPUT abcd$: GOTO 3000 INPUT a$ IF a$ = "n" THEN 1500 IF a$ = "s" THEN 60 IF a$ = "e" THEN 80 IF a$ = "w" THEN 90 IF a$ = "h" THEN GOTO 1000 IF a$ = "i" THEN 900 IF a$ = "q" THEN 1 GOTO 70 80 room = 8 CLS PRINT "You walk in and fall into an endless pit! Aaaaahh!" GOTO 4000 90 room = 9 PRINT "You've reached the treasure-and the end of this game!" PRINT "Hurray! You've won!" PRINT INPUT abcd$ GOTO 1 100 CLS PRINT "You've reached the secret room! Hurray! Your hit points are now" PRINT "100! Congratulations!" HP = 100 INPUT abcd$ GOTO 2000 900 PRINT "You are carrying:" IF knife = 1 THEN PRINT "A Knife" IF ky = 1 THEN PRINT "A Key" IF sword = 1 THEN PRINT "A sword" IF bomb = 1 THEN PRINT "A bomb" IF tpick = 1 THEN PRINT "A toothpick" IF cup = 1 THEN PRINT "A cup" PRINT "Press enter to continue." INPUT abcd$ GOTO 2000 1000 PRINT PRINT "Instructions:" PRINT "-------------" PRINT PRINT "-Type n, s, e, and w to walk around." PRINT "-Type a to attack enemies while in battle mode." PRINT "Type u to use a bomb while in battle mode." PRINT "-Type t to take what's in the room." PRINT "-Type i to see your inventory." PRINT "-Type q to quit." PRINT "Press enter to continue." INPUT abcd$ GOTO 2000 1500 PRINT PRINT "You can't go that way." PRINT PRINT "Press enter to continue." INPUT abcd$ 2000 IF room = 1 THEN 10 IF room = 2 THEN 20 IF room = 3 THEN 30 IF room = 4 THEN 40 IF room = 5 THEN 50 IF room = 6 THEN 60 IF room = 7 THEN 70 IF room = 8 THEN 80 IF room = 9 THEN 90 IF room = 10 THEN 100 3000 orchp = 60 3010 CLS PRINT "Do you want to (a)ttack or (u)se a bomb"; : INPUT att$ PRINT IF att$ = "q" THEN 1 IF att$ = "u" AND bomb = 0 THEN PRINT "You don't have any bombs!": GOTO 3010 IF att$ = "u" AND bomb = 1 THEN PRINT "The Orc gets blown up and falls dead!": orchp = 0: INPUT abcd$ IF att$ = "a" THEN attack = INT(RND * 30) + 1 IF knife = 1 THEN attack = attack + 2 IF sword = 1 THEN attack = attack + 5 PRINT "You hit the orc for "; attack; " hit points!" orchp = orchp - attack PRINT "The orc now has "; orchp; " hit points." IF HP < 1 THEN 4000 IF orchp < 1 AND monstor = 0 THEN monstor = 1: GOTO 2000 IF orchp < 1 AND monstor = 1 THEN monster = 1: GOTO 70 PRINT orcatt = INT(RND * 15) + 1 PRINT "The orc attacks you for "; orcatt; " hit points" HP = HP - orcatt PRINT "You now have "; HP; " hit points." IF HP < 1 THEN 4000 PRINT PRINT "Press any key to continue." INPUT abcd$ GOTO 3010 4000 PRINT "You have died." END ------------------------------------------- That's it for these challenges. Read tutorial Number three and get crackin' on the next set of 'em. P.S.: Open this in QBASIC annd REM out all of my rambling crap, cut, paste and run it! Don't worry about typing it in line by line. It takes WAY to long. Any .TXT file can be opened in QBASIC. :)