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

Username:   Password: 
 RegisterRegister   
 Problem with mutli commands
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TokenHerbz




PostPosted: Sat Jul 23, 2005 9:23 pm   Post subject: Problem with mutli commands

TRY THIS, I JUST MADE IT!!!!
FUN FUN FUN
code:

%%%Practise!%%%

setscreen ("graphics:200;300")

var choice: int     %get choice to color
var num: int     %pick number color
var c: int
var key : array char of boolean
c := 0

put "1 changes house."
put "2 changes door."
put "3 changes door window."
put "4 changes T L window."
put "5 changes T R wondow."
put "6 changes B R window."
put "7 changes top window."
put "8 changes EVERYTHING!."
put "9 = H E L P !."
put "Press SPACE to clear!."
put "0 --> Choose a color!."
Input.Pause
cls

loop
    Input.KeyDown (key)
   
%House outlines   
    if key ('1') then
        randint (c,1,99)
        drawline (20,20,180,20,c)           %bottom
        drawline (20,20,20,180,c)           %left
        drawline (180,20,180,180,c)         %right
        drawline (20,180,180,180,c)         %top
        drawline (20,180,100,300,c)         %roof left
        drawline (100,300,180,180,c)        %roof right
    end if
%door
    if key ('2') then
        randint (c,1,99)
        drawline (40,20,40,60,c)            %left
        drawline (40,60,60,60,c)            %top
        drawline (60,60,60,20,c)            %right
        drawoval (55,35,1,1,c)              %handle
    end if
%door window
    if key ('3') then
        randint (c,1,99)
        drawline (45,45,55,45,c)            %bottom
        drawline (45,45,45,55,c)            %left 
        drawline (45,55,55,55,c)            %top
        drawline (55,55,55,45,c)            %right
    end if
%Left top window
    if key ('4') then
        randint (c,1,99)
        drawline (40,100,40,150,c)          %left
        drawline (40,150,90,150,c)          %top
        drawline (90,150,90,100,c)          %right
        drawline (40,100,90,100,c)          %bottom
    end if
%Right top window
    if key ('5') then
        randint (c,1,99)
        drawline (111,100,111,150,c)        %left
        drawline (111,150,160,150,c)        %top
        drawline (160,150,160,100,c)        %right
        drawline (111,100,160,100,c)        %bottom
    end if
%Right bottom window
    if key ('6') then
        randint (c,1,99)
        drawline (90,30,150,30,c)           %bottom
        drawline (90,30,90,60,c)            %left
        drawline (90,60,150,60,c)           %top
        drawline (150,60,150,30,c)          %right
    end if
%addict 'triangle' window
    if key ('7') then
        randint (c,1,99)
        drawline (70,210,130,210,c)         %bottom
        drawline (70,210,100,250,c)         %left
        drawline (100,250,130,210,c)        %right
    end if
   
%CHANGES HOLE PICTURE AS 1!
    if key ('8') then
        loop
            randint (c,1,99)
            drawline (20,20,180,20,c)         
            drawline (20,20,20,180,c)           
            drawline (180,20,180,180,c)         
            drawline (20,180,180,180,c)         
            drawline (20,180,100,300,c)       
            drawline (100,300,180,180,c)       
            drawline (40,20,40,60,c)         
            drawline (40,60,60,60,c)           
            drawline (60,60,60,20,c)           
            drawoval (55,35,1,1,c)             
            drawline (45,45,55,45,c)       
            drawline (45,45,45,55,c)         
            drawline (45,55,55,55,c)           
            drawline (55,55,55,45,c)           
            drawline (40,100,40,150,c)         
            drawline (40,150,90,150,c)   
            drawline (90,150,90,100,c)         
            drawline (40,100,90,100,c)         
            drawline (111,100,111,150,c)       
            drawline (111,150,160,150,c)       
            drawline (160,150,160,100,c)       
            drawline (111,100,160,100,c)     
            drawline (90,30,150,30,c)       
            drawline (90,30,90,60,c)     
            drawline (90,60,150,60,c)         
            drawline (150,60,150,30,c)       
            drawline (70,210,130,210,c)         
            drawline (70,210,100,250,c)       
            drawline (100,250,130,210,c)
            exit when hasch       
        end loop
        cls
    end if

%Help part!
    if key ('9') then
        cls
        put "1 changes house."
        put "2 changes door."
        put "3 changes door window."
        put "4 changes T L window."
        put "5 changes T R wondow."
        put "6 changes B R window."
        put "7 changes top window."
        put "8 changes EVERYTHING!."
        put "9 = H E L P !."
        put "Press SPACE to clear!."
        put "0 --> Choose a color!."
        Input.Pause
        cls
    end if
   
%Clearing screen
    if key (' ') then
        cls
    end if
   
%Choose a color
    if key ('0') then
        cls
        put "Hi, Color your house"
        cls
        loop
            loop
                put "Use number 1 - 225"
                get num
                cls
                if num >= 1 and num <= 225 then
                    exit
                end if
            end loop

            loop
                put "Please choose which part you want that color"
                put "1 for frame"
                put "2 for door"
                put "3 for door window"
                put "4 for T L window"
                put "5 for T R window"
                put "6 for B R window"
                put "7 for Addict window"
                get choice
                cls
                if choice >= 1 and choice <=7 then
                    exit
                end if
            end loop
            if choice = 1 then
                drawline (20,20,180,20,num)   
                drawline (20,20,20,180,num)     
                drawline (180,20,180,180,num)         
                drawline (20,180,180,180,num)       
                drawline (20,180,100,300,num)         
                drawline (100,300,180,180,num)
            end if
            if choice = 2 then
                drawline (40,20,40,60,num)         
                drawline (40,60,60,60,num)         
                drawline (60,60,60,20,num)         
                drawoval (55,35,1,1,num)
            end if
            if choice = 3 then
                drawline (45,45,55,45,num)       
                drawline (45,45,45,55,num)           
                drawline (45,55,55,55,num)           
                drawline (55,55,55,45,num)
            end if
            if choice = 4 then
                drawline (40,100,40,150,num)         
                drawline (40,150,90,150,num)       
                drawline (90,150,90,100,num)         
                drawline (40,100,90,100,num)
            end if
            if choice = 5 then
                drawline (111,100,111,150,num)     
                drawline (111,150,160,150,num)       
                drawline (160,150,160,100,num)       
                drawline (111,100,160,100,num)
            end if
            if choice = 6 then
                drawline (90,30,150,30,num)       
                drawline (90,30,90,60,num)           
                drawline (90,60,150,60,num)           
                drawline (150,60,150,30,num)
            end if
            if choice = 7 then
                drawline (70,210,130,210,num)       
                drawline (70,210,100,250,num)         
                drawline (100,250,130,210,num)
            end if
        end loop
    end if
    Input.Pause
end loop


now when you try this, press 0...
it seems to work, but its over after u choose 1 color, then the house is gone. I want to beable to keep the house, and still add on personal user colours...

ALSO, i tryed to do this with words

like
var word: string
put "enter a color"
get word

drawfilloval (55,55,5,5,word)
is dosn't work...

Which to me should, cause if u type red then
drawfillcirle (55,55,5,5,red)
Which does work...

Anyways, please help me!!!

Thanks...
Sponsor
Sponsor
Sponsor
sponsor
TokenHerbz




PostPosted: Sat Jul 23, 2005 9:25 pm   Post subject: (No subject)

PS...

Be honest, how much extra work did i do??

how short can i make this with keeping all of my functions?
[Gandalf]




PostPosted: Sat Jul 23, 2005 9:47 pm   Post subject: (No subject)

Well, it seems like the code could be shortened a lot using for loops. Look for loops up in the tutorials sections.
MysticVegeta




PostPosted: Mon Jul 25, 2005 9:11 am   Post subject: (No subject)

i dont... get it. What does it do? We can change everything by just changing the door Confused
Delos




PostPosted: Mon Jul 25, 2005 1:47 pm   Post subject: (No subject)

Well for a start you could put all your drawing commands in procedures. You could use seperate proecedures for each (inclue parameters to make things easier to change later), or you could use a single procedure that pretty much draws straight from your if structure.

Oh, and 'setscreen("nobuttonbar")' would be good, and look into View.Update() and offscreenonly for your graphic changes. Right now you don't have anything to worry about since you don't have any animation, but it's always useful to know about.
Geminias




PostPosted: Mon Sep 19, 2005 4:06 pm   Post subject: (No subject)

dude, i'm a complete noob but i'll be honest, you did tonz more work than necessary

why not just use Draw.Box ? instead of drawing all four lines to make the box lol.
Cervantes




PostPosted: Mon Sep 19, 2005 5:17 pm   Post subject: (No subject)

I'm sure if he did it now, nearly two months later, he would do so.

http://www.compsci.ca/v2/viewtopic.php?t=6405
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  [ 7 Posts ]
Jump to:   


Style:  
Search: