- - - - - -
Hi, and welcome to my first freeBASIC tutorial.
Why another freeBASIC tut, you ask? Well, although there are many out there, they are all either ultra-beginner for the "Hello, World!" program or assume you are a veteran and go straight into great detail. This, however, is different. I will assume you know the basics of BASIC, but only the basics. Here I will explain the stuff you need to know in this tutorial
gap. However, rapidly moving on...
- - - - - -
*-=THE ACTUAL TUTORIAL=-*
Before you can add graphics to your program, you need to set your screen mode. This can be done very easily:
The SCREEN means graphics mode.
SCREEN 0 Sets the screen mode to text mode
SCREEN 1 Sets the screen mode to graphics mode 320x200 with 4 colours (!!!)
SCREEN 2 Sets the screen mode to monochrome (only two colours!!!) graphics mode 640x200
SCREEN 7 Sets the screen mode to graphics mode 320x200 with 16 colours (very useful in the past)
SCREEN 8 Sets the screen mode to graphics mode 640x200 with 16 colours (not as useful)
SCREEN 9 Sets the screen mode to graphics mode 640x350 with 16 colours (VERY useful in the past)
SCREEN 11 Sets the screen mode to graphics mode 640x480 with 2 colours (blue and black ????)
SCREEN 12 Sets the screen mode to graphics mode 640x480 with 16 colours
SCREEN 13 Sets the screen mode to graphics mode 320x200 with 256 colours!
SCREEN 13…21 These set the screen mode to graphics mode with at least 320x240 with 256 colours. You can also specify how many bits per pixel there are.
Now let's add something a lot more exciting:
screen 13 circle (150,100),8 sleep
Here we tell the computer to draw a circle at coordinates 150x100, which is the centre on the 300x200 screen, and it will
have a diameter of 8. Then sleep. Pretty simple, eh? Let's spice it up a bit:
screen 13 circle (150,100),20,2 circle (150,100),10,3 sleep
Now we have COLOUR! The 2 and 3 determine the colour of our circles. Try making your own program with more, differently
Finally, the grand finale. We will create a circle-text hybrid program with input. Behold:
screen 13 do circle (42,155),22,2 locate 20, 5 print "Press t" loop until inkey()="t" do circle (100,155),22,3 locate 20, 10 print "Now press y" loop until inkey()="y" do circle (158,155),22,4 locate 20, 19 print "Now u" loop until inkey()="u" circle (218,155),22,5 locate 20, 26 print "Okey Dokey!" sleep
Locate will put any text you then request to be printed at a particular point on the computer screen. Cool, huh? However, a flaw in this approach is that the locate coordinates are different to and sometimes do not match the
circle coordinates. Now you know about screen, circle and locate you can fool about and make your own graphical programs in freeBASIC.
This post has been edited by paperclipmuffin: 14 May 2009 - 12:53 AM