edoz:
100 COLOR,0,0:SCREEN5:PSET(128,92),0:FORF=1TO96STEP.5:Y1=F*SIN(F):X1=F*COS(F):Y2=100-Y1:X2=125-X1:LINE-(X2,Y2),((F*2)MOD 15)+1:NEXTF 101 FORI=1TO15:CIRCLE(15,15),I,I:CIRCLE(240,15),I,I:NEXTI 110 FORI=1TO15:COLOR=(I,7,7,7):COLOR=(I,0,0,0):NEXTI:GOTO110
Who! on a turbo-r this is cool! ..
After the drawing you do some thrick with the colors... how is this visual effect working ?
Do you know the COLOR=
command? YOu can use it to set the pallette of each color. So, basically you can define the actual color displayed for that color number. In line 110 there is a loop over color 1 to 15 where the color is defined as white (7, 7, 7 = maximum value for R, G and B components, so it's white) and just after that again to black (0, 0, 0, minimum value for R, G and B components, so black).
I haven't run this, but it must be flashy as hell
No, I was not aware with the color= command. It's smart to change the palette. But by this you get some fast effects in Basic. So what's next in course
Whoa, great work NYYRIKKI! Cool to see the wiki extending from a forum topic like this. Keep up the good job!
There are some interesting basic programs that draw patterns in different colors (from 1-15) and then make a loop in basic to show only color N as white and the others as black. This gives an animation effect.
So, like this:
5 ' insert code here to create nifty picture 10 FOR N=1 TO 15 ' Loop over all colors 20 FOR C=1 TO 15' Another loop, to make all black 30 COLOR=(C, 0, 0, 0) 40 NEXT C 50 COLOR=(N, 7, 7, 7) 60 NEXT N 70 GOTO 10
But this is not very efficient/clean of course. Better is to remember which color was white last time:
10 FOR C=1 TO 15' make all black, note that this is outside of the main loop! So only runs once. 20 COLOR=(C, 0, 0, 0) 30 NEXT C 40 P = 0 ' previous color we made white (have to start somewhere) 50 FOR N=1 TO 15 ' Loop over all colors 60 COLOR=(P, 0, 0, 0) 70 COLOR=(N, 7, 7, 7) 80 P=N 90 NEXT N 100 GOTO 50
Actually, we know what the previous color was. It's just current minus 1. So this can be simplified, we really don't need P:
10 FOR C=1 TO 15' make all black, note that this is outside of the main loop! So only runs once. 20 COLOR=(C, 0, 0, 0) 30 NEXT C 50 FOR N=1 TO 15 ' Loop over all colors 60 COLOR=(N-1, 0, 0, 0) ' this goes wrong of course: if N = 1 we clear color 0 and not color 15... 70 COLOR=(N, 7, 7, 7) 90 NEXT N 100 GOTO 50
So, let's fix that bug... we need some expression that results in the following values for each N (the value of the previous N of the loop):
N outcome
1 15
2 1
3 2
...
14 13
15 14
So, as we already saw, in most cases N-1 was good enough. But when N=1 we want to get out 15 and not 0. We could make some simple IF to fix for that, but that looks worse than the P help variable we used before. So, indeed, I'm trying to find a single expression that based on N always gives me the right value according to the above table.
Finding that expression is left as an excercise for the reader! It shows that for nice programming, some math skills can come in handy.
Disclaimer: I haven't tried any of this stuff on an MSX.
EdoZ - so what do you want to learn about next?
@manuel: instead of n-1, one could use
(-((n-1)<1)*15)-(n>1)*(n-1)
so you would get
color=((-((n-1)<1)*15)-(n>1)*(n-1),0,0,0)
these are two simple equations: the first
-((n-1)<1)*15)
can be split in
(n-1)<1
if N is 1, then n-1 is 0. This gives a value of -1 (which means true, in MSX Basic). If N is 2 or bigger, it gives a value of 0 (which means false).
((n-1)<1)*15
We multiply this value (which is -1 or 0) by 15, so we get -15 or 0.
-((n-1)<1)*15)
and then change the sign (-*- is +), so this value is changed to 15 or 0
The second equation is
(n>1)
if n equals 1, then this returns 0, else it returns -1
(n>1)*(n-1)
and we multiply with the value of N, minus 1. If N equals 13, for example, n-1 equals 12. n>1 is -1. -1 *12 is -12.
we subtract that from the previous equation (and because it's -*-, it's actually an addition), and we get the value we wanted.
NYYRIKKI would probably do this in a much shorter version...
I also added my favourite BASIC-command to the WIKI BASIC-manual. :)
There are still SO many things missing...