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

Username:   Password: 
 RegisterRegister   
 Paint/Write Code (hard to explain!)
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TylerL




PostPosted: Wed Jun 07, 2006 11:58 am   Post subject: Paint/Write Code (hard to explain!)

This program lets you draw lines in Turing and have the code written out for you in a text file.

code:
View.Set ("graphics")
Mouse.ButtonChoose ("multibutton")

% Hold L to draw a line. To stop drawing a line, right click while holding L.
% You must create code.txt in the same directory as this file before using
% this program. Clear the code.txt file before using again.

var x, y, button, right, lastx, lasty, counter : int

var filename : string := "code.txt"
var filenumber : int

var drawline1 : string := "drawline("
var comma : string := ", "
var drawline2 : string := ", black)"

var stringx : string
var thisvar : string

var keydown : array char of boolean

counter := 0
right := 100

open : filenumber, filename, put

loop

    loop
   
        Input.KeyDown (keydown)
       
        if keydown ('l') then
       
        delay (75)

        Mouse.Where (x, y, button)

        if button = 1 and counter = 0 then

            lastx := x
            lasty := y

            counter := 1

        elsif button = 1 then

                put : filenumber, drawline1 ..
                put : filenumber, lastx ..
                put : filenumber, comma ..
                put : filenumber, lasty ..
                put : filenumber, comma ..
                put : filenumber, x ..
                put : filenumber, comma ..
                put : filenumber, y ..
                put : filenumber, drawline2

            drawline (lastx, lasty, x, y, black)

            lastx := x
            lasty := y


        end if

        exit when button = 100
       
        end if
       
       
    end loop


    counter := 0
    lastx := 0
    lasty := 0

end loop
close : filenumber


Enjoy!
Sponsor
Sponsor
Sponsor
sponsor
CodeMonkey2000




PostPosted: Wed Jun 07, 2006 2:23 pm   Post subject: (No subject)

not bad
code:

var x, y, button : int
var c:int:=10
var keydown : array char of boolean

loop
Input.KeyDown (keydown)
       
        if keydown ('c') then
cls
elsif keydown ('v') then
randint (c,1,255)
end if
    Mouse.Where (x, y, button)
    if button = 0 then

    else
        drawfilloval (x, y , 5, 5, c)
    end if
end loop
Clayton




PostPosted: Wed Jun 07, 2006 2:51 pm   Post subject: (No subject)

@spearmonkey2000 : your above post is spam, plz refrain from doing so in the future Very Happy

now as for the program TylerL, not bad but believe me, this is not the first of its kind, keep working on it using new ideas, check the Turing Walkthrough for anything new and start learning new things Very Happy
upthescale




PostPosted: Wed Jun 07, 2006 3:00 pm   Post subject: (No subject)

super freak why do u talk, u always spam and double post, u haven o right to say, cuz i do mistakes to so i kleep my motuh shut
iker




PostPosted: Wed Jun 07, 2006 3:23 pm   Post subject: (No subject)

upthescale wrote:
super freak why do u talk, u always spam and double post, u haven o right to say, cuz i do mistakes to so i kleep my motuh shut

upthescale, you're realy starting to get anoying and ridiculous. People change over time, just because super freak may have spammed/double posted before, it doesn't mean he didn't learn from those mistakes, unlike some people (mainly you) who keep on spamming even after being told not to.
_justin_




PostPosted: Wed Jun 07, 2006 10:48 pm   Post subject: (No subject)

eh thats a rather useful program when it comes to drawing line

you should add a feature where you can select a color for the line to be

but anywho good job Dance
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 1  [ 6 Posts ]
Jump to:   


Style:  
Search: