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

Username:   Password: 
 RegisterRegister   
 Copthesaint's Turing Helper
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
copthesaint




PostPosted: Mon Nov 17, 2008 7:24 pm   Post subject: Copthesaint's Turing Helper

As you may have seen I had recently made a sound finder but I decided to goto the next level and create 3 programs in a program.

The first program will find a sound for the user.
The second program will find a color for the user.
The third program will position and resize a box

I hope you (the user) enjoy.
This will help alot for drawing pictures.

Post Comments please.

No Pictures Required.
code:
var fnt1 := Font.New ("Ariel:18x12")
var spd := 0
var sdp := 5
var x := maxx div 2
var y := maxy div 2
var stp := 0
var menuB := 1
var x1 := 0
var y1 := 0
var x2 := 0
var y2 := 0
var pst := 1
var clr := 0
View.Set ("offscreenonly")

var chars : array char of boolean
loop
    Input.KeyDown (chars)
    if stp = 8 then

        if pst = 1 then
            if chars (KEY_DOWN_ARROW) then
                if y1 > 0 then
                    cls
                    y1 := y1 - 1
                    View.Update
                    delay (10)
                end if
            end if
            if chars (KEY_UP_ARROW) then
                if y1 < maxy then
                    cls
                    y1 := y1 + 1
                    View.Update
                    delay (10)
                end if
            end if
            if chars (KEY_RIGHT_ARROW) then
                if x1 < maxx then
                    cls
                    x1 := x1 + 1
                    View.Update
                    delay (10)
                end if
            end if
            if chars (KEY_LEFT_ARROW) then
                if x1 > 0 then
                    cls
                    x1 := x1 - 1
                    View.Update
                    delay (10)
                end if
            end if
            if chars (KEY_ENTER) then
                cls
                pst := 2
                delay (250)
            end if
            Draw.FillBox (x1, y1, x1 + 2, y1 + 2, black)
            View.Update
        elsif pst = 2 then
            if chars (KEY_DOWN_ARROW) then
                if y2 > 0 then
                    cls
                    y2 := y2 - 1
                    View.Update
                    delay (10)
                end if
            end if
            if chars (KEY_UP_ARROW) then
                if y2 < maxy then
                    cls
                    y2 := y2 + 1
                    View.Update
                    delay (10)
                end if
            end if
            if chars (KEY_RIGHT_ARROW) then
                if x2 < maxx then
                    cls
                    x2 := x2 + 1
                    View.Update
                    delay (10)
                end if
            end if
            if chars (KEY_LEFT_ARROW) then
                if x2 > 0 then
                    cls
                    x2 := x2 - 1
                    View.Update
                    delay (10)
                end if
            end if
            if chars (KEY_ENTER) then
                cls
                pst := 3
                delay (250)
            end if
            Draw.FillBox (x1, y1, x1 + 2, y1 + 2, black)
            Draw.FillBox (x2, y2, x2 - 2, y2 - 2, black)
            View.Update
        elsif pst = 3 then
            Draw.FillBox (x1, y1, x2, y2, grey)
            if chars (KEY_ENTER) then
                Draw.FillBox (x1, y1, x2, y2, grey)
                Font.Draw (("Draw.FillBox (" + intstr (x1) + "," + intstr (y1) + "," + intstr (x2) + "," + intstr (y2) + ",black)"), 50, y, fnt1, black)
                View.Update
                delay (10000)
                stp := 1
                pst := 1
                cls
                View.Update
            end if
            View.Update
        end if

    elsif stp = 7 then
   
            if chars (KEY_DOWN_ARROW) then
                if clr > 0 then
                    clr := clr - 1
                    View.Update
                    delay (250)
                end if
            end if
            if chars (KEY_UP_ARROW) then
                if clr < 255 then                   
                    clr := clr + 1
                    View.Update
                    delay (250)
                end if
            end if
            if chars (KEY_ENTER) then
                cls
                Draw.FillBox (0, 0, maxx, maxy, clr)
                Font.Draw (("Draw.FillBox (0,0,maxx,maxy," + intstr (clr) + ")"), 50, y, fnt1, black)
                View.Update
                delay (10000)
                cls
                stp := 1
                clr := 0               
            end if
        Draw.FillBox (0, 0, maxx, maxy, clr)
        View.Update 
    elsif stp = 6 then
        cls
        put ("Welcome to copthesaint's Position Editor.")
        put ("Use the Up, Down, Right, Left keys on your keyboard to move the Pointer.")
        put ("If you have found the First Position of your Box simply press enter and repeat  step 1.")
        put ("If you have found the Second Position of your Box simply press enter and watch  as your box appears on the screen.")
        put ("Press enter a thrid time and the code will appear on the screen.")
        put ("Enjoy!")
        put ("")
        put ("Press Enter to START")
        View.Update
        if chars (KEY_ENTER) then
            delay (50)
            cls
            stp := 8
            delay (250)
        end if

    elsif stp = 5 then
        cls
        put ("Welcome to copthesaint's Color Finder.")
        put ("Use the Up and Down keys on your keyboard to change the color.")
        put ("If you have found the color you were looking for simply press enter and the program will show the code in the middle of the screen.")
        put ("Enjoy!")
        put ("")
        put ("Press Enter to START")
        View.Update
        if chars (KEY_ENTER) then
            delay (50)
            cls
            stp := 7
            delay (250)
        end if

    elsif stp = 4 then
        cls
        put ("Welcome to copthesaint's Sound Finder.")
        put ("Use the Up and Down keys on your keyboard to change how low or high the note is.")
        put ("Use the Right and Left keys on your keyboard to change how long the sound is.")
        put ("If you have found the sound you were looking for simply press enter and the program will show the code in the middle of the screen.")
        put ("Enjoy!")
        put ("")
        put ("Press Enter to START")
        View.Update
        if chars (KEY_ENTER) then
            delay (50)
            cls
            stp := 2
            delay (250)
        end if

    elsif stp = 2 then
        Music.SoundOff
        if chars (KEY_ENTER) then
            Font.Draw (("Music.Sound (" + intstr (spd) + "),(" + intstr (sdp) + ")"), 50, y, fnt1, black)
            View.Update
            delay (7000)
            stp := 1
        end if
        if chars (KEY_DOWN_ARROW) then
            if spd > 0 then
                spd := spd - 5
                stp := 3
                delay (50)
            end if
        end if
        if chars (KEY_UP_ARROW) then
            if spd < 5500 then
                spd := spd + 5
                stp := 3
                delay (50)
            end if
        end if
        if chars (KEY_RIGHT_ARROW) then
            if sdp < 5500 then
                sdp := sdp + 1
                stp := 3
                delay (50)
            end if
        end if
        if chars (KEY_LEFT_ARROW) then
            if sdp > 0 then
                sdp := sdp - 1
                stp := 3
                delay (50)
            end if
        end if
        delay (sdp)
        View.Update
        cls
    elsif stp = 3 then
        Music.Sound (spd, sdp)
        View.Update
        cls
        delay (sdp)
        stp := 2
    elsif stp = 0 then
        cls
        put ("Welcome to Copthesaint's Turing Helper.")
        put ("I hope this program helps you.")
        put ("Enjoy!")
        put ("")
        put ("Press Enter to START")
        View.Update
        if chars (KEY_ENTER) then
            delay (50)
            cls
            stp := 1
            delay (250)
        end if

    elsif stp = 1 then

        if chars (KEY_DOWN_ARROW) then
            if menuB < 4 then
                menuB += 1
                delay (250)
                cls
            end if
        end if
        if chars (KEY_UP_ARROW) then
            if menuB > 0 then
                menuB -= 1
                delay (250)
                cls
            end if
        end if

        if menuB = 1 then
            if chars (KEY_ENTER) then
                delay (50)
                cls
                stp := 4
                delay (250)
            end if
            Font.Draw ("Copthesaints Helper Programs", 50, 340, fnt1, black)
            Font.Draw ("Sound Finder", 150, 300, fnt1, black)
            Font.Draw ("Color Finder", 150, 275, fnt1, black)
            Font.Draw ("Position Editor", 150, 250, fnt1, black)
            Draw.FillBox (125, 300, 150, 318, black)
            View.Update
        end if
        if menuB = 2 then
            if chars (KEY_ENTER) then
                delay (50)
                cls
                stp := 5
                delay (250)
            end if
            Font.Draw ("Copthesaints Helper Programs", 50, 340, fnt1, black)
            Font.Draw ("Sound Finder", 150, 300, fnt1, black)
            Font.Draw ("Color Finder", 150, 275, fnt1, black)
            Font.Draw ("Position Editor", 150, 250, fnt1, black)
            Draw.FillBox (125, 275, 150, 293, black)
            View.Update
        end if
        if menuB = 3 then
            if chars (KEY_ENTER) then
                delay (50)
                cls
                stp := 6
                delay (250)
            end if
            Font.Draw ("Copthesaints Helper Programs", 50, 340, fnt1, black)
            Font.Draw ("Sound Finder", 150, 300, fnt1, black)
            Font.Draw ("Color Finder", 150, 275, fnt1, black)
            Font.Draw ("Position Editor", 150, 250, fnt1, black)
            Draw.FillBox (125, 250, 150, 268, black)
            View.Update
        end if
    end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Mon Nov 17, 2008 7:54 pm   Post subject: RE:Copthesaint\'s Turing Helper

