Musical keyboard
Author |
Message |
petree08
|
Posted: Thu Oct 26, 2006 8:20 am Post subject: Musical keyboard |
|
|
This is a fun little program I wrote when i started using the sound command. All the keys on the computer make a different sound, Plus it looks cool (i put in some screen effects. You can change how long the notes can go by using the arrow keys.
code: |
var Key : array char of boolean
var Ch : char
var Font1 : int := Font.New ("Arial:50")
var Font2 : int := Font.New ("Arial:30")
var Font3 : int := Font.New ("Arial:20")
var X1, Y1, Size, C : int
var X2, Y2 : int
var L : nat2 := 100
procedure DrawStuff
randint (X1, 1, maxx)
randint (Y1, 1, maxy)
randint (C, 1, 15)
randint (Size, 1, 200)
drawfilloval (X1, Y1, Size, Size, C)
drawoval (X1, Y1, Size, Size, 7)
end DrawStuff
procedure DrawLines
randint (X1, 1, maxx)
randint (X2, 1, maxx)
randint (Y1, 1, maxy)
randint (Y2, 1, maxy)
randint (C, 1, 15)
drawline (X1, Y1, X2, Y2, C)
end DrawLines
procedure Pause
Ch := getchar
end Pause
setscreen ("graphics:max,max,nobuttonbar")
colorback (7)
cls
Font.Draw ("Silly Keybord", maxx div 2 - 200, maxy - 200, Font1, 12)
Font.Draw ("(press any key to continue)", maxx div 2 - 200, maxy - 300, Font2, 12)
Font.Draw ("Made by: Peter Watt", maxx div 2 - 200, maxy - 400, Font3, 12)
Pause
loop
cls
Input.KeyDown (Key)
if Key ('1') then
DrawStuff
sound (25, L)
end if
if Key ('2') then
DrawLines
sound (125, L)
end if
if Key ('3') then
DrawStuff
sound (225, L)
end if
if Key ('4') then
DrawLines
sound (253, L)
end if
if Key ('5') then
DrawStuff
sound (425, L)
end if
if Key ('6') then
DrawLines
sound (525, L)
end if
if Key ('7') then
DrawStuff
sound (625, L)
end if
if Key ('8') then
DrawLines
sound (725, L)
end if
if Key ('9') then
DrawStuff
sound (825, L)
end if
if Key ('0') then
DrawLines
sound (925, L)
end if
if Key ('q') then
DrawStuff
sound (50, L)
end if
if Key ('w') then
DrawLines
sound (150, L)
end if
if Key ('e') then
DrawStuff
sound (250, L)
end if
if Key ('r') then
DrawLines
sound (350, L)
end if
if Key ('t') then
DrawStuff
sound (450, L)
end if
if Key ('y') then
DrawLines
sound (550, L)
end if
if Key ('u') then
DrawStuff
sound (650, L)
end if
if Key ('i') then
DrawLines
sound (750, L)
end if
if Key ('o') then
DrawStuff
sound (850, L)
end if
if Key ('p') then
DrawLines
sound (950, L)
end if
if Key ('a') then
DrawStuff
sound (75, L)
end if
if Key ('s') then
DrawLines
sound (175, L)
end if
if Key ('d') then
DrawStuff
sound (275, L)
end if
if Key ('f') then
DrawLines
sound (375, L)
end if
if Key ('g') then
DrawStuff
sound (475, L)
end if
if Key ('h') then
DrawLines
sound (575, L)
end if
if Key ('j') then
DrawStuff
sound (675, L)
end if
if Key ('k') then
DrawLines
sound (775, L)
end if
if Key ('l') then
DrawStuff
sound (875, L)
end if
if Key (';') then
DrawLines
sound (975, L)
end if
if Key ('z') then
DrawStuff
sound (100, L)
end if
if Key ('x') then
DrawLines
sound (200, L)
end if
if Key ('c') then
DrawStuff
sound (300, L)
end if
if Key ('v') then
DrawLines
sound (400, L)
end if
if Key ('b') then
DrawStuff
sound (500, L)
end if
if Key ('n') then
DrawLines
sound (600, L)
end if
if Key ('m') then
DrawStuff
sound (700, L)
end if
if Key (',') then
DrawLines
sound (800, L)
end if
if Key ('.') then
DrawStuff
sound (900, L)
end if
if Key ('/') then
DrawLines
sound (1000, L)
end if
if Key (KEY_LEFT_ARROW) then
L := 50
end if
if Key (KEY_RIGHT_ARROW) then
L := 300
end if
if Key (KEY_UP_ARROW) then
L := 200
end if
if Key (KEY_DOWN_ARROW) then
L := 500
end if
end loop
|
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
jr.ranger.33
|
Posted: Sat Nov 04, 2006 5:51 pm Post subject: Bored |
|
|
I was really bored so i took your idea and created an onscreen keyboard that does pretty much the same thing, so here's the code:
import GUI
setscreen ("graphics:400;300")
procedure sound1
sound (25,50)
end sound1
procedure sound2
sound (125,50)
end sound2
procedure sound3
sound (225,50)
end sound3
procedure sound4
sound (253,50)
end sound4
procedure sound5
sound (425,50)
end sound5
procedure sound6
sound (525,50)
end sound6
procedure sound7
sound (625,50)
end sound7
procedure sound8
sound (725,50)
end sound8
procedure sound9
sound (825,50)
end sound9
procedure sound10
sound (925,50)
end sound10
procedure sound11
sound (50,50)
end sound11
procedure sound12
sound (150,50)
end sound12
procedure sound13
sound (250,50)
end sound13
procedure sound14
sound (350,50)
end sound14
procedure sound15
sound (450,50)
end sound15
procedure sound16
sound (550,50)
end sound16
procedure sound17
sound (650,50)
end sound17
procedure sound18
sound (750,50)
end sound18
procedure sound19
sound (850,50)
end sound19
procedure sound20
sound (950,50)
end sound20
procedure sound21
sound (75,50)
end sound21
procedure sound22
sound (175,50)
end sound22
procedure sound23
sound (275,50)
end sound23
procedure sound24
sound (375,50)
end sound24
procedure sound25
sound (475,50)
end sound25
procedure sound26
sound (575,50)
end sound26
procedure sound27
sound (675,50)
end sound27
procedure sound28
sound (775,50)
end sound28
procedure sound29
sound (875,50)
end sound29
procedure sound30
sound (975,50)
end sound30
procedure sound31
sound (100,50)
end sound31
procedure sound32
sound (200,50)
end sound32
procedure sound33
sound (300,50)
end sound33
procedure sound34
sound (400,50)
end sound34
procedure sound35
sound (500,50)
end sound35
procedure sound36
sound (600,50)
end sound36
procedure sound37
sound (700,50)
end sound37
procedure sound38
sound (800,50)
end sound38
procedure sound39
sound (900,50)
end sound39
procedure sound40
sound (1000,50)
end sound40
var button1:int:=GUI.CreateButton(20,270,10,"1",sound1)
var button2:int:=GUI.CreateButton(55,270,10,"2",sound2)
var button3:int:=GUI.CreateButton(90,270,10,"3",sound3)
var button4:int:=GUI.CreateButton(125,270,10,"4",sound4)
var button5:int:=GUI.CreateButton(160,270,10,"5",sound5)
var button6:int:=GUI.CreateButton(195,270,10,"6",sound6)
var button7:int:=GUI.CreateButton(230,270,10,"7",sound7)
var button8:int:=GUI.CreateButton(265,270,10,"8",sound8)
var button9:int:=GUI.CreateButton(300,270,10,"9",sound9)
var button0:int:=GUI.CreateButton(335,270,10,"0",sound10)
var buttonq:int:=GUI.CreateButton(20,247,10,"q",sound11)
var buttonw:int:=GUI.CreateButton(55,247,10,"w",sound12)
var buttone:int:=GUI.CreateButton(90,247,10,"e",sound13)
var buttonr:int:=GUI.CreateButton(125,247,10,"r",sound14)
var buttont:int:=GUI.CreateButton(160,247,10,"t",sound15)
var buttony:int:=GUI.CreateButton(195,247,10,"y",sound16)
var buttonu:int:=GUI.CreateButton(230,247,10,"u",sound17)
var buttoni:int:=GUI.CreateButton(265,247,10,"i",sound18)
var buttono:int:=GUI.CreateButton(300,247,10,"o",sound19)
var buttonp:int:=GUI.CreateButton(335,247,10,"p",sound20)
var buttona:int:=GUI.CreateButton(20,224,10,"a",sound21)
var buttons:int:=GUI.CreateButton(55,224,10,"s",sound22)
var buttond:int:=GUI.CreateButton(90,224,10,"d",sound23)
var buttonf:int:=GUI.CreateButton(125,224,10,"f",sound24)
var buttong:int:=GUI.CreateButton(160,224,10,"g",sound25)
var buttonh:int:=GUI.CreateButton(195,224,10,"h",sound26)
var buttonj:int:=GUI.CreateButton(230,224,10,"j",sound27)
var buttonk:int:=GUI.CreateButton(265,224,10,"k",sound28)
var buttonl:int:=GUI.CreateButton(300,224,10,"l",sound29)
var buttonsemicolon:int:=GUI.CreateButton(335,224,10,";",sound30)
var buttonz:int:=GUI.CreateButton(20,201,10,"z",sound31)
var buttonx:int:=GUI.CreateButton(55,201,10,"x",sound32)
var buttonc:int:=GUI.CreateButton(90,201,10,"c",sound33)
var buttonv:int:=GUI.CreateButton(125,201,10,"v",sound34)
var buttonb:int:=GUI.CreateButton(160,201,10,"b",sound35)
var buttonn:int:=GUI.CreateButton(195,201,10,"n",sound36)
var buttonm:int:=GUI.CreateButton(230,201,10,"m",sound37)
var buttoncomma:int:=GUI.CreateButton(265,201,10,",",sound38)
var buttonperiod:int:=GUI.CreateButton(300,201,10,".",sound39)
var buttonslash:int:=GUI.CreateButton(335,201,10,"/",sound40)
loop
exit when GUI.ProcessEvent
end loop |
|
|
|
|
 |
araevin

|
Posted: Sun Nov 05, 2006 12:36 pm Post subject: (No subject) |
|
|
my computer crashed when i ran this ....
prolly just my computer |
|
|
|
|
 |
|
|