TIP: Click on subject to list as thread! ANSI
echo: quik_bas
to: Brian Iglesias
from: Greg Easthom
date: 2003-08-08 05:41:00
subject: the matrix

BI> i am trying to make a matrix screen program but i am unable
BI> to make the characters "fall" from the top of the screen.
BI> does anyone have an idea on how to do that?

How about this....

(Fancy programmers might use PEEK and POKE and DEF SEG and all
 those other functions that make me go "Huh????", but I prefer
 simple programming that anyone can understand).

My comments start with '''

'---[ matrix.bas ]---

DIM SHARED Oneline AS STRING * 80
CLS

COLOR 2
RANDOMIZE TIMER

''' Let's make a mess on "default" screen memory page 0 (zero)

''' bigger number = more time before message
FOR A = 1 TO 10000
  LOCATE INT(RND * 25) + 1, INT(RND * 79) + 1
    IF RND > .4 THEN PRINT " ";  ELSE PRINT CHR$(INT(RND * 242) + 14);
NEXT A

''' copy the "random" screen page 0 to page 1, without the message
PCOPY 0, 1

''' Now write the message on page 0
LOCATE 13, 18
COLOR 10
PRINT "   T h e   M a t r i x   H a s   Y o u . . .   "
COLOR 2

''' Let the message sink in for a couple of seconds....
SLEEP 2

'--------------------------------------------

''' Here's where we do the scrolling, until they hit a key
DO WHILE INKEY$ = ""

''' work on page 1, while still looking at page 0
SCREEN , , 1, 0
COLOR 2

''' Scroll page 1 by one line

''' First, working from (almost) the bottom up...
FOR L = 24 TO 1 STEP -1
  ''' Read the whole line off the screen a character at a time,
  ''' and put it into string "Oneline"
  FOR Char = 1 TO 80
    MID$(Oneline, Char, 1) = CHR$(SCREEN(L, Char))
  NEXT Char
  ''' Now print that line one line lower on the screen
  LOCATE L + 1, 1: PRINT Oneline;
NEXT L

''' Print a new random top line on page 1
FOR b = 1 TO 80
  LOCATE 1, b
  IF RND > .4 THEN PRINT " ";  ELSE PRINT CHR$(INT(RND * 242) + 14);
NEXT b

''' Now copy page 1 back to page 0 so you can see it
PCOPY 1, 0
''' Go back to working on page 0
SCREEN , , 0, 0

''' and immediately superimpose the message
LOCATE 13, 18
COLOR 10
PRINT "   T h e   M a t r i x   H a s   Y o u . . .   "
COLOR 2

''' Wait a bit between line scrolls (bigger number = slower scroll)
FOR q = 1 TO 10000: NEXT q

''' You may want to come up with a "test loop", basically
''' counting to a huge number to figure out how fast the
''' current machine is running, and use that instead of the
''' FOR-NEXT delay loops, otherwise the program may take
''' forever to scroll, or may go too fast, depending on whose
''' computer it's running on.

''' Go back and do it all again
LOOP

SYSTEM

'---[ end ]---


  * SLMR 2.1a *

--- Maximus 3.01
* Origin: The BandMaster, Vancouver, B.C., Canada (1:153/7715)
SEEN-BY: 633/267 270
@PATH: 153/7715 140/1 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.