You should look into procedures, save yourself a LOT of coding. My teacher has a policy, 'if it's bigger than 1 screen, break it into procedures.'. So if your code visible takes up more room than 1 screen, top to bottom, break it into procedures.

They really are quite easy, and you will start using them even when they are not necessary.
copthesaint




PostPosted: Mon Nov 17, 2008 8:04 pm   Post subject: Re: Copthesaint's Turing Helper

Thats fine but how would you resume to main menu?
Turing will not allow me to go from 1 procedure to another...

Btw expect less since I took 2 and a half hours to make this ;p;
also This isn't for marks I was just making a program to help other users.



this is a update
Insectoid




PostPosted: Mon Nov 17, 2008 9:02 pm   Post subject: RE:Copthesaint\'s Turing Helper

If this took 2.5 hours, then I expect more.

The menu typically is the last procedure you write, as it calls other procedures. You can indeed go from one procedure to another.

ex.

[code]
proc sound_thing
%blah
end sound_thing

proc color_thing
%blooh
end color_thing

proc box_thing
%blieh
end box_thing

proc menu
if sound_thing chosen then
sound_thing
elsif color_thing choses then
color_thing
elsif box_thing chosen then
box_thing
end if
end menu
copthesaint




PostPosted: Mon Nov 17, 2008 9:29 pm   Post subject: RE:Copthesaint\'s Turing Helper

