Daranhiss program listing

To all ... The program listing below can be copied and pasted into one's TB Bronze, Silver or Gold software. Four lines of code have been commented-out, so that one doesn't need to have the two JPEG files that are required for the program to RUN properly. Interested readers are encouraged to RUN the code, and perhaps debug the program's DO ... LOOP problem. Comments and suggestions are solicited. Regards ... Tom M


! Filename: daranhiss_20091008a_tjm.tru
ASK PIXELS xpix,ypix
SET WINDOW 1,xpix,ypix,1
LET midx=xpix/2
LET midy=ypix/2
SET BACKGROUND COLOR 16
CLEAR
!CALL Read_Image ("JPEG", gamename$, "Gamenamepage.jpg")
!BOX SHOW gamename$ at midx-420,midy+270
PAUSE 1
LET redomm=1
DO while redomm=1
LET redomm = 0
CLEAR
SET BACKGROUND COLOR 15
CLEAR
! CALL Read_Image ("JPEG", mainmenu$, "mainmenupage.jpg")
! BOX SHOW mainmenu$ at midx-276,200
FOR ii=1 to 20
PRINT
NEXT ii
PRINT TAB (50);"1. Play game"
PRINT tab (50);"2. Little bit of semi-useful information about the game"
INPUT prompt "Choose an option sir.":mainmenu
SELECT CASE mainmenu
CASE 1
LET game$="y"
LET redomm= 0
CASE 2
LET tut$="y"
LET redomm= 0
CASE else
PRINT "FOOL chose something thats ON THE MENU!"
LET redomm=1
END SELECT
LOOP until redomm = 1
DO while tut$="y"
CLEAR
PRINT
LET confirm$="no"
DO while confirm$="no"
PRINT "What would you like to know, sir? "
PRINT "1. How to make gold."
PRINT
PRINT "2. How to get weapons."
PRINT
PRINT "3. How to level up."
PRINT
PRINT "4. Return to game main menu."
INPUT prompt "Which would you like to learn about? ":tutorial
SELECT CASE tutorial
CASE 1
CLEAR
INPUT prompt"So you would like to lern about gold?(yes/no)":option$
IF option$ = "no" then
LET confirm$="no"
CLEAR
END IF
IF option$="yes" then
LET confirm$="yes"
END IF
DO while confirm$= "yes"
CLEAR
PLOT TEXT, AT midx,16:"?!?GOLD? !?"
PLOT TEXT, AT midx,17: "__________"
PRINT
PRINT
PRINT"To make gold you have to go to the forest and kill monsters."
PRINT"Every monster gives you an amount of gold depending on their level."
PRINT"The higher the level the more gold you get."
PRINT"Kill high leveled monsters to get more gold!"
PRINT"press any key to return to the information page"
GET KEY pse
LET confirm$="no"
CLEAR
LOOP until confirm$="no"
CASE 2
CLEAR
INPUT prompt"So you would like to lern about weapons?(yes/no)":option$
IF option$ = "no" then
LET confirm$="no"
CLEAR
END IF
IF option$="yes" then
LET confirm$="yes"
END IF
DO while confirm$="yes"
SET COLOR -23
CLEAR
PLOT TEXT, AT midx,16:"?!?Weapon§? !?"
SET COLOR 16
PLOT TEXT, AT midx,17:"_____________"
PRINT
PRINT
PRINT"To get weapons you need gold. to lern how to obtain gold see prievious page."
PRINT"If You have gold you can obtain weapons by going into one of the corresponding shops."
PRINT"If you don't have enough money to buy the weapon selected, and if you try to buy it you get kicked outa the store for trying to haggle."
PRINT"this includes magic, items, swords, daggers, and the armory."
PRINT"press any key to return to the tutorial page."
GET KEY pse
LET confirm$="no"
CLEAR
LOOP until confirm$="no"
CASE 3
CLEAR
INPUT prompt"So you would like to learn how to level up?(yes/no)":option$
IF option$ = "no" then
LET confirm$="no"
CLEAR
END IF
IF option$="yes" then
LET confirm$="yes"
END IF
DO while confirm$="yes"
SET COLOR 12
CLEAR
PLOT TEXT, AT midx,16:"?!?Leveling Up? !?"
SET COLOR -23
PLOT TEXT, AT midx,17:"_________________"
PRINT
PRINT
SET COLOR 16
PRINT"To level up you must kill........Monsters."
PRINT"To kill you have to go to the forest."
PRINT"In there the option to kill comes up."
PRINT"Click that and then the fight action will be activated triggering well a fight."
PRINT"win the fight to obtain experience"
PRINT"After you have filled your experience bar go to the arena to fight the knight at your current level."
PRINT"After you win this fight you will level up."
PRINT"After level five you will go to castle town which has a magic shop you can use."
PRINT"Press any key to return to the tutuorial page"
GET KEY pse
LET confirm$="no"
CLEAR
LOOP until confirm$="no"
CASE 4
CLEAR
PLOT TEXT, AT midx,16: "Are you certain?"
PLOT TEXT, AT midx,17: "________________"
PRINT
PRINT
INPUT prompt"Are you sure you know everything you need? (yes/no)":option$
IF option$ = "no" then
LET confirm$="no"
CLEAR
END IF
IF option$="yes" then
LET confirm$="yes"
END IF
DO while confirm$ ="yes"
PRINT "ok then off to the main menu you go"
PRINT "press any key to return to the main menu"
GET KEY pse
LET confirm$="no"
LOOP until confirm$="no"
LET redomm=1
CASE else
CLEAR
PRINT"Please choose an option thats on the menu, sir."
PRINT"press any key to continue."
GET KEY pse
CLEAR
END SELECT
LOOP
LOOP
END

Comments

ok

thank you finally just please don't spam my posts i put these up not only for my aid but the aid of others that have the same problem. lastly according to our schools Manuel we are allowed to take a copy as long as we get rid of it after we are done with the course/school.

Re: Flow charts ...

To all ... I Googled 'flowcharts', then opened and printed the 5-page Wikipedia article on the first
Google page. If you're a flowchart novice, it's a good
place to start, and has several External links on the subject. Regards ... Tom M

The actual problem with the initial code

OK--classes are in session (almost mid-term time here) so we start seeing student programs show up. Helping to fix a bug or two is OK--but I agree that we shouldn't be writing anybody's software for them.

It is also true that this method of coding is not optimum but the problem is obvious if you format the code and look at the problem area. The decision to exit the tutorial resets confirm$ to "no". The case statement then dumps back into a loop that continues while confirm$ = no. You're stuck in that loop forever. To properly exit that loop, when the user says they want to exit the tutorial set a variable (I would name it exitflag) to 1 and then within the loop add a
if exitflag = 1 then exit do
statement.

Also--if students (or anyone else) want to argue with each other--do so OFF THIS LIST please.

Richard Tarara
Professor of Physics
Saint Mary's College

As for the results

here was the problem i used loop and loop so it would continually go. This wasn't in my plan i fixed the program by putting
LOOP until tutorial=4
LOOP until tut$="n"
at the end of the loops and extra coding so that when required it would meet those statements. as for my school we have a teacher that just started teaching lessons and i showed him the importing pictures and etc. He is new to the language just as i am but I will say that he could start out better by making new learners "course 1" read the book some before starting right out into the programming.

I have to disagree!!

Honestly, I like the method he's using right now i've only taken this class for 5 weeks so far and i have learned alot. the way he teaches now helps me because he just tells us what he wants our program to accomplish and we make it work. i don't have very good reading comprehension so the only thing i can do with the book is look up in the index what i need to use to accomplish my goals

what

mr. asmondy didnt just start teaching hes been teaching this class for years

thank you guys for all the help and ideas

thanks for all the suggestions and extra help guys and gals. I appreciate it much, although i did figure out the problem thanks to a teacher that didn't even know about programing . she said"what is that a infinite loop inside of a infinite loop?" and then it click and i went through and fixed it. As for the idea of flow charts, in northwestern school district they do not teach anything about flow charts and it would be nice if some one could explain further or draw an example of one.

If one cannot debug one's own program,

Then one should write out a flow diagram. Anyone worth his salt can debug anything with a flow chart. In fact the best procedure in composing a really complicated program is to START with the flow chart in the first place and avoid the "code salad" such as the above. Don't they teach flow charting these days, or what.

Mike C.

Re: flow diagrams ...

Mike C ... In general, I agree, but when I was learning to program in C, I would write the objective program first in True BASIC. When I got that to work, I knew that when I wrote the C program, it could work!! And, I didn't have to go through repeated sessions of compiling and linking to get to the finished C product! Regards ... Tom M

Re: Darenhiss program ...

If one decides to Run the Subject: program, I recommend one use the RUN/DO FORMAT routine first. That was the program style that was posted to the TB Forum.

Formatting the code better reveals the nesting of the many DO LOOPs in this program. Regards ... Tom M

darenhiss' program

This message goes out to everyone helping darenhiss (Tim Rikowski). you guys are helping him with his schoolwork and should stop the point of him and his group making this game is to use it as a senior project to graduate if he can't do this by himself then he shouldn't graduate. You guys really shouldn't help him with his schoolwork. I am in his class and he didn't purchase the program he copied the teachers cd. he's lying to you guys he really is not worth the time debugging his program. you guys tell him to use subprogams but this stupid shit keeps using case statements and getting himself get stuck in nested loops. just please let him do his schoolwork on his own.

And to Darenhiss (Tim Rikowski) you need to do your own work come on if you are going to do a program for your senior project you need to do research and do it yourself come on there is no reason for you to go to the support forums and get people to do and to debug your programs for you.

chunck

i did buy an actual copy of silver chunk and if this were to be my senior project i would rather do it in Java or c++. which i am currently learning. this was to get idea to see what i can do to further debug other than to use debug mode. While I'm at it you shouldn't be complaining because you couldn't even get yours to loop. as for the sub programs look at my other threads. thank you Mike C. Tom, Retarra, Bigjohn and anyone else whom so far have helped me learn more about TB Silver.

first off

don't lie you got your copy from kenny i gave kenny the original and he copied onto a flashdrive and gave you a copy. second for the looping problem i dont know what it is called but its like a double loop heres the entire loop i had

LET SCORE1 = 0
LET SCORE2 = 0
DO WHILE SCORE1 <= 10 OR SCORE2 <= 10 !LOOP 2 stART

LET NOGUESSES = 0
DO while NOGUESSES <= 3 !loop 3 start

and the end loops were

LOOP until NOGUESSES = 3

LOOP until SCORE1 = 10 or SCORE2 = 10

all i forgot was

LOOP until NOGUESSES = 3 OR GUESS = NUM

and if i remember right and i am remembering right i figured it out and you just sat there like a fricken idiot

i am sorry i am a noobe and litterally just started 5 weeks ago and already came up wit my car loan program, numbergame, hangman, area volume calculator, and several others just for fun that weren't even assigned i just got bored.

look i'm not good at these chat room fights. lets talk in programming tomorrow and keep this shit off the forum because this is immature and is probably pissing a lot of people off. so i'm sorry everyone and i'm keeping this shit off the forum, and tim i'll talk to you tomorrow.

Re: Daranhiss program ...

bubbachunk ... I have no intention of helping Daranhiss write his game program. You can see he a long way from writing the GAME code; he's been writing his "tutorial" code, and he's a long way from completing that code too.

I am intrigued by his use of "nested" DO loops. The TB Silver/Gold manuals don't say much about nested IF and/or SELECT CASE code structures.

If there's anyone out there who IS an expert on these code structures, PLEASE STAND UP!

For me, I'm willing to spend valuable time in learning how to study and possibly debug "challenging" code examples like the Daranhiss program. Hey! I think I'll Google "nested code structures". Regards ... Tom M

Nested loops

Hi you guys,

Enough of the classroom fights.

The first point I should make is that you should attempt to make your program code readable - make it as close to English as you can. You can help by using meaningful variable names e.g.
LET P=S-C-O-E ! is not very instructive
LET profit=sales-costs-overheads-expenses ! reads much better.

The next point is that as early as possible learn to use SUB-ROUTINES. These will help to make code easier to understand and much easier to debug because you only have to debug little bits of code at a time. Usually sub-routines only have about 20 or lines. Each sub-routine undertakes a fairly simple task. In effect you split up your program into a succession of simple tasks. Basically this is what FLOW CHARTS are all about - they break down your program into simpler objectives in diagramatic form so that you can see how each is linked to make a whole.

Even very complex programs only have maybe a 100 lines of code. Most of these lines are calls to sub-routines. The subroutines can run into hundreds and more.

For example suppose we take the task of converting DATE$ into a more readable format, e.g.
CALL get_month_names(month$())
CALL get_month(monthnumber)
CALL get_day(daynumber)
CALL get_year(yearnumber)
LET human_date$=str$(daynumber) & month$(monthnumber)& str$(yearnumber) ! e.g. 15 October 2009

You can see immediately what is going on and how the task has been broken down. The routines themselves (in this instance) are very simple, e.g.
SUB get_month(monthnumber)
LET monthnumber=val(DATE$[5:6])
END SUB

If Darranhiss had adopted these guidelines he would not have run into trouble in the first place. Instead of using complex nested LOOPS he could have started with the first loop and called a sub routine containing the second loop and so on. Debugging this sort of code would have been infinitely easier.

Have fun guys.

Big John

thank you big J

thanks the point is that i never really learned how to do these "sub routines" because our teacher only did not even a day on them so if you could make an example in another forum it would be greatly appreciated.

regards Tim R

SUB-ROUTINES

Hi,

Sub-routines are no big deal.

Let's assume you have a fairly simple program that begins with the first statement and ends with the END statement. As your program runs it deals with each line in turn EXCEPT when it encounters a CALL to a sub-routine. At that point the program skips off to look for the sub-routine that you have named in the CALL. When the program finds the sub-routine it process each line in the sub-routine as if it was a mini program until it gets to the END SUB statement. At that point the program returns to your main program where it left off.

For the moment we can forget about parameters in sub-routines because they will confuse the issue.

For now, all you need to know is that the sub-routine must have a name (with no spaces) and when you want to use it you just CALL it by that name. The sub-routine itself must begin with the keyword SUB, e.g.

SUB get_month
LET monthnumber=val(DATE$[5:6])
END SUB

and the sub-routine must end with END SUB.

You can put the sub-routine code anywhere you like, but I would advise you to put all your sub-routines at the end of your program, just before the END statement. That way you will always know where to find them.

You can put as much or as little code as you like in a sub-routine. Generally you make each routine do just one simple job, because it is easier to degub that way.

The sub-routine knows all the values of variables in your program and can do calculations or operations on them. Your main program will also know what the routine has done with those variables too.

Not so difficult after all.

Regards

Big John

Re: SUB-ROUTINES ...

Big John ... Gee! Who would have thought - 5 days ago - that my posting of a school student's defective computer program listing would have launched such a wide-ranging number of "classroom" sessions on basic computer programming! Subprograms, infinite loops, flow charts, True BASIC (what's that?). Wow!

We need more of these super-sessions. We're EDUCATING AMERICA!! Regards ... Tom M

Educating America

Hi Tom,

Let's hope it's not just America we are educating.

It does occur to me that reproducing some of the examples in the superb DOS manual (version 3.05) would be very instructive for novice programmers. None of the manuals written since then have been anywhere near as good.

Maybe one article per week would be a good start. After we have shown a complete set we could just repeat it for those that missed it first time around. I can even post each article on my website for those that want to download them. What do you think?

Big John

Hi I'm just butting in real quick

I think that would be a great idea to make your article once a week. I think that i could learn a lot from your articles.

if you wouldnt mind could i

if you wouldnt mind could i have the link to that site

Re: Educating America ...

Big John ... There are several books that can be used to teach rudimentary True BASIC, and I own them all. Let's start with the "DiscoveryPak: 52 Ready-to-Run True BASIC programs for Fun and Learning", $30 back in 1993. That was when TB vsrsion 3.xx was in vogue.

This book's Chapters address a wide range of subjects, including:

ART, CODES & PUZZLES, ENVIRONMENT, GAMES, GEROGRAPHY, HEALTH, HISTORY, HOME & OFFICE, IT'S YOUR MONEY, MUSIC & SOUND, NUMBER FUN, SCIENCE, TIME & DATES, and WORD WISE.

It shouldn't be difficult to update the book's programs so they work flawlessly in TB version 5.

There are several other books I could mention. Regards ... Tom M

nice

Guys that sounds great if we could learn more it would make it easier and better to learn other programs. like chunk hes making pacman outa class for fun we need people like him and me and anyone else thats out there that does the same thing to post there questions this is how good programmers are made.