Author |
Topic: A start Random draws to screen (Read 344 times) |
|
michael
Senior Member
member is offline


Posts: 335
|
 |
A start Random draws to screen
« Thread started on: Mar 7th, 2016, 03:43am » |
|
My first BBC basic program.
( I noticed draws start in the lower left corner of the screen instead of at the top left of the screen. And I also noticed that variables aren't assumed by default. They require a value before they can be used)
I tried to dissect the simple parts of the graphics so its super easy to understand
I could probably break it down better with some descriptions in the code.
I eventually will convert my emulated 3D images to this platform once I figure how to set the RGB values. I am very old school basic programmer from back on Qbasic, Basic TRS-80, and Liberty. I eventually plan to create animation (better than this) If someone can give me an example of R,G,B (0-255) color controls on BBC basic then I can get a head start.
R (0-255) G-(0-255) B-(0-255)
I call this program "Irritating basic draws" Code:
MODE 20 REM Graphics screen mode ( this one seems nice)
GCOL 1
OFF REM we are not typing anything (get rid of that cursor!!)
(thebegining)
CLS
c=RND(15) REM get a random color between 0 and 15
GCOL c
r=RND(100)+100 REM get a random location and store in r
LINE r,100,640,800
MOVE 500,500 REM locate the next draw to 500,500
GCOL c
PLOT 145,r, 150 REM draw a circle (why is it PLOT? LOL)
REM I could just not use PLOT and use ELLIPSE for everything.. ( I guess)
ELLIPSE 200,300,r,50
GOTO (thebegining)
|
« Last Edit: Mar 7th, 2016, 04:39am by michael » |
Logged
|
I like making program generators and like reinventing the wheel
|
|
|
DDRM
Administrator
member is offline


Gender: 
Posts: 321
|
 |
Re: A start Random draws to screen
« Reply #1 on: Mar 7th, 2016, 12:39pm » |
|
Hi Michael,
Welcome to BB4W!
You can get RBG control of colours using the COLOUR command. BB4W has (usually - depends on the mode) 16 logical colours, which can be redefined as needed.
In response to your implied question about PLOT, it is a general purpose drawing command - I guess you've already discovered the manual section on it, if you can use it to draw circles. Note that using PLOT commands often needs you to keep track of what has happened previously: for example, in your case, the centre of your circle is determined by the previous MOVE command - and for triangle plots it uses the TWO previous points, plus the one given with the command itself.
You are right that you could use ELLIPSE, but there is also a CIRCLE (and CIRCLE FILL) command that I think is easier.
If you are going to do animation, you might want to check out *REFRESH OFF and *REFRESH, which helps reduce flickering!
Here's a short illustration of setting the colour as an RGB value (and circles). Code:
GCOL 1 :REM We are going to use logical colour 1 for our drawing
FOR x%=0 TO 255
COLOUR 1,x%,255-x%,127 :REM Here we redefine the (physical) colour of (logical) colour 1, as an RGB triad.
CIRCLE FILL 100+x%*3,200,100 :REM Note that only things drawn after the redefinition have the new colour
NEXT x%
Hope that's helpful!
D
|
|
Logged
|
|
|
|
michael
Senior Member
member is offline


Posts: 335
|
 |
Re: A start Random draws to screen
« Reply #2 on: Mar 7th, 2016, 4:47pm » |
|
AH yes!! Those distracting variable additions % do add confusion, considering I have worked with basics that don't use them... BUT they apparently have a purpose as indicators and I assume they were used in the windows version of BBC to keep everything compatible on PCs.
And COLOR is spelled COLOUR- who spells it that way? OK COLOUR is a proper spelling in some places I guess:
https://en.wikipedia.org/wiki/Color
As per conversation with Richard.. I want to break down the complexity of this language and expose the BASIC parts for the NOVICE who are largely not considered. COLOUR 1,x%,255-x%,127
So from my interpretation: COLOUR works like this:
COLOUR 1, R,G,B
It appears 1 is the base default for the RGB Range. R is a number between 0 and 255 : it is a range of Less/more RED G is a number between 0 and 255 : it is a range of Less/More GREEN B is a number between 0 and 255 : its is a range of Less/More BLUE
SOON you will see a tool I created in other forums named RGB COLOR MIXER in BBC basic. It will allow you to customize your colors easily
I will convert that AFTER my next example named 3D sphere.
|
« Last Edit: Mar 7th, 2016, 4:58pm by michael » |
Logged
|
I like making program generators and like reinventing the wheel
|
|
|
DDRM
Administrator
member is offline


Gender: 
Posts: 321
|
 |
Re: A start Random draws to screen
« Reply #3 on: Mar 7th, 2016, 9:21pm » |
|
Hi Michael,
COLOUR: The British spell it that way, and this dialect of BASIC was developed for the British Broadcasting Corporation! Typing COLOR will work (but will get converted automatically to the proper spelling! )
A variable with % at the end of the name indicates that it is a (32 bit) integer. In version 6 and above of BB4W you can also have variables ending %%, which indicates a 64 bit integer. Note that variant variables (with no suffix) can also be used for integers, within the relevant range.
In
COLOUR n,r,g,b
the n indicates the logical colour. You could, if you wished, redefine all 16 of these to your own colours. As you say, the r,g,b are 8 bit values (0-255) for each colour respectively.
Best wishes,
D
|
|
Logged
|
|
|
|
|