HOW CAN YOU EXPECT MORE!
You didn't even download the new version
!!WOW!!
I think making a 500 line program in 2.5 hours is pretty good also since I type with 2 fingers.

Why not download the new version that took 2.5hours THEN judge...
gitoxa




PostPosted: Mon Nov 17, 2008 10:38 pm   Post subject: Re: RE:Copthesaint\'s Turing Helper

insectoid @ Mon Nov 17, 2008 7:54 pm wrote:
You should look into procedures, save yourself a LOT of coding. My teacher has a policy, 'if it's bigger than 1 screen, break it into procedures.'. So if your code visible takes up more room than 1 screen, top to bottom, break it into procedures.

That's a pretty bad policy, if I do say so myself. For one, breaking things into procedures the way you explained doesn't save you any typing whatsoever. Unless of course you're counting negative. Yea that's right, there's more typing.
And please lay off copthesaint, i've seen a few of his posts now where all you've done is harass him.


insectoid @ Mon Nov 17, 2008 9:02 pm wrote:
If this took 2.5 hours, then I expect more. The menu typically is the last procedure you write, as it calls other procedures. You can indeed go from one procedure to another.

I write it first, it's just preference.
CodeMonkey2000




PostPosted: Mon Nov 17, 2008 11:46 pm   Post subject: Re: RE:Copthesaint\'s Turing Helper

insectoid @ Mon Nov 17, 2008 7:54 pm wrote:
You should look into procedures, save yourself a LOT of coding. My teacher has a policy, 'if it's bigger than 1 screen, break it into procedures.'. So if your code visible takes up more room than 1 screen, top to bottom, break it into procedures.

They really are quite easy, and you will start using them even when they are not necessary.


Imo that's a bad policy. I have a policy, where if you are copy and pasting a lot of code that has the same logic, you probably should factor that into one general method/procedure.
Euphoracle




PostPosted: Tue Nov 18, 2008 6:58 am   Post subject: RE:Copthesaint\'s Turing Helper

I "design" my code on a lined sheet of paper before writing, which usually makes it obvious what code will be repeating, and thus, functions.
copthesaint




PostPosted: Tue Nov 18, 2008 7:40 am   Post subject: Re: Copthesaint's Turing Helper

Yes I do also write my program on lined sheets of paper but Since I wasn't like trying to get marks on this I just did trial and error.
The reason why I made this was really because I didn't have my final fantasy project on me or at least my recent version with me. Rolling Eyes Smile
Again I hope this does help someone.

Also I seemed to notice that there are all these coments but there Are Downloads...
I'd prefer if you looked at the final post of my project before you comment...

Btw my finl Update will have these tools.
Sound finder
Color finder
box creator and positioner.
oval creator and positioner.
I don't know If I will Do all the shapes...
I just thought I would do the basics
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  [ 9 Posts ]
Jump to:   


Style:  
Search: