Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QB text-based graphical screensaver in *just* 7 lines.
#9
Hah! In my 7-line submission, lines 3 and 6 are redundant! >:D Now I have another line to work with :)

*peace*

Meg

EDIT:

Adigun, I've been looking at both of our programs, and finding ways to optimize them and free up more lines.

Your initial program:
Quote:1 WIDTH 80, 50
2 COLOR 8, 0
3 x = INT(RND(1) * 78) + 1
4 y = INT(RND(1) * 48) + 1
5 LOCATE y, x
6 IF INT(RND(1) * 4) + 1 = 1 THEN PRINT CHR$(176) ELSE IF INT(RND(1) * 4) + 1 = 2 THEN PRINT CHR$(177) ELSE IF INT(RND(1) * 4) + 1 = 3 THEN PRINT CHR$(178) ELSE IF INT(RND(1) * 4) + 1 = 3 THEN PRINT CHR$(219)
7 GOTO 2

Can be recoded like this:
Code:
1 WIDTH 80, 50
2 COLOR 8, 0
3 LOCATE INT(RND * 48) + 1, INT(RND * 78) + 1
4 PRINT MID$("░▒▓█", INT(RND * 4) + 1, 1);
5 GOTO 3

The four characters in the string there are CHR$(176), CHR$(177), CHR$(178), and CHR$(219) but I'm not sure they display correctly.

I'm working on an updated submission that uses these changes, as well.

EDIT: This is my most current program
Code:
'7-line screensaver (submission #2)
'This program crawls around the screen displaying one of four characters.
'Color is either randomly black or is selected by formula which determines
'the location's distance from the center of the screen.

'change the x and y coordinate by random values (-1, 0, +1)
1 char.x& = char.x& + INT(RND * 3) - 1
2 char.y& = char.y& + INT(RND * 3) - 1

3

'locate the x and y coordinates on the screen.  Allow for wrap-around.
4 LOCATE 1 + ABS(char.y& MOD 24), 1 + ABS(char.x& MOD 80)

'set the color
5 IF INT(RND * 50) = 0 THEN COLOR 0 ELSE COLOR INT(RND * 2) + SQR(ABS((1 + ABS(char.y& MOD 24)) - 12) ^ 2 + ABS((1 + ABS(char.x& MOD 80)) - 40) ^ 2) \ 3

'print a random character
6 PRINT MID$("░▒▓█", INT(RND * 4) + 1, 1);

'exit if a key is hit, otherwise a delay/loop
7 IF INKEY$ <> "" THEN SYSTEM ELSE IF INT(RND * 1000) = 0 THEN GOTO 1 ELSE GOTO 7

This still has line 3 free. Not sure what to do with it, yet.
Reply


Messages In This Thread
QB text-based graphical screensaver in *just* 7 lines. - by Meg - 09-21-2004, 05:42 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)