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

Username:   Password: 
 RegisterRegister   
 HELP with Paint Outline - URGENT!!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mcv




PostPosted: Sat Apr 29, 2006 9:47 pm   Post subject: HELP with Paint Outline - URGENT!!

I made a paint outline but everytime I run it it the screen flickers. For the pics, I have them saved in the attachment. Can you tell me how to make it so that the screen does not flicker and my green highlight/pics still work and show on the boxes? I need this for Monday. Thanks

PS: Anyone know why the save/load boxes are not displayed and how to use them in order to allow the user to choose a save name and save the picture with a bmp extension?

code:

%The "Draw It!" program.

%****************Declares variables and gives general outline****************

var pencil, circle, line, star, paint, text, eraser, box : int
var x,y,button : int

pencil := Pic.FileNew ("pencil.bmp")
circle := Pic.FileNew ("circle.bmp")
line := Pic.FileNew ("line.bmp")
star := Pic.FileNew ("star.bmp")
paint := Pic.FileNew ("paint.bmp")
text := Pic.FileNew ("text.bmp")
eraser := Pic.FileNew ("eraser.bmp")
box := Pic.FileNew ("box.bmp")

%****************Displays the tool boxes****************

    loop

    colourback (black)
    locate (11, 5)
colour (white)
put "Tools"
   
        Mouse.Where (x, y, button)
        %Draw Line
        Draw.Box (5, 5, 55, 55, white)
        Pic.Draw (line, 20, 20, picCopy)

        %Draw Box
        Draw.Box (5, 60, 55, 110, white)
        Pic.Draw (box, 20, 75, picCopy)

        %Draw star
        Draw.Box (5, 115, 55, 165, white)
        Pic.Draw (star, 20, 130, picCopy)

        %Draw Circle
        Draw.Box (5, 170, 55, 220, white)
        Pic.Draw (circle, 20, 185, picCopy)

        %Pencil
        Draw.Box (60, 5, 110, 55, white)
        Pic.Draw (pencil, 75, 20, picCopy)

        %Eraser
        Draw.Box (60, 60, 110, 110, white)
        Pic.Draw (eraser, 75, 75, picCopy)

        %Text
        Draw.Box (60, 115, 110, 165, white)
        Pic.Draw (text, 75, 130, picCopy)

        %Paint Bucket
        Draw.Box (60, 170, 110, 220, white)
        Pic.Draw (paint, 75, 185, picCopy)

        if x > 4 and x < 56 and y > 4 and y < 56 and button = 1 then
            Draw.FillBox (5, 5, 55, 55, green)
            Pic.Draw (line, 20, 20, picCopy)
            delay (500)
            cls
           
        elsif x > 4 and x < 56 and y > 59 and y < 111 and button = 1 then
            Draw.FillBox (5, 60, 55, 110, green)
            Pic.Draw (box, 20, 75, picCopy)
            delay (500)
            cls
           
        elsif x > 4 and x < 56 and y > 114 and y < 166 and button = 1 then
            Draw.FillBox (5, 115, 55, 165, green)
            Pic.Draw (star, 20, 130, picCopy)
            delay (500)
            cls
           
        elsif x > 4 and x < 56 and y > 169 and y < 220 and button = 1 then
            Draw.FillBox (5, 170, 55, 220, green)
            Pic.Draw (circle, 20, 185, picCopy)
            delay (500)
            cls
           
        elsif x > 59 and x < 111 and y > 4 and y < 56 and button = 1 then
            Draw.FillBox (60, 5, 110, 55, green)
            Pic.Draw (pencil, 75, 20, picCopy)
            delay (500)
            cls
           
        elsif x > 59 and x < 111 and y > 59 and y < 111 and button = 1 then
            Draw.FillBox (60, 60, 110, 110, green)
            Pic.Draw (eraser, 75, 75, picCopy)
            delay (500)
            cls
           
        elsif x > 59 and x < 111 and y > 114 and y < 166 and button = 1 then
            Draw.FillBox (60, 115, 110, 165, green)
            Pic.Draw (text, 75, 130, picCopy)
            delay (500)
            cls
           
        elsif x > 59 and x < 111 and y > 169 and y < 221 and button = 1 then
            Draw.FillBox (60, 170, 110, 220, green)
            Pic.Draw (paint, 75, 185, picCopy)
            delay (500)
            cls
           
        end if

%****************Displays the colour boxes****************


locate (1, 2)
colour (white)
put "Choose colour"
cls

Draw.FillBox (5, 325, 55, 375, blue)
Draw.FillBox (5, 270, 55, 320, red)

Draw.FillBox (60, 325, 110, 375, green)
Draw.FillBox (60, 270, 110, 320, white)

%****************Displays drawing box****************

locate (2, 50)
colour (white)
put "Draw It!"

%****************Displays SAVE AND LOAD boxes****************

%Click to save.
Draw.Box (600, 50, 250, 350, white)
%Click to load.
Draw.Box (60, 170, 110, 220, white)

end loop



Paint Program Assignment.ace
 Description:
You can open it up with winace, winrar or any extraction program.

Download
 Filename:  Paint Program Assignment.ace
 Filesize:  1.15 KB
 Downloaded:  119 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
do_pete




PostPosted: Sat Apr 29, 2006 10:00 pm   Post subject: (No subject)

You need to learn how to use View.Update. Check out the Turing Walkthrough for a tutorial.
jamonathin




PostPosted: Sat Apr 29, 2006 10:21 pm   Post subject: Re: HELP with Paint Outline - URGENT!!

mcv wrote:

PS: Anyone know why the save/load boxes are not displayed and how to use them in order to allow the user to choose a save name and save the picture with a bmp extension?


By taking a look at just the coding (i dont have winRAR), i can see one reason why your program flickers so much, your CLS is halfway through your program! How do you expect to see everything if your CLS is in the Display Colors section? put it at the top, and use only 1 cls and 1 View.Update.

Since there aren't any delays in your main loop (neverminding your if statements), its no wonder you can't see the white boxes when your program is flashing at warp speed with no View.Update.
But note: do NOT use delay's when u get in View.Update - it'll just slow stuff down.

to save a picture is really easy - just take a look at this code and incorporate it into your program:


code:
drawfillbox (100, 100, 200, 200, green)

var name : string

put "Enter file name: " ..
get name

var newPic : int := Pic.New (100, 100, 200, 200)
Pic.Save (newPic, name + ".bmp")

put "Image saved as: ", name + ".bmp"
do_pete




PostPosted: Sat Apr 29, 2006 10:51 pm   Post subject: (No subject)

Use Pic.ScreenSave instead.

Random note: this is the 111,111th post on this site
mcv




PostPosted: Sun Apr 30, 2006 9:35 am   Post subject: Still doesn't work..

Anyone know how to load a file? I wrote a new code with procedures but the boxes are all still out of place.

code:


%The "Draw It!" program.

%****************Declares variables and gives general outline****************

var pencil, circle, line, star, paint, text, eraser, box : int
var x, y, button : int

pencil := Pic.FileNew ("pencil.bmp")
circle := Pic.FileNew ("circle.bmp")
line := Pic.FileNew ("line.bmp")
star := Pic.FileNew ("star.bmp")
paint := Pic.FileNew ("paint.bmp")
text := Pic.FileNew ("text.bmp")
eraser := Pic.FileNew ("eraser.bmp")
box := Pic.FileNew ("box.bmp")

%****************Displays the tool boxes****************

colourback (black)
locate (11, 5)
colour (white)
put "Tools"

Mouse.Where (x, y, button)

%Draw Line
proc line1
    Draw.Box (5, 5, 55, 55, white)
    Pic.Draw (line, 20, 20, picCopy)
    if x > 4 and x < 56 and y > 4 and y < 56 and button = 1 then
        Draw.FillBox (5, 5, 55, 55, green)
        Pic.Draw (line, 20, 20, picCopy)
        delay (500)
        cls
    end if
end line1

%Draw Box
proc box1
    Draw.Box (5, 60, 55, 110, white)
    Pic.Draw (box, 20, 75, picCopy)
    if x > 4 and x < 56 and y > 59 and y < 111 and button = 1 then
        Draw.FillBox (5, 60, 55, 110, green)
        Pic.Draw (box, 20, 75, picCopy)
        delay (500)
    end if
end box1

