Jumat, 27 Maret 2020

SMALL BASIC: Making video intro like matrix

Hello, SMALL Basic Programmer.

In this tutorial, we will learn about how to make video intro like matrix. You can watch the video below to see. You can also uses this program as a video therapy when you want to sleep (I found out that this program can be a video therapy when I stared the code running too long; it kinda give me some calm effect to my brain) or you can use it as video banner of your youtube video.


The program is dividing the width of the graphics window with the area the determined by the user, the result is x.

This is kinda confusing but the point is x, and the loop start from 0 to x - 1.


There are problems that arise:
1. You need to be continuous between the cloters number
2. How to make the Text always in front position not in the back position.
3. Etc,.

You can watch the movie here:



In this program, we devide it in two:
1. The first version
2. The last completed version



This is the 1st style program:

GraphicsWindow.Show()
GraphicsWindow.Width = Desktop.Width
GraphicsWindow.Height = Desktop.Height
GraphicsWindow.Top = 0
GraphicsWindow.Left = 0

TextWindow.WriteLine("Hello, welcome to the matrix board created with Small Basic.")
TextWindow.WriteLine("Created by: Jesus Christ, the Lord and Messiah.")
TextWindow.WriteLine("1. Enter what background color that you want to use: ")
bc = TextWindow.Read()
TextWindow.WriteLine("2. Enter what font color that you want to use: ")
fc = TextWindow.Read()
TextWindow.WriteLine("3. Enter the font size that you want to use (default is 12): ")
fs = TextWindow.Read()
TextWindow.WriteLine("4. Enter the font name that you wan to use (for ex. Times New Roman)")
fn = TextWindow.Read()
TextWindow.WriteLine("5. Enter the font space : ")
fsp = TextWindow.Read()
TextWindow.WriteLine("6. Enter the text that you want to enter: ")
tte = TextWindow.Read()
TextWindow.WriteLine("7. Enter the size of the text that you want to use: ")
sott = TextWindow.Read()
TextWindow.WriteLine("8. Enter the x position of the text that you want to use: ")
xpt = TextWindow.Read()
TextWindow.WriteLine("9. Enter the y position of the text that you want to enter: ")
ypt = TextWindow.Read()

'Set the graphics settings based on the input from the user
GraphicsWindow.BackgroundColor = bc
GraphicsWindow.BrushColor = fc
GraphicsWindow.FontSize = fs
GraphicsWindow.FontName = fn

GraphicsWindow.FontSize = sott
GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
GraphicsWindow.DrawText(GraphicsWindow.Width/2,GraphicsWindow.Height/2,tte)

GraphicsWindow.BrushColor = fc
GraphicsWindow.FontSize = fs
ics = fsp + fs
nocpw = GraphicsWindow.Width / ics


continue = 1

  For i = 0 to nocpw
    td = Text.GetCharacter(Math.GetRandomNumber(100))
    TextWindow.WriteLine(td)
    ts[i] = Shapes.AddText(td)
    Shapes.Move(ts[i],i*ics,0)
    'group = group + 1
    'Program.Delay(100)
  EndFor
  maks = i

While continue = 1
  For i = 0 To Array.GetItemCount(ts) - 1
    x = Shapes.GetLeft(ts[i])
    y = Shapes.GetTop(ts[i])
    'TextWindow.WriteLine(x)
    'TextWindow.WriteLine(y)
    Shapes.Move(ts[i],x,y+fs)
    'Program.Delay(100)
    EndFor
 
 
  'This part is for adding new sprites
  For j = 0 to nocpw
    'maks = maks + 1
    i = maks + j
    td = Text.GetCharacter(Math.GetRandomNumber(100))
    'TextWindow.WriteLine(td)
    ts[i] = Shapes.AddText(td)
    Shapes.Move(ts[i],j*ics,0)
    'TextWindow.WriteLine("Testing")
    'Program.Delay(100)
  EndFor

  maks = i
  endwhile

  sub nantiajalah
    For i = 0 To Array.GetItemCount(ts) - 1
      Shapes.Move(ts[i],Shapes.GetTop(ts[i]),shapes.GetLeft(ts[i])+ fs)
      'Program.Delay(1000)
      'gt = Shapes.gettop(ts[i])
      'gl = Shapes.GetLeft(ts[i])
      'TextWindow.WriteLine("gt : " + gt + ", gl : " + gl)
      EndFor
  endsub
   




This is the completed version:
GraphicsWindow.Show()
GraphicsWindow.Width = Desktop.Width
GraphicsWindow.Height = Desktop.Height
GraphicsWindow.Top = 0
GraphicsWindow.Left = 0
GraphicsWindow.Title = "Jesus Christ the Lord and Messiah - Graphicswindow"
TextWindow.Title = "Jesus Christ the Lord and Messiah - Textwindow"
'TextWindow.WriteLine("")

TextWindow.WriteLine("Hello, welcome to the matrix board created with Small Basic.")
TextWindow.WriteLine("Created by: Jesus Christ, the Lord and Messiah.")
TextWindow.WriteLine("Year: 2020, amid of Coronavirus outbreak.")
TextWindow.WriteLine("Ok, lets begin...")
TextWindow.WriteLine("=============================================================")
TextWindow.WriteLine("")
TextWindow.WriteLine("1. Enter what background color that you want to use (default is orange): ")
bc = TextWindow.Read()
TextWindow.WriteLine("2. Enter what font color that you want to use (default is yellow): ")
fc = TextWindow.Read()
TextWindow.WriteLine("3. Enter the font size that you want to use (default is 12): ")
fs = TextWindow.Read()
TextWindow.WriteLine("4. Enter the font name that you want to use (default is Times New Roman): ")
fn = TextWindow.Read()
TextWindow.WriteLine("5. Enter the area width of each character (default is 5): ")
wec = TextWindow.Read()
TextWindow.WriteLine("6. Enter the text that you want to enter (default Jesus Christ is the Lord and Messiah!): ")
tte = TextWindow.Read()
TextWindow.WriteLine("7. Enter the size of the text that you want to use (default is 12): ")
sott = TextWindow.Read()
TextWindow.WriteLine("8. Enter the x position of the text that you want to use (default is 0): ")
xpt = TextWindow.Read()
TextWindow.WriteLine("9. Enter the y position of the text that you want to enter (default is 0): ")
ypt = TextWindow.Read()


TextWindow.Write("Ok, Lets draw")
For i = 0 To 2
  TextWindow.write(".")
  Program.Delay(1000)
EndFor


'This part is for Userinput validation
If bc = "" Then
  bc = "Orange"
Else
EndIf

If  fc = "" Then
  fc = "Yellow"
Else
EndIf

If fn = "" Then
  fn = "Times New Roman"
Else
EndIf

If wec = "" Then
  wec = 5
Else
EndIf

If tte = "" Then
  tte = "Jesus Christ is the Lord and Messiah!"
Else
EndIf

If xpt = "" Then
  xpt = 0
Else
EndIf


If ypt = "" Then
  ypt = 0
Else
EndIf


If sott = "" Then
  sott = 36
  GraphicsWindow.FontSize = 36
Else
  GraphicsWindow.FontSize = sott
EndIf

If fs = "" Then
  fs = 12
  GraphicsWindow.FontSize = 12
Else
  GraphicsWindow.FontSize = fs
EndIf

'TextWindow.WriteLine("sott is this: " + sott)
'TextWindow.WriteLine("fs is this: " + fs)

GraphicsWindow.BackgroundColor = bc
GraphicsWindow.FontName = fn

'Program.Delay(5000)
GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
gbc = GraphicsWindow.BrushColor


'GraphicsWindow.DrawText(GraphicsWindow.Width/2,GraphicsWindow.Height/2,tte)
wec = wec + fs 'area width
'TextWindow.WriteLine("ini wec: " + wec)
'Program.Delay(6000)
myt = Shapes.AddText(tte)

'TextWindow.WriteLine("OK")
shapes.Move(myt,xpt,ypt)


GraphicsWindow.BrushColor = fc


spot = GraphicsWindow.Width / wec

'TextWindow.WriteLine("ini spot: " + spot)
'Program.Delay(5000)

continue = 1


'This creating the 1st cloter
  For i = 0 to spot - 1
    'td = Text.GetCharacter(Math.GetRandomNumber(100))
    td = Math.GetRandomNumber(99)
 
    'TextWindow.WriteLine(td)
    ts[i] = Shapes.AddText(td)
    Shapes.Move(ts[i],i*wec,0)
    'TextWindow.WriteLine(i + "dengan nilai: "+ td)
    'group = group + 1
    'Program.Delay(1000)
 
  EndFor

  'TextWindow.WriteLine("ini i : " + i - 1)
  'Program.Delay(5000)
  'Goto eof
  'TextWindow.WriteLine(i)
  'maks = i
  'TextWindow.WriteLine("maks : " + maks)

While continue = 1
  'This part is for moving all sprite down one fontsize to the bottom

  For i = 0 To Array.GetItemCount(ts) - 1
    'TextWindow.WriteLine(ts)
    'Program.Delay(5000)
    'TextWindow.WriteLine("Ini nilai panjang ts: "+ Array.GetItemCount(ts))
    'Goto eof
    'Program.Delay(100)
    x = Shapes.GetLeft(ts[i])
    y = Shapes.GetTop(ts[i])
    Shapes.Move(ts[i],x,y+wec)
    'TextWindow.WriteLine("Total elemen adalah: " + array.GetItemCount(ts) - 1)
    'TextWindow.WriteLine("ini adalah i penurunan: " + i)
    'TextWindow.WriteLine("Ini adalah elemennya nilai: " + ts[i])
    'Program.Delay(500)
  EndFor

    'TextWindow.WriteLine(ts)
    'TextWindow.WriteLine("jumlah yang telah diturunkan : " + i - 1)
    'TextWindow.WriteLine("###############################")
    'Program.Delay(5000)
 
    'This part is for creating new sprites for total nocpw
 
    start = Array.GetItemCount(ts)
   For i = 0 to spot - 1
 
    'TextWindow.WriteLine(ts)
    'Program.Delay(5000)
    'td = Text.GetCharacter(Math.GetRandomNumber(100))
    td = Math.GetRandomNumber(99)
    'TextWindow.WriteLine("dibawah: " + i +", td : " + td)
    'TextWindow.WriteLine("nilai: "+ td)
    GraphicsWindow.BrushColor = fc
    GraphicsWindow.FontSize = fs
    ts[i+start] = Shapes.AddText(td)
    Shapes.Move(ts[i+start],i*wec,0)
    'Program.Delay(5000)
  EndFor
  'TextWindow.WriteLine("Total element hingga sekarang: " + Array.GetItemCount(ts)-1)
  'TextWindow.WriteLine("###############################")
  'Program.Delay(5000)
  maks = i

  'This part is for recreating the text, so it can't get behind the rainning characters
  'A.k.a this is for the shape get in front of the rainning character


  Shapes.Remove(myt)
  GraphicsWindow.FontSize = sott
  GraphicsWindow.BrushColor = gbc
  myt = Shapes.AddText(tte)
  shapes.Move(myt,xpt,ypt)
  GraphicsWindow.FontSize = fs
  GraphicsWindow.BrushColor = gbc
  endwhile


   

eof:

Tidak ada komentar:

Posting Komentar