% The TypeWriter Program
%By Paul Bian
var window : int := Window.Open ("graphics:800;400")
var font : int
font := Font.New ("serif:24")
var letter : string (1)
var alpha : array 1 .. 10 of string := init ("Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P")
var alpha2 : array 11 .. 19 of string := init ("A", "S", "D", "F", "G", "H", "J", "K", "L")
var alpha3 : array 20 .. 26 of string := init ("Z", "X", "C", "V", "B", "N", "M")
var move, addx, addy, add : int := 0
loop
addx := 0
addy := 0
for a : 1 .. 10
drawbox (164 + addx, 195, 199 + addx, 229, black)
drawfillbox (165 + addx, 195, 200 + addx, 230, grey)
Draw.Text (alpha (a), 170 + addx, 200, font, red)
addx := addx + 40
end for
addx := 0
for a : 11 .. 19
drawbox (184 + addx, 155, 219 + addx, 189, black)
drawfillbox (185 + addx, 155, 220 + addx, 190, grey)
Draw.Text (alpha2 (a), 190 + addx, 160, font, red)
addx := addx + 40
end for
addx := 0
for a : 20 .. 26
drawbox (224 + addx, 115, 259 + addx, 149, black)
drawfillbox (225 + addx, 115, 260 + addx, 150, grey)
Draw.Text (alpha3 (a), 230 + addx, 120, font, red)
addx := addx + 40
end for
drawfillbox (240, 110, 485, 85, grey)
drawbox (239, 110, 486, 85, black)
locate (1, 1)
put "Type: "
locate (2, 1)
put "Press 5 to exit"
getch (letter)
if letter = "q"
then
add := 0
addy := 0
elsif letter = "w"
then
add := 40
addy := 0
elsif letter = "e"
then
add := 80
addy := 0
elsif letter = "r"
then
add := 120
addy := 0
elsif letter = "t"
then
add := 160
addy := 0
elsif letter = "y"
then
add := 200
addy := 0
elsif letter = "u"
then
add := 240
addy := 0
elsif letter = "i"
then
add := 280
addy := 0
elsif letter = "o"
then
add := 320
addy := 0
elsif letter = "p"
then
add := 360
addy := 0
elsif letter = "a"
then
add := 20
addy := 40
elsif letter = "s"
then
add := 60
addy := 40
elsif letter = "d"
then
add := 100
addy := 40
elsif letter = "f"
then
add := 140
addy := 40
elsif letter = "g"
then
add := 180
addy := 40
elsif letter = "h"
then
add := 220
addy := 40
elsif letter = "j"
then
add := 260
addy := 40
elsif letter = "k"
then
add := 300
addy := 40
elsif letter = "l"
then
add := 340
addy := 40
elsif letter = "z"
then
add := 60
addy := 80
elsif letter = "x"
then
add := 100
addy := 80
elsif letter = "c"
then
add := 140
addy := 80
elsif letter = "v"
then
add := 180
addy := 80
elsif letter = "b"
then
add := 220
addy := 80
elsif letter = "n"
then
add := 260
addy := 80
elsif letter = "m"
then
add := 300
addy := 80
elsif letter = "5" then
exit
elsif letter = " " then
drawfillbox (240, 110, 485, 85, 34)
drawbox (239, 110, 486, 85, black)
end if
if letter not= " " and letter not = "5" then
drawbox (164 + add, 195 - addy, 199 + add, 229 - addy, black)
drawfillbox (165 + add, 195 - addy, 200 + add, 230 - addy, blue)
Draw.Text (chr (ord (letter) - 32), 170 + add, 200 - addy, font, 34)
Draw.Text (letter, 20 + move, 20, font, red)
elsif letter= " " then
Draw.Text (letter, 170 + add, 200 - addy, font, 34)
Draw.Text (letter, 20 + move, 20, font, red)
end if
move := move + 20
delay (100)
end loop
Window.Close (window)
|