Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [source] My typewriter program...
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Paul




PostPosted: Thu Jan 22, 2004 7:32 pm   Post subject: [source] My typewriter program...

It isnt very useful, just an animation kinda thing, made the best I can with my limited knowledge...

just type
code:

% 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)



Edit: the window should close when you hit 5 and the spacebar works now
Sponsor
Sponsor
Sponsor
sponsor
shorthair




PostPosted: Thu Jan 22, 2004 7:57 pm   Post subject: (No subject)

ummm ,what hte heck is it meant to be for , is i t partof a bigger program ofr sumthing ? , its cool , but you should close th ewindow after its finished and you should let the user proess esc or enter to exit , but rockin app whatever it is
Paul




PostPosted: Thu Jan 22, 2004 7:59 pm   Post subject: (No subject)

As I said, its not very useful, could be used for one of those typing training programs though..., as for exiting, isn't "5" exit? or is that not what you meant?
Tony




PostPosted: Thu Jan 22, 2004 8:01 pm   Post subject: (No subject)

spacebar doesn't seem to work Confused
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Paul




PostPosted: Thu Jan 22, 2004 8:06 pm   Post subject: (No subject)

I think I fixed it
santabruzer




PostPosted: Thu Jan 22, 2004 10:31 pm   Post subject: (No subject)

i remember i did something like this onl with out the graphical typewriter.. it was in some program i think the casino one.. and i was told it was utterly useless Razz
Paul




PostPosted: Fri Jan 23, 2004 5:00 pm   Post subject: (No subject)

lol, just like me to make a useless program...
I was thinking of making one of those typing training programs though, with wpm and stuff, maybe an animation of hands.
sport




PostPosted: Fri Jan 23, 2004 7:17 pm   Post subject: (No subject)

It might be some what useul if you press the letters with the mouse, f the keyboard does not work you can still do some things. Just a thought.
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Fri Jan 23, 2004 8:35 pm   Post subject: (No subject)

nice thought, I think I'll do it.
DanShadow




PostPosted: Sun Jan 25, 2004 12:08 am   Post subject: (No subject)

I hate to be negative...but does program have any point or use at all??? And if you make it so your clicking the buttons, I may consider th ink ing better of it...sorry man
we64




PostPosted: Tue Jan 27, 2004 6:34 pm   Post subject: (No subject)

it can be useful in some typing practice programs.
Paul




PostPosted: Tue Jan 27, 2004 8:13 pm   Post subject: (No subject)

Lol, Im just posting here so that if ppl think they can use it, they do. Im not posting here to impress u, though thats always good. But as for its usefulness... didn't I mention what it might be used for at the beginning? Are we just posting these replies for bits (like I am) or what? Laughing
shorthair




PostPosted: Tue Jan 27, 2004 8:33 pm   Post subject: (No subject)

no actually these post mostly arnt about hte bits , bits are what fuel the new peopel , but once your name is jazzed up and you have a few things in your profile , buts arnt that much , im jsut savin mineright now , for a ) a full email at compsci ( mabye , i quite like forwarding ) and im having a huge bit giveaway soon , gona have a little programming contest of my own
Paul




PostPosted: Tue Jan 27, 2004 8:35 pm   Post subject: (No subject)

wow, do people make a conscious effort to do typos? I count at least 6 that u could add to that dictionary thingy.
shorthair




PostPosted: Tue Jan 27, 2004 8:39 pm   Post subject: (No subject)

The dictionary is only for dans typos , no one else's typo's go in there , unless mazer accept it of course , but it is the dictonary of DAN Wink ,
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: