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

Username:   Password: 
 RegisterRegister   
 Need help with my program and with drawing...Please
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
madskillz




PostPosted: Tue Jan 13, 2004 9:32 pm   Post subject: Need help with my program and with drawing...Please

Hi. I've just sstarted turing and I was wondering if you guys can help me improve my program. This is what I have so far.
code:
import GUI
% Change window to 500x500
setscreen ("graphics")
var winID1 : int := Window.Open ("position:100;100, graphics:700;500")
%Declaration section
var choice : int
var colour1 : int
var xcoord : int
var ycoord : int
var xcoord2 : int
var ycoord2 : int
var key : string (1)
%Fonts
var font1, font2 : int
%Buttons
var draw1, draw2, quit1 : int := 0
%Background
drawfillbox (1, 1, 699, 499, black)
%Procedures Title, pauseProgram...
proc title
    font1 := Font.New ("BERNARD:60:")
    assert font1 > 0
    Font.Draw ("Microsoft Paint", 153, 430, font1, brightred)
    Font.Free (font1)
end title
proc pauseProgram
    font2 := Font.New ("KARINE:18:bold")
    assert font2 > 0
    Font.Draw ("Press any key to continue..", 1, 110, font2, brightblue)
    Font.Free (font2)
    locate (26, 1)
    getch (key)
end pauseProgram
proc intro
    title
    font2 := Font.New ("KARINE:18:bold")
    assert font2 > 0
    Font.Draw ("This program will help you draw either a rectangle or a circle.", 1, 270, font2, brightgreen)
    Font.Free (font2)
    pauseProgram
end intro
proc shapeChoice
    font2 := Font.New ("KARINE:18:bold")
    assert font2 > 0
    Font.Draw ("What do you want to do?", 1, 300, font2, brightblue)
    Font.Free (font2)
end shapeChoice
%First Page
%------------------------------------------------
intro
%------------------------------------------------
%Stars that clean screen
proc starsClean1
    for x : 0 .. 720 by 5
        Draw.FillStar (-50 + x, -3, 50 + x, 100, yellow)
        Draw.FillStar (-50 + x, 50, 50 + x, 150, yellow)
        Draw.FillStar (-50 + x, 100, 50 + x, 200, yellow)
        Draw.FillStar (-50 + x, 150, 50 + x, 250, yellow)
        Draw.FillStar (-50 + x, 200, 50 + x, 300, yellow)
        Draw.FillStar (-50 + x, 250, 50 + x, 350, yellow)
        Draw.FillStar (-50 + x, 300, 50 + x, 400, yellow)
        Draw.FillStar (-50 + x, 350, 50 + x, 450, yellow)
        Draw.FillStar (-50 + x, 400, 50 + x, 503, yellow)
        delay (25)
        Draw.FillStar (-50 + x, -3, 50 + x, 100, 42)
        Draw.FillStar (-50 + x, 50, 50 + x, 150, 42)
        Draw.FillStar (-50 + x, 100, 50 + x, 200, 42)
        Draw.FillStar (-50 + x, 150, 50 + x, 250, 42)
        Draw.FillStar (-50 + x, 200, 50 + x, 300, 42)
        Draw.FillStar (-50 + x, 250, 50 + x, 350, 42)
        Draw.FillStar (-50 + x, 300, 50 + x, 400, 42)
        Draw.FillStar (-50 + x, 350, 50 + x, 450, 42)
        Draw.FillStar (-50 + x, 400, 50 + x, 503, 42)
    end for
end starsClean1
%Stars clean
%------------------------------------------------
starsClean1
%------------------------------------------------
%mainMenu proc
proc mainMenu
    title
    shapeChoice
    GUI.Show (draw1)
    GUI.Show (draw2)
    GUI.Show (quit1)
end mainMenu
%Stars that clean screen
proc starsClean2
    for decreasing x : 820 .. 0 by 5
        Draw.FillStar (-100 + x, -3, 0 + x, 100, yellow)
        Draw.FillStar (-100 + x, 50, 0 + x, 150, yellow)
        Draw.FillStar (-100 + x, 100, 0 + x, 200, yellow)
        Draw.FillStar (-100 + x, 150, 0 + x, 250, yellow)
        Draw.FillStar (-100 + x, 200, 0 + x, 300, yellow)
        Draw.FillStar (-100 + x, 250, 0 + x, 350, yellow)
        Draw.FillStar (-100 + x, 300, 0 + x, 400, yellow)
        Draw.FillStar (-100 + x, 350, 0 + x, 450, yellow)
        Draw.FillStar (-100 + x, 400, 0 + x, 503, yellow)
        delay (25)
        Draw.FillStar (-100 + x, -3, 0 + x, 100, 4)
        Draw.FillStar (-100 + x, 50, 0 + x, 150, 4)
        Draw.FillStar (-100 + x, 100, 0 + x, 200, 4)
        Draw.FillStar (-100 + x, 150, 0 + x, 250, 4)
        Draw.FillStar (-100 + x, 200, 0 + x, 300, 4)
        Draw.FillStar (-100 + x, 250, 0 + x, 350, 4)
        Draw.FillStar (-100 + x, 300, 0 + x, 400, 4)
        Draw.FillStar (-100 + x, 350, 0 + x, 450, 4)
        Draw.FillStar (-100 + x, 400, 0 + x, 503, 4)
    end for
