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

Username:   Password: 
 RegisterRegister   
 Colour Changing 2
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mike200015




PostPosted: Fri Jan 21, 2005 12:24 am   Post subject: Colour Changing 2

Hey i got it to work, thanx to whoever helped me.

My program draws shapes. When u press up it increses the colour by 1. When you press down it decreases by 1. The only thing is when u draw 1 shape, it stops and waits for input from the keyboard, i dont want it to. i want it to be able so you can press up or down anytime while you are drawing shapes. This is a part of my program. What do i need to do in this portion so it will draw the filled box while u pres the buttons?
code:
procedure colchange
    getch (key)
    if key = KEY_UP_ARROW then
        col := col + 1
    elsif key = KEY_DOWN_ARROW then
        col := col - 1
    end if
    if col > 255 then
        col := 0
    elsif col < 0 then
        col := 255
    end if
end colchange


procedure mike
    loop
        buttonwait ("down", x1, y1, b1, b2)
        x2 := x1
        y2 := y1
        drawfillbox (x1, y1, x2, y2, col)
        loop
            mousewhere (x, y, b1)
            exit when b1 = 0
            if x not= x2 or y not= y2 then
                drawfillbox (x1, y1, x2, y2, col)
                x2 := x
                y2 := y
                drawfillbox (x1, y1, x2, y2, col)

            end if

        end loop
    end loop
end mike

Sponsor
Sponsor
Sponsor
sponsor
eNc




PostPosted: Fri Jan 21, 2005 9:12 am   Post subject: Re: Colour Changing 2

Hey ok check this out I think it may help you here but i'm not entirely sure.


code:
setscreen ("nocursor")
var col : int
var key : string (1)
procedure colchange
col := 0
    loop
        getch (key)
        if key = KEY_UP_ARROW then
            if col < 255 then
                col := col + 1
            elsif col = 255 then
                col := col - 1
            end if
        elsif key = KEY_DOWN_ARROW then
            if col not= 0 then
                col := col - 1
            elsif col = 1 then
                col := col + 1
            end if
        end if
        %Drawing stuff
        drawfillbox (20, 20, 300, 300, col)
        locate (15, 40)
        put col
        delay (200)
    end loop
end colchange
colchange



Press up/Down to begin
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  [ 2 Posts ]
Jump to:   


Style:  
Search: