Tuesday 20 May 2014

SMALL BASIC: Source code untuk Piano Sederhana

Berikut source code untuk piano di bahasa pemrograman SMALL BASIC. Silahkan kamu copy dan paste kan ke editor kamu kemudian jalankan atau Run atau tombol F5. Snapshot ada dibawah.

GraphicsWindow.Title = "Piano untuk Naomi"
GraphicsWindow.MouseDown = mouseclick
lebartutsputih = 50
tinggitutsputih = 200
lebartutshitam = 25
tinggitutshitam = 125

'penciptaan dan peletakkan tutshitam dan putih
GraphicsWindow.BrushColor = "yellow"
For i = 0 To 16
tutsputih[i] = Shapes.AddRectangle(lebartutsputih, tinggitutsputih)
shapes.Move(tutsputih[i],i*50,200)
EndFor

GraphicsWindow.BrushColor = "black"
For i = 0 To 16
  tutshitam[i] = Shapes.AddRectangle(lebartutshitam, tinggitutshitam)
  Shapes.Move(tutshitam[i],25 + i*50,200)
EndFor

Shapes.Remove(tutshitam[2])
Shapes.Remove(tutshitam[6])
Shapes.Remove(tutshitam[9])
Shapes.Remove(tutshitam[13])
Shapes.Remove(tutshitam[16])

'pengkondisian
Sub mouseclick
  ''UNTUK TUTS1
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[0]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[0]) + lebartutsputih/2 Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[0]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[0]) Then
    Sound.PlayMusic("O4 C")
    Shapes.setOpacity(tutsputih[0], 80)
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutshitam[0]) And GraphicsWindow.MouseX <= Shapes.Getleft(tutshitam[0]) + lebartutshitam Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutshitam[0]) And GraphicsWindow.MouseY <= Shapes.GetTop(tutshitam[0]) + tinggitutshitam Then
    Sound.PlayMusic("O4 C#")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutsputih[0]) + lebartutsputih/2 And GraphicsWindow.MouseX <= Shapes.GetLeft(tutsputih[0])+ lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutsputih[0]) + tinggitutshitam And GraphicsWindow.MouseY <= Shapes.GetTop(tutsputih[0])+tinggitutsputih Then
    Sound.PlayMusic("O4 C")
  EndIf
EndIf

  'UNTUK TUTS2
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[1]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[1]) + lebartutsputih/2 Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[1]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[1]) Then
    Sound.PlayMusic("O4 D")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutshitam[1]) And GraphicsWindow.MouseX <= Shapes.Getleft(tutshitam[1]) + lebartutshitam Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutshitam[1]) And GraphicsWindow.MouseY <= Shapes.GetTop(tutshitam[1]) + tinggitutshitam Then
    Sound.PlayMusic("O4 D#")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutsputih[1]) + lebartutsputih/2 And GraphicsWindow.MouseX <= Shapes.GetLeft(tutsputih[1])+ lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutsputih[1]) + tinggitutshitam And GraphicsWindow.MouseY <= Shapes.GetTop(tutsputih[1])+tinggitutsputih Then
    Sound.PlayMusic("O4 D")
  EndIf
EndIf

  'UNTUK TUTS3
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[2]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[2]) + lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[2]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[2]) Then
    Sound.PlayMusic("O4 E")
  EndIf
EndIf

  'UNTUK TUTS4
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[3]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[3]) + lebartutsputih/2 Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[3]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[3]) Then
    Sound.PlayMusic("O4 F")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutshitam[3]) And GraphicsWindow.MouseX <= Shapes.Getleft(tutshitam[3]) + lebartutshitam Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutshitam[3]) And GraphicsWindow.MouseY <= Shapes.GetTop(tutshitam[3]) + tinggitutshitam Then
    Sound.PlayMusic("O4 F#")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutsputih[3]) + lebartutsputih/2 And GraphicsWindow.MouseX <= Shapes.GetLeft(tutsputih[3])+ lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutsputih[3]) + tinggitutshitam And GraphicsWindow.MouseY <= Shapes.GetTop(tutsputih[3])+tinggitutsputih Then
    Sound.PlayMusic("O4 F")
  EndIf
EndIf


  'UNTUK TUTS5
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[4]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[4]) + lebartutsputih/2 Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[4]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[4]) Then
    Sound.PlayMusic("O4 G")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutshitam[4]) And GraphicsWindow.MouseX <= Shapes.Getleft(tutshitam[4]) + lebartutshitam Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutshitam[4]) And GraphicsWindow.MouseY <= Shapes.GetTop(tutshitam[4]) + tinggitutshitam Then
    Sound.PlayMusic("O4 G#")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutsputih[4]) + lebartutsputih/2 And GraphicsWindow.MouseX <= Shapes.GetLeft(tutsputih[4])+ lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutsputih[4]) + tinggitutshitam And GraphicsWindow.MouseY <= Shapes.GetTop(tutsputih[4])+tinggitutsputih Then
    Sound.PlayMusic("O4 G")
  EndIf
EndIf

  'UNTUK TUTS6
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[5]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[5]) + lebartutsputih/2 Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[5]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[5]) Then
    Sound.PlayMusic("O4 A")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutshitam[5]) And GraphicsWindow.MouseX <= Shapes.Getleft(tutshitam[5]) + lebartutshitam Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutshitam[5]) And GraphicsWindow.MouseY <= Shapes.GetTop(tutshitam[5]) + tinggitutshitam Then
    Sound.PlayMusic("O4 A#")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutsputih[5]) + lebartutsputih/2 And GraphicsWindow.MouseX <= Shapes.GetLeft(tutsputih[5])+ lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutsputih[5]) + tinggitutshitam And GraphicsWindow.MouseY <= Shapes.GetTop(tutsputih[5])+tinggitutsputih Then
    Sound.PlayMusic("O4 A")
  EndIf
EndIf

  'UNTUK TUTS7
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[6]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[6]) + lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[6]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[6]) Then
    Sound.PlayMusic("O4 B")
  EndIf
EndIf

  'UNTUK TUTS8
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[7]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[7]) + lebartutsputih/2 Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[7]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[7]) Then
    Sound.PlayMusic("O5 C")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutshitam[7]) And GraphicsWindow.MouseX <= Shapes.Getleft(tutshitam[7]) + lebartutshitam Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutshitam[7]) And GraphicsWindow.MouseY <= Shapes.GetTop(tutshitam[7]) + tinggitutshitam Then
    Sound.PlayMusic("O5 C#")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutsputih[7]) + lebartutsputih/2 And GraphicsWindow.MouseX <= Shapes.GetLeft(tutsputih[7])+ lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutsputih[7]) + tinggitutshitam And GraphicsWindow.MouseY <= Shapes.GetTop(tutsputih[7])+tinggitutsputih Then
    Sound.PlayMusic("O5 C")
  EndIf
EndIf

  'UNTUK TUTS9
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[8]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[8]) + lebartutsputih/2 Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[8]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[8]) Then
    Sound.PlayMusic("O5 D")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutshitam[8]) And GraphicsWindow.MouseX <= Shapes.Getleft(tutshitam[8]) + lebartutshitam Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutshitam[8]) And GraphicsWindow.MouseY <= Shapes.GetTop(tutshitam[8]) + tinggitutshitam Then
    Sound.PlayMusic("O5 D#")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutsputih[8]) + lebartutsputih/2 And GraphicsWindow.MouseX <= Shapes.GetLeft(tutsputih[8])+ lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutsputih[8]) + tinggitutshitam And GraphicsWindow.MouseY <= Shapes.GetTop(tutsputih[8])+tinggitutsputih Then
    Sound.PlayMusic("O5 D")
  EndIf
EndIf

  'UNTUK TUTS10
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[9]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[9]) + lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[9]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[9]) Then
    Sound.PlayMusic("O5 E")
  EndIf
EndIf

  'UNTUK TUTS11
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[10]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[10]) + lebartutsputih/2 Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[10]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[10]) Then
    Sound.PlayMusic("O5 F")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutshitam[10]) And GraphicsWindow.MouseX <= Shapes.Getleft(tutshitam[10]) + lebartutshitam Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutshitam[10]) And GraphicsWindow.MouseY <= Shapes.GetTop(tutshitam[10]) + tinggitutshitam Then
    Sound.PlayMusic("O5 F#")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutsputih[10]) + lebartutsputih/2 And GraphicsWindow.MouseX <= Shapes.GetLeft(tutsputih[10])+ lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutsputih[10]) + tinggitutshitam And GraphicsWindow.MouseY <= Shapes.GetTop(tutsputih[10])+tinggitutsputih Then
    Sound.PlayMusic("O5 F")
  EndIf
EndIf

  'UNTUK TUTS12
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[11]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[11]) + lebartutsputih/2 Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[11]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[11]) Then
    Sound.PlayMusic("O5 G")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutshitam[11]) And GraphicsWindow.MouseX <= Shapes.Getleft(tutshitam[11]) + lebartutshitam Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutshitam[11]) And GraphicsWindow.MouseY <= Shapes.GetTop(tutshitam[11]) + tinggitutshitam Then
    Sound.PlayMusic("O5 G#")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutsputih[11]) + lebartutsputih/2 And GraphicsWindow.MouseX <= Shapes.GetLeft(tutsputih[11])+ lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutsputih[11]) + tinggitutshitam And GraphicsWindow.MouseY <= Shapes.GetTop(tutsputih[11])+tinggitutsputih Then
    Sound.PlayMusic("O5 G")
  EndIf
EndIf

  'UNTUK TUTS13
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[12]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[12]) + lebartutsputih/2 Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[12]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[12]) Then
    Sound.PlayMusic("O5 A")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutshitam[12]) And GraphicsWindow.MouseX <= Shapes.Getleft(tutshitam[12]) + lebartutshitam Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutshitam[12]) And GraphicsWindow.MouseY <= Shapes.GetTop(tutshitam[12]) + tinggitutshitam Then
    Sound.PlayMusic("O5 A#")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutsputih[12]) + lebartutsputih/2 And GraphicsWindow.MouseX <= Shapes.GetLeft(tutsputih[12])+ lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutsputih[12]) + tinggitutshitam And GraphicsWindow.MouseY <= Shapes.GetTop(tutsputih[12])+tinggitutsputih Then
    Sound.PlayMusic("O5 A")
  EndIf
EndIf

  'UNTUK TUTS14
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[13]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[13]) + lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[13]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[13]) Then
    Sound.PlayMusic("O5 B")
  EndIf
EndIf

  'UNTUK TUTS15
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[14]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[14]) + lebartutsputih/2 Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[14]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[14]) Then
    Sound.PlayMusic("O6 C")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutshitam[14]) And GraphicsWindow.MouseX <= Shapes.Getleft(tutshitam[14]) + lebartutshitam Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutshitam[14]) And GraphicsWindow.MouseY <= Shapes.GetTop(tutshitam[14]) + tinggitutshitam Then
    Sound.PlayMusic("O6 C#")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutsputih[14]) + lebartutsputih/2 And GraphicsWindow.MouseX <= Shapes.GetLeft(tutsputih[14])+ lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutsputih[14]) + tinggitutshitam And GraphicsWindow.MouseY <= Shapes.GetTop(tutsputih[14])+tinggitutsputih Then
    Sound.PlayMusic("O6 C")
  EndIf
EndIf

  'UNTUK TUTS16
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[15]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[15]) + lebartutsputih/2 Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[15]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[15]) Then
    Sound.PlayMusic("O6 D")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutshitam[15]) And GraphicsWindow.MouseX <= Shapes.Getleft(tutshitam[15]) + lebartutshitam Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutshitam[15]) And GraphicsWindow.MouseY <= Shapes.GetTop(tutshitam[15]) + tinggitutshitam Then
    Sound.PlayMusic("O6 D#")
  EndIf
EndIf

If GraphicsWindow.MouseX >= Shapes.GetLeft(tutsputih[15]) + lebartutsputih/2 And GraphicsWindow.MouseX <= Shapes.GetLeft(tutsputih[15])+ lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.GetTop(tutsputih[15]) + tinggitutshitam And GraphicsWindow.MouseY <= Shapes.GetTop(tutsputih[15])+tinggitutsputih Then
    Sound.PlayMusic("O6 D")
  EndIf
EndIf

  'UNTUK TUTS17
  If GraphicsWindow.MouseX >= shapes.Getleft(tutsputih[16]) and GraphicsWindow.MouseX <= Shapes.Getleft(tutsputih[16]) + lebartutsputih Then
  If GraphicsWindow.MouseY >= Shapes.Gettop(tutsputih[16]) And GraphicsWindow.MouseY <= tinggitutsputih + Shapes.Gettop(tutsputih[16]) Then
    Sound.PlayMusic("O6 E")
  EndIf
EndIf
EndSub

No comments:

Post a Comment