Page 1 of 1

FreeBASIC graphics tutorial An introduction to graphics in freeBASIC

#1 paperclipmuffin  Icon User is offline

  • Disassembling...
  • member icon

Reputation: 13
  • View blog
  • Posts: 944
  • Joined: 16-April 09

Posted 08 May 2009 - 12:21 AM

Paperclip Muffin's freeBASIC tutorial: Graphics
- - - - - -
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:
screen 13


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 1321 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
coloured circles.
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.
Good luck! ;)

This post has been edited by paperclipmuffin: 14 May 2009 - 12:53 AM


Is This A Good Question/Topic? 0
  • +

Replies To: FreeBASIC graphics tutorial

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,517
  • Joined: 23-August 08

Posted 11 May 2009 - 02:02 PM

Can you explain the screen modes some more, perhaps?
Was This Post Helpful? 0
  • +
  • -

#3 paperclipmuffin  Icon User is offline

  • Disassembling...
  • member icon

Reputation: 13
  • View blog
  • Posts: 944
  • Joined: 16-April 09

Posted 14 May 2009 - 12:40 AM

View PostJackOfAllTrades, on 11 May, 2009 - 01:02 PM, said:

Can you explain the screen modes some more, perhaps?

OK. Am I allowed to edit this? :blink:
Was This Post Helpful? 0
  • +
  • -

#4 firebolt  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 92
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Posted 20 May 2009 - 12:17 AM

If the edit button is still visible.
Was This Post Helpful? 0
  • +
  • -

#5 Braber01  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 247
  • Joined: 29-November 08

Posted 21 April 2012 - 12:56 PM

Would you mind explain Pointers In FreeBasic?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1