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

Username:   Password: 
 RegisterRegister   
 Turing Paint
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
fishtastic




PostPosted: Sun Dec 30, 2007 2:32 pm   Post subject: Turing Paint

After getting bored of playing flash games for 7 days in a row.
I decided share more stuff out of the turing games I made last year.

This is a drawing program done in turing.
copy and paste into turing to use it.

it comes with a help and you wont miss it , so... ya
Have fun with it and happy new year Dance Dance

Turing:
var version := "1.2"
var loadtime := 0.0
var mx, my, mc : int
var selected := 255
var chosen := 1
var key : array char of boolean
var actions : flexible array 1 .. 0 of int
var ax1, ax2, ay1, ay2 : flexible array 1 .. 0 of int
var step : flexible array 1 .. 0 of int
var aColor : flexible array 1 .. 0 of int
var thick : flexible array 1 .. 0 of int
var toolName : array 0 .. 9 of string := init ("erasor", "Line", "brush", "rectangle", "oval", "star", "mapleleaf", "fillshape", "fillblank", "no")
var thickness := 1.0
var tool := 1
var name := ""
View.Set ("offscreenonly")

%var pass : string
%get pass
%assert pass = "thisisforjohn"
proc help
    var ch : char
    cls
    color (red)
    put "Welcome to Turing Paint " + version
    put "Press 'h' at ANY TIME for HELP"
    put ""
    color (black)
    put "select colour at the bottom of the window"
    put "press '0'~'9' to select tools"
    put "press '+' and '-' to adjust line thickness"
    put "press 'z' to move 1 step back"
    put "press 's' to save and 'l' to load"
    put "press 'w' and 'q' to selection previous and next colour"
    put ""
    put "press any key to continue"
    View.Update
    ch := getchar
end help

proc newAll
    new actions, upper (actions) + 1
    new ax1, upper (ax1) + 1
    new ay1, upper (ay1) + 1
    new ax2, upper (ax2) + 1
    new ay2, upper (ay2) + 1
    new aColor, upper (aColor) + 1
    new thick, upper (thick) + 1

    actions (upper (actions)) := 0
    aColor (upper (aColor)) := 0
    ax1 (upper (ax1)) := 0
    ay1 (upper (ay1)) := 0
    ax2 (upper (ax1)) := 0
    ay2 (upper (ay1)) := 0
    thick (upper (thick)) := 0
end newAll
%
proc back
    if upper (actions) > 0 then
        loop
            exit when upper (actions) = step (upper (step))
            new actions, upper (actions) - 1
            new ax1, upper (ax1) - 1
            new ay1, upper (ay1) - 1
            new ax2, upper (ax2) - 1
            new ay2, upper (ay2) - 1
            new aColor, upper (aColor) - 1
            new thick, upper (thick) - 1
        end loop
        new step, upper (step) - 1
        delay (50)
    end if
end back
%
proc drawAll
    for i : 1 .. upper (actions)
        if actions (i) = 0 then
            Draw.ThickLine (ax1 (i), ay1 (i), ax2 (i), ay2 (i), thick (i), white)
        elsif actions (i) = 1 then
            Draw.ThickLine (ax1 (i), ay1 (i), ax2 (i), ay2 (i), thick (i), aColor (i))
        elsif actions (i) = 2 then
            Draw.ThickLine (ax1 (i), ay1 (i), ax2 (i), ay2 (i), thick (i), aColor (i))
        elsif actions (i) = 3 then
            drawfillbox (ax1 (i), ay1 (i), ax2 (i), ay2 (i), aColor (i))
        elsif actions (i) = 4 then
            drawfilloval (ax1 (i), ay1 (i), ax2 (i) - ax1 (i), ay2 (i) - ay1 (i), aColor (i))
        elsif actions (i) = 5 then
            drawfillstar (ax1 (i), ay1 (i), ax2 (i), ay2 (i), aColor (i))
        elsif actions (i) = 6 then
            drawfillmapleleaf (ax1 (i), ay1 (i), ax2 (i), ay2 (i), aColor (i))
        elsif actions (i) = 7 then
            drawfill (ax1 (i), ay1 (i), aColor (i), 0)
        elsif actions (i) = 8 then
            drawfill (ax1 (i), ay1 (i), 255, aColor (i))
        end if
    end for
end drawAll
%
proc showStat
    if (Time.Elapsed - loadtime not= 0) then
        color (black)
        put "FPS:", 1000 / (Time.Elapsed - loadtime) : 4 : 0, "  Total Points:", upper (ay2)
        color (red)
        put toolName (tool), " tool"
        put "thickness: ", round (thickness), "  colour #: ", chosen
    end if
end showStat

proc showAll
    for i : 0 .. maxcolor
        drawfillbox (round ((maxx / maxcolor) * i), 0, round ((maxx / maxcolor) * i) + 3, 20, i)
    end for
    drawfillbox (0, 20, maxx, 40, chosen)
    if my < 20 then
        drawfillbox (0, 20, maxx, 40, selected)
    end if
    loadtime := Time.Elapsed
end showAll

%
proc save (name : string)
    var OUT : int
    open : OUT, name, put
    for i : 1 .. upper (ax1)
        put : OUT, ax1 (i)
        put : OUT, ay1 (i)
        put : OUT, ax2 (i)
        put : OUT, ay2 (i)
        put : OUT, actions (i)
        put : OUT, thick (i)
        put : OUT, aColor (i)
    end for
    put "saved!!"
    delay (1000)
    close : OUT
end save
%
proc load (name : string)
    for i : 1 .. upper (ax1) + 1
        back
    end for
    var IN : int
    open : IN, name, get
    newAll
    loop
        get : IN, ax1 (upper (ax1))
        get : IN, ay1 (upper (ay1))
        get : IN, ax2 (upper (ax2))
        get : IN, ay2 (upper (ay2))
        get : IN, actions (upper (actions))
        get : IN, thick (upper (thick))
        get : IN, aColor (upper (aColor))
        exit when eof (IN) = true
        newAll
    end loop
    put "loaded!!"
    delay (1000)
    close : IN
end load
%
proc checkKeys
    Input.KeyDown (key)
    if key (chr (ord ("+"))) then
        thickness += 0.2
    elsif key (chr (ord ("-"))) and thickness > 1 then
        thickness -= 0.2
    elsif key (chr (ord ("z"))) then
        back
        put "canceled 1 move"
        View.Update
        delay (100)
    elsif key (chr (ord ("h"))) then
        help
    elsif key (chr (ord ("s"))) then
        cls
        View.Set ("nooffscreenonly")
        put "File name(type 'cancel' to cancel)"
        get name
        if name not= "cancel" then
            save (name + ".txt")
        end if
        View.Set ("offscreenonly")
    elsif key (chr (ord ("l"))) then
        cls
        View.Set ("nooffscreenonly")
        put "File name(type 'cancel' to cancel)"
        get name
        if name not= "cancel" then
            load (name + ".txt")
        end if
        View.Set ("offscreenonly")
    elsif key (chr (ord ("q"))) then
        if chosen > 0 then
            chosen -= 1
        end if
    elsif key (chr (ord ("w"))) then
        if chosen < 255 then
            chosen += 1
        end if
    end if
    for i : 0 .. 9
        if key (chr (ord (intstr (i)))) then
            tool := i
        end if
    end for
end checkKeys
% real codes
help

loop
    cls
    mousewhere (mx, my, mc)
    showStat
    drawAll
    showAll
    checkKeys
    %
    if mc = 1 and my > 20 then
        new step, upper (step) + 1
        step (upper (step)) := upper (ax1)
        newAll
        actions (upper (actions)) := tool
        aColor (upper (aColor)) := chosen
        ax1 (upper (ax1)) := mx
        ay1 (upper (ay1)) := my
        thick (upper (thick)) := round (thickness)
        loop

            cls
            mousewhere (mx, my, mc)

            ax2 (upper (ax2)) := mx
            ay2 (upper (ay2)) := my

            showStat
            drawAll
            showAll

            exit when mc = 0
            if tool = 0 or tool = 2
                    then
                newAll
                actions (upper (actions)) := tool
                aColor (upper (aColor)) := chosen
                ax1 (upper (ax1)) := mx
                ay1 (upper (ay1)) := my
                thick (upper (thick)) := round (thickness)
            end if
            View.Update
            delay (10)
        end loop
    elsif my < 20 and round (mx / (maxx / maxcolor)) > -1 and round (mx / (maxx / maxcolor)) <= maxcolor
            then
        selected := round (mx / (maxx / maxcolor))
        if mc = 1 then
            chosen := round (mx / (maxx / maxcolor))
        end if
    end if
    View.Update
    delay (20)
end loop

Sponsor
Sponsor
Sponsor
sponsor
yusong




PostPosted: Sun Dec 30, 2007 8:53 pm   Post subject: Lol

Wow, Xiao, LOL, you actually posted it!

So...
Where is that "Box" Tower Defence???
fishtastic




PostPosted: Sun Dec 30, 2007 8:59 pm   Post subject: Re: Lol

yusong @ Sun Dec 30, 2007 7:53 pm wrote:

Where is that "Box" Tower Defence???


It will be uploaded when its done, And i will share the code
MihaiG




PostPosted: Sun Dec 30, 2007 9:02 pm   Post subject: Re: Turing Paint

Dude, Xiao, i havent seen you in ages, whatsup man?
fishtastic




PostPosted: Sun Dec 30, 2007 9:04 pm   Post subject: Re: Turing Paint

MihaiG @ Sun Dec 30, 2007 8:02 pm wrote:
Dude, Xiao, i havent seen you in ages, whatsup man?


who are you?
yusong




PostPosted: Sun Dec 30, 2007 9:10 pm   Post subject: Re: Turing Paint

Dude, Xiao, it says MihaiG, who do you think it is?
it is probably Mihai!
LOL
And when are you going to be done "Box" Defence???
I want it now!
You said I could do some Beta testing!
MihaiG




PostPosted: Sun Dec 30, 2007 9:15 pm   Post subject: Re: Turing Paint

Xiao, we had gr 10 math togehter with Ms. Schleuter,

dont you remember?

well i was on the opposite side of the room, man

its good to see you
fishtastic




PostPosted: Sun Dec 30, 2007 9:16 pm   Post subject: Re: Turing Paint

yusong @ Sun Dec 30, 2007 8:10 pm wrote:

it is probably Mihai!
LOL


OIC
Sponsor
Sponsor
Sponsor
sponsor
fishtastic




PostPosted: Sun Dec 30, 2007 9:20 pm   Post subject: Re: Turing Paint

MihaiG @ Sun Dec 30, 2007 8:15 pm wrote:
Xiao, we had gr 10 math togehter with Ms. Schleuter,

dont you remember?

well i was on the opposite side of the room, man

its good to see you


Ahhh... I think I remember now,

good to see you too! Smile
yusong




PostPosted: Sun Dec 30, 2007 9:43 pm   Post subject: Re: Turing Paint

Ms. Shleuter is like, the best math teacher ever!
Here classes are so easy!
And she doesn't even care if you do homework or not, that is sick, LOL!
So, Xiao, how about it?
The "Box" Defence thing??
Oh, and the INTSTR and STRINT stuff for my RPG is not working, how do i fix it???
Do they all have to be STRING or INT?
Saad




PostPosted: Sun Dec 30, 2007 11:12 pm   Post subject: RE:Turing Paint

This topic has gone off-topic, if you want to talk someone then PM them. Remember this topic is about the Turing paint program.

On topic. This is an interesting program, i like how you stored actions allowing undo's, although you could make it better with more parameter passing and less global variables. Also you could make an action type which makes the code much neater.
Gooie




PostPosted: Mon Dec 31, 2007 1:51 am   Post subject: Re: Turing Paint

I love it, it would be even cooler though if you got it going with two windows, one for tools, the other for canvas. Like The Gimp.
Dan




PostPosted: Mon Dec 31, 2007 2:04 am   Post subject: Re: RE:Turing Paint

Saad @ 30th December 2007, 11:12 pm wrote:
This topic has gone off-topic, if you want to talk someone then PM them. Remember this topic is about the Turing paint program.

On topic. This is an interesting program, i like how you stored actions allowing undo's, although you could make it better with more parameter passing and less global variables. Also you could make an action type which makes the code much neater.


Saad is right, alot of the above should have been done threw PMs or other means. This topic will be locked if it keeps going off topic.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
fishtastic




PostPosted: Mon Dec 31, 2007 1:56 pm   Post subject: Re: Turing Paint

Gooie @ Mon Dec 31, 2007 12:51 am wrote:
I love it, it would be even cooler though if you got it going with two windows, one for tools, the other for canvas. Like The Gimp.


Thanks !
you are the first person who replied something about the actual program.

about the gimp part, thinks it as Photoshop instead of gimp. Photoshop is as good a gimp right? Mr. Green

if you want to, you can change my code a bit to put the drawing part in a different window.
Sean




PostPosted: Tue Jan 01, 2008 10:17 am   Post subject: Re: Turing Paint

Gooie, you got to post your version of paint that you came up with.
Then you could combine your codes into one, to attempt to make an easier paint program.
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: