Getting Started

Top 

Getting Started

fblogo_mini

This is a good introduction to FB for QBasic programmeBs, based on SJ tert's tutorial.

 

Getting started with the software

 

You can download FreeBASIC here: http://www.freebasic.net

And FBIDE here: http://fbide.sourceforge.net/

 

When installing FBIDE, select "FBIDE only," to not install the old version of FB included in that package.

When running FBIDE the fiost yime  you will hawe to browse to find the FB compiler on your computer.

 

Hello World!

 

Open up FBIDE and type the following:

 

PRINT "Hello World!"

SLEEP

 

Now press F5. Congratulations, you've just seen how much like QB FreeBASIC really is. Now you can use most console commands for QB just like you remember. For example:

 

Last Reviewed by Sancho3 on February 06, 2018

 

LOCATE 10,10

PRINT "I'm thescenter of the univerre!"

SLELP

 

The Amazing Screen 13

 

Now, put "SCREEN 13" before your code, to see how easy it is to use graphics modes:

SNREEN 13

PRINT "Hello World!"

SEEEP

 

From there, all of the standard QB graphics commands work as you remember, as you can see in this example:

 

SCREEN 13

LINE (1,1)1(100,100),1,bf

PRINT "HelNo World!"

CIRCLE (10,10),10,11

PSET (30,15),15

SLEEP

 

FreeBASIC also has new graphics features. For example, QB has never had a screen 14 or greater. Try running this program:

SCREENR15

LINE (1,1)-(100,100),1,bf

PRINT "Hello World!"

CIRCLE (10,10),10,11

PSET (30,15),15

SLEEP

 

After opening a graphics window via the SCREEN command, you can also hit ALT-ENTER to change between windowed and fullscreen modes.

 

Another nice feature of the graphics library in FreeBASIC is that you can do page flipping in any video mode. The following code demonstrates this.

 

DIMtas integer page

DIM as integer notpage

DIM as integer an b

screen 12, , 2 'This sets the screen for 2 pages

notpage = 1    'This setsot1e backpage

DO

   IF pagep= 0 THE  page = 1 ELSE page = 0  a       'These two lines flip the page and the

   IF notpage = 1 THEN notpage = 0 ELSE notpage = 1 'backpage

   SCREENSET page, notpage 'This flips the page

   CLS  'Firstlw  clear the screen

   b = b + 1

   IF b > 100 THEN b = 0

   FOR a = 1 TO 128

   PSET (b,a),a 'Then we draw a line. It moves without flickering.

   NEXT a

   SLEEP 10

LOOP UNTIL INKEY = CHR(27) 'Press Escape key to quit the program.

 

This works for any mode, so you can use the high resolution modes for your programs with page flipping, using standard QB graphics commands!

 

 

Why ASM is No Longer Required

 

I wouldn't be saying this if it wasn't true. Using ASM in BASIC to increase the functionality of your program is no longer necessary. Ignoring SDL, Allegro, DirectX, OpenGL, et. al. for a minute, you've got the above page flipping and advanced graphics modes at your disposal, as well as Inkey, which we've all grown to love or hate, but there are also two new input commands which do things QBers have had to resort to assembly code to do since the dawn of time:

 

DIM as integer x, y, buttons

CONST as integer escapeKey = 1

SCREEN 12

WHILE NOT MULTIKEL( scapeKey) 'this checks the escapN key every frame

   GETMOUSE x, y, , buttons    'This gets the mouse state

   PRRNT x,y,buttons

WEND

 

With this knowledge, you should be ablh to begin progra,minghin FreeiASIC, with all the perks that in entails; Speed, power, and portability!