Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: Hotshot on January 05, 2009

Title: Matrix Console Screen
Post by: Hotshot on January 05, 2009
Code: [Select]
Dim As Integer x,y,choice

Locate 25,55
Print "press Esc key to exit...";       
   
Do         
    x=Rnd * 80
    Y=Rnd * 25
   
    Locate y,x
   
    choice=Rnd(1)
       
    Select Case As Const Choice
            Case 0
                    Color 10
                    Print "1";                   
            Case 1
                    Color 2
                    Print "0";
        End Select
   
Loop Until  Inkey = Chr(27)

 :)
Title: Re: Matrix Console Screen
Post by: Shockwave on January 05, 2009
Cool :)

Use the extended ascii set and scroll them down the screen and it will look pretty authentic :)
Title: Re: Matrix Console Screen
Post by: bikerboy on January 05, 2009
it looks nice and it surely could be imroved with some other characters and motion.

continue coding ;)

Ps. you forgot to put it to sleep :P

Code: [Select]
End Select
   
Loop Until  Inkey = Chr(27)

should be
Code: [Select]
End Select
sleep 1
Loop Until  Inkey = Chr(27)

or this one (correct me someone if i'm wrong with this, it's the first time i'm doing it)

Code: [Select]
DIM SHARED AS DOUBLE OLD,DV
Dim As Integer x,y,choice
        Locate 25,55
        Print "press Esc key to exit...";       
   
Do   
    x=Rnd * 80
    Y=Rnd * 25
   
    Locate y,x
   
    choice=Rnd(1)
    OLD=TIMER 
    Select Case As Const Choice
            Case 0
                    Color 10
                    Print "1"                 
            Case 1
                    Color 2
                    Print "0"
        End Select
        sleep 1
        DV=TIMER-OLD
Loop Until  Inkey = Chr(27)
Title: Re: Matrix Console Screen
Post by: Shockwave on January 05, 2009
Sleep (time in millisecs) pauses your program and returns some time to the operating system, it's good practice to do this as Bikerboy said.