%Draw star
proc star1
    Draw.Box (5, 115, 55, 165, white)
    Pic.Draw (star, 20, 130, picCopy)
    if x > 4 and x < 56 and y > 114 and y < 166 and button = 1 then
        Draw.FillBox (5, 115, 55, 165, green)
        Pic.Draw (star, 20, 130, picCopy)
        delay (500)
    end if
end star1

%Draw Circle
proc circle1
    Draw.Box (5, 170, 55, 220, white)
    Pic.Draw (circle, 20, 185, picCopy)
    if x > 4 and x < 56 and y > 169 and y < 220 and button = 1 then
        Draw.FillBox (5, 170, 55, 220, green)
        Pic.Draw (circle, 20, 185, picCopy)
        delay (500)
    end if
end circle1

%Pencil
proc pencil1
    Draw.Box (60, 5, 110, 55, white)
    Pic.Draw (pencil, 75, 20, picCopy)
    if x > 59 and x < 111 and y > 4 and y < 56 and button = 1 then
        Draw.FillBox (60, 5, 110, 55, green)
        Pic.Draw (pencil, 75, 20, picCopy)
        delay (500)
    end if
end pencil1

%Eraser
proc eraser1
    Draw.Box (60, 60, 110, 110, white)
    Pic.Draw (eraser, 75, 75, picCopy)
    if x > 59 and x < 111 and y > 59 and y < 111 and button = 1 then
        Draw.FillBox (60, 60, 110, 110, green)
        Pic.Draw (eraser, 75, 75, picCopy)
        delay (500)
    end if
end eraser1

%Text
proc text1
    Draw.Box (60, 115, 110, 165, white)
    Pic.Draw (text, 75, 130, picCopy)
    if x > 59 and x < 111 and y > 114 and y < 166 and button = 1 then
        Draw.FillBox (60, 115, 110, 165, green)
        Pic.Draw (text, 75, 130, picCopy)
        delay (500)
    end if
end text1

%Paint Bucket
proc paint1
    Draw.Box (60, 170, 110, 220, white)
    Pic.Draw (paint, 75, 185, picCopy)
    if x > 59 and x < 111 and y > 169 and y < 221 and button = 1 then
        Draw.FillBox (60, 170, 110, 220, green)
        Pic.Draw (paint, 75, 185, picCopy)
        delay (500)
    end if
end paint1


%****************Displays the colour boxes****************


locate (1, 2)
colour (white)
put "Choose colour"

Draw.FillBox (5, 325, 55, 375, blue)
Draw.FillBox (5, 270, 55, 320, red)

Draw.FillBox (60, 325, 110, 375, green)
Draw.FillBox (60, 270, 110, 320, white)

%****************Displays drawing box****************

locate (2, 50)
colour (white)
put "Draw It!"

%****************Displays SAVE AND LOAD boxes****************

%Click to save.
Draw.Box (600, 300, 700, 350, white)

var name : string

put "Enter file name: " ..
get name

var newPic : int := Pic.New (100, 100, 200, 200)
Pic.Save (newPic, name + ".bmp")

put "Image saved as: ", name + ".bmp"


%Click to load.
Draw.Box (60, 170, 110, 220, white)


View.Update

jamonathin




PostPosted: Sun Apr 30, 2006 10:06 am   Post subject: Re: Still doesn't work..

mcv wrote:
Anyone know how to load a file? I wrote a new code with procedures but the boxes are all still out of place.


Well first of all, you know how to load a file. You have already shown that you know how to use Pic.FileNew and Pic.Draw - there is no difference.

Now for your boxes, one is drawn at: (600, 300, 700, 350, white)
- where the maximun x-value on the screen is 639. (you are going to 700)
And your second one is being drawn after the get statement, so that is why you don't see it right away - im not shure where you want it however.

You need to double check your (x1, y1, x2, y2) values in your boxes.
mcv




PostPosted: Sun Apr 30, 2006 10:15 am   Post subject: (No subject)

Yes. But, why don't all my boxes show up in the lay out like the main drawing box, colour boxes, text, etc..
mcv




PostPosted: Sun Apr 30, 2006 11:25 am   Post subject: (No subject)

Nevermind my last message. I decided to go along with a standard white background.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: