Qbasicnews.com

Full Version: Challenge....
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
What about Ctrl + Break? Tongue
Quote:Cool screensaver. Putting the variables in a string can save you at least 2 lines of code.

Hmm...you're right. Ok, here's that version, making it a 7 line saver doing the exact thing...

Code:
1  SCREEN 13   'below holds the clr%, x%, y%
2  A$ = CHR$(16) + MKI$(RND * 320) + MKI$(RND * 200)
3  FOR z% = (RND * 15 + 1) TO 1 STEP -1
4      CIRCLE (CVI(MID$(A$, 2, 2)), CVI(MID$(A$, 4, 2))), z%, ASC(MID$(A$, 1, 1))
5      IF INKEY$ = "" THEN PAINT (CVI(MID$(A$, 2, 2)), CVI(MID$(A$, 4, 2))), ASC(MID$(A$, 1, 1)) ELSE END
6      IF z% = 1 THEN GOTO 2 ELSE MID$(A$, 1) = CHR$(ASC(MID$(A$, 1, 1)) + 1)
7  NEXT

(sorry if that code word-wraps on your screen)

- Dav
Kewl ScreenSaver guys!!!!
Heres a Matrix like screen saver. I cant get it down to 9 lines with the palette changing code so Ill make that optional.

Code:
1 screen 12
2 FOR k = 1 TO 33 STEP 8
3   FOR i = 1 TO 6
4     COLOR INT(RND * 15) + 1
5     LOCATE 29, (i + k - 1) * 2
6     IF k = 33 AND i = 6 THEN PRINT INT(RND * 10) ELSE PRINT INT(RND * 10);
7   NEXT
8 NEXT
9 IF INKEY$ = "" THEN GOTO 1

The optional palette code sits between lines 1 and 2 and sets the colors to 16 shades of green for a real Matrix look 8). I didnt actually write this bit and I cant remember who I stole it from either. ;-)
Code:
OUT &H3C8, 0
FOR i = 0 TO 15
OUT &H3C9, (0)
OUT &H3C9, (i * 4)
OUT &H3C9, (0)
NEXT
Actually you could fit it in 9 lines loose.

Tips:

1. Use Strings for vars as long as the values are less than 256 you could have as many vars in one line as you want.

2. One OUT statement is enough for rotations
Ie.
Do
X=(X+1) mod 1024
Out (&h3c8)+((X and 3)=0), "insert formula here
loop


3. You can do away with the For Do Loops
Played around with it a bit more (since I had 2 more lines to use Smile )

In this version, PALETTE is used both to make the gradient pallette and as a method for delay. Ball size is increased.

Big BLUE balls....

Code:
1  SCREEN 13
2  FOR c% = -1 TO 63
3    IF c% = -1 THEN A$ = MKI$(RND * 320) + MKI$(RND * 200) + CHR$(8) ELSE PALETTE c%, c% * 65536
4  NEXT
5  FOR z% = RND * 54 TO 0 STEP -1
6     MID$(A$, 5, 1) = CHR$(ASC(MID$(A$, 5, 1)) + 1)
7     IF INKEY$ = "" THEN CIRCLE (CVI(MID$(A$, 1, 2)), CVI(MID$(A$, 3, 2))), z%, ASC(MID$(A$, 5, 1)) ELSE END
8     IF z% = 0 THEN GOTO 2 ELSE PAINT (CVI(MID$(A$, 1, 2)), CVI(MID$(A$, 3, 2))), ASC(MID$(A$, 5, 1))
9  NEXT

- Dav
Quote:Cool screensaver. Putting the variables in a string can save you at least 2 lines of code.

Interesting screensaver Keyboard. But no exit condition? Sad
Thx :bounce:, in the QB IDE just press CTRL+Break.
(But it doesn't work if you compile it).
Wow!!!! These savers a great!!!!

Keep it up!!!

I would prolly post a Plasma when I get to code. Haven't code for 2 weeks 'cept for an hour yesterday.


My plasma would use Sin Additions. ie. Slow as hell

;*)
I made a plasma background for my NTLOADER.EXE program. (hehe).
Here is my screen saver. See if your eyes can stand it..

Code:
1 SCREEN 13
2 t% = RND * 345
3 WAIT &H3DA, 8
4 FOR i% = 0 TO 199
5 FOR j% = 0 TO 319
6 k% = ((k% + t% XOR j% XOR i%)) AND &HFF
7 PSET (j%, i%), k%
8 NEXT j%, i%
9 IF LEN(INKEY$) THEN END ELSE GOTO 2
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22