end starsClean2
proc colour4
    for x : 1 .. 999999
        font2 := Font.New ("KARINE:18:bold")
        assert font2 > 0
        Font.Draw ("Chose an option above using the numbers: ", 1, 130, font2, brightgreen)
        Font.Free (font2)
        locate (23, 50)
        get choice
        if choice = 1 then
            colour1 := 55
            exit
        elsif choice = 2 then
            colour1 := 12
            exit
        elsif choice = 3 then
            colour1 := 47
            exit
        elsif choice = 4 then
            colour1 := 14
            exit
        elsif choice = 5 then
            colour1 := black
            exit
        elsif choice = 6 then
            starsClean1
            mainMenu
            exit
        else
            font2 := Font.New ("KARINE:18:bold")
            assert font2 > 0
            Font.Draw ("I gave you all the options and you still get it wrong. Try again!", 1, 100, font2, brightgreen)
            Font.Free (font2)
            locate (23, 50)
            get choice
        end if
    end for
end colour4
proc colour3
    font2 := Font.New ("KARINE:18:bold")
    assert font2 > 0
    Font.Draw ("What colour do you want your shape to be?", 1, 270, font2, brightgreen)
    Font.Draw ("1. Blue", 1, 250, font2, brightblue)
    Font.Draw ("2. Red", 1, 230, font2, brightred)
    Font.Draw ("3. Green", 1, 210, font2, brightgreen)
    Font.Draw ("4. Yellow", 1, 190, font2, yellow)
    Font.Draw ("5. Black", 1, 170, font2, black)
    Font.Draw ("6. Go back to Main Menu", 1, 150, font2, 42)
    Font.Free (font2)
end colour3
%Proc Colour2
proc colour2
    GUI.Hide (draw1)
    GUI.Hide (draw2)
    GUI.Hide (quit1)
    starsClean2
    title
    colour3
    colour4
end colour2
%Instructions
proc instructionscircle
end instructionscircle
 
%Close Windows
procedure closeWindows
    GUI.CloseWindow (winID1)
end closeWindows
%Main menu
draw1 := GUI.CreateButtonFull (180, 150, 0, "Draw a Rectangle", colour2, 0, '^F', false)
draw2 := GUI.CreateButtonFull (300, 150, 0, "Draw a Circle", colour2, 0, '^S', false)
quit1 := GUI.CreateButtonFull (400, 150, 0, "Quit", GUI.Quit, 0, KEY_ESC, false)

%------------------------------------------------
mainMenu
%------------------------------------------------
%setWindows
loop
    exit when GUI.ProcessEvent
end loop
closeWindows

What I have to do is create a program that will allow the user to input the colour and then draw a circle or rectangle with the mouse.
I want to know if you have any ideas on how to improve my program and how to make my program draw with the mouse. Thanx ahead of time.My program look like shit, so can you give me ideas to make it look better/
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Tue Jan 13, 2004 11:12 pm   Post subject: (No subject)

well:

Mouse.Where (var x, y, button : int)

can be used to track where the mouse is, the x and y vars put in to this will have the cordents of the mouse and the button var will have a num indacting where the buttion is down or up.

you could draw bascik shapes at x and y when buttion is not 0 for a very basik pant progame.

also there is more info on using the mouse in turing and the code for some realy good paint progames on the site.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Thuged_Out_G




PostPosted: Wed Jan 14, 2004 4:23 pm   Post subject: (No subject)

code:

var x,y,button:int
var clr:int
var flag:boolean
put "PLease enter color number you wish to use: "..
get clr
var xy:array 1..2

loop
Mouse.Where(x,y,button)
if button=1 then
flag:=true
xy(1):=x
xy(2):=y
end if

if flag=true then
drawoval(xy(1),xy(2),xy(1),xy(2),clr)
end if
end loop


that should work...dont have turing on this comp to check...im sure there is a better method not envolving flags...but meh lol
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  [ 3 Posts ]
Jump to:   


Style:  
Search: