Post by Azan on Mar 11, 2005 16:54:48 GMT -5
Intro to Blitz
Okay this tutorial is for you if you have never programmed before or have programmed but you have never programmed in Blitz Basic. In this tutorial we will.
~ learn how to create/alter variables
~ learn how to create simple loops
~ learn how to use simple if statements
~ eventualy create a simple guessing game
In this tutorial I will not teach you how to...
~ create functions
~ work with graphics
~ smoke crack
~ use types
Ok lets get started first of all open up blitz then go to File then New, ok first lets create a variable, I chose to go with x but you can choose whatever you want, make x equal to zero like this.
x=0
now below x make a new variable lets call this one s (for stop) and make s equal to zero, your program should now look like this.
x=0
s=0
Okay now we will be creating a while loop for this lets first type while below s then after while put s=0: your program should now look like this.
x=0
s=0
While s=0:
Ok now this is saying that as long as s is equal to zero it will go through the loop (and as you can see s does equal zero) but now lets go one line down below our loop, and put in x=x+1 this is saying that each time the program goes through the loop 1 is added to the value of x, now below that put this in print x this is telling the program to put the value of x on the screen each time the loop goes through it, now to close our while loop below the print statement add "wend" wend closes a while loop, our program should now look like this.
x=0
s=0
While s=0:
x=x+1
Print x
Wend
and now we can run our program just hit F5 the values of x should go up constantly if you did it right. if we want to break the loop all we need to do is add 1 to s but for this case lets change our while loop, where it says while s=0: change it to while x<2000 and run it, the program should go all the way up to 2000 and stop.
Ok now that you have some idea of how loops and variables work lets go on to If statements
1st lets make the following variables n and s make them both equal zero then we make a while loop just like we did above.
s=0
n=0
While s=0:
Ok now we add this below it
i=input(":")
input will allow a person to add input into the line now below that add
if i=n then print "You win"
and below that put
if i<n then print "too low"
and below that put
if i>n then print "too high"
and below that close the while with
And that finishes this tutorial, heres a more high tech form of the game we just made, it has a counter and imports a random number for the secret number.
wend
SeedRnd (MilliSecs())
n=Rand(1,100)
st=0
c=0
Print "Welcome to guessing game"
While St=0:
inp=Input(":")
If c>10 Then Print "you suck"
If inp<n Then Print "Too low" c=c+1
If inp>n Then Print "too high" c=c+1
If inp=n Then c=c+1 Print "you win it took you "+c+" guesses" st=st+1
If c>10 Then Print "you suck"
Wend
If you have any questions regarding this tutorial please feel free to post questions in this thread.
Copyright: This document may not be posted anywhere else but ragnarokcom.proboards33.com with out the authors consent, by posting anywhere else with out the authors consent you are agreeing to give me your soul mwahahaha (but feel free to post links to this site/tutorial on other sites).