! Building a house.
 ! In this program, the user interacts with the program to design a house that is 1,2,or 3 stories tall with up to 2,4,or 5 rooms depending on the number of 
 ! stories.  A user is also asked to choose if he would like a door and grass.  Finally, the user is asked to input text which will be displayed in color
! along with sound once the user clicks wherever he chooses.

 !1: SET MODE, line 33
 !2: SET WINDOW, line 34
 !3: PRINT, line 38
 !4: PAUSE, line 39
 !5: DO-LOOP, line 41
 !6: INPUT PROMPT, line 42
 !7: SELECT CASE-END SELECT, line 43
 !8: ELSEIF, line 64
 !9: IF-ELSE-ENDIF, 102
 !10: DRAW, line 65
 !11: PICTURE, line 174
 !12: BOX LINES, line 179
 !13: BOX CIRCLE, line 184
 !14: PLOT LINES, line 196
 !15: SET COLOR, line 209
 !16: FLOOD, line 210
 !17: SOUND, line 232
 !18: PLOT POINTS, line 240
 !19: GET POINT, line 246
 !20: PLOT TEXT, line 247

 

 SET MODE "GRAPHICS"             !setting to graphics mode                         
 SET WINDOW -25,25,0,51          ! setting the size of the window to 50 by 51                         

 

 PRINT "It's time to build a house!"         !displaying this line of text on the screen                         
PAUSE 2                                     !asking the program to pause slightly                        
PRINT                                       !creating a blank space on the screen                        
DO                             !starting a loop
 INPUT PROMPT "First, how many stories tall would you like your house to be?": stories            !prompting the user to enter an answer which will be stored as "stories" for the program to read next.               
 SELECT CASE stories                         !now, the program will be able plot different lines (3 cases) depending on the input given by the user in the previous input line.                         
   CASE 1                        
       PLOT LINES: -15,0; -15,10 ; 0,18 ; 15,10 ; 15,0 ; -15,0                         
   CASE 2                        
       PLOT LINES: -15,0; -15,18 ; 0,27 ; 15,18 ; 15,0 ; -15,0                         
   CASE 3                        
       PLOT LINES: -15,0; -15,26 ; 0,34 ; 15,26 ; 15,0 ; -15,0                         
   CASE ELSE                        
       PRINT "Please choose 1,2,or 3 stories."                        
END SELECT                        
 LOOP while stories > 3                     !this part of the program will loop until the user enters 1,2,or 3.  If the user enters something else, they will be prompted again until they choose 1,2or3.                         
PRINT                            !displaying a blank line on the screen
PAUSE 1                            !causing the program to pause slightly
DO                              !another loop, explained at the LOOP statement
 INPUT PROMPT "Now, how many rooms would you like?  Please choose no more than 5..." : rooms      !just as in the last case, the variable "rooms" tells the program how many rooms the user wants.  Depending on the number of rooms and the level of stories, the program will proceede to one of the next cases and if statements.                         
LOOP while rooms > 5                  !this question will repeat until the user enters a number no larger than 5         
PRINT                        
PAUSE 2                           
 PRINT "You'll be able to tell how many rooms are in your house by how many windows you see!"                        
SELECT CASE rooms                        
   CASE 1                        !here, if the user says he wants 1 room, the program will draw that room in a different place depending on the level or stories in the house.     
      IF stories = 1 then              !also, notice that the DRAW statement knows how to draw Window from the PICTURE Window statement later in the program.               
          DRAW Window (0,10)                    
      ELSEIF stories = 2 then                   
       DRAW Window (0,10)               
      ELSEIF stories = 3 then                   
       DRAW Window (0,16)               
      END IF                   
   CASE 2                        !again, depending on the number of stories, the program will draw 2 rooms in a specified location
      IF stories = 1 then                   
       DRAW Window (-9,8)               
          DRAW Window (9,8)                    
      ELSEIF stories = 2 then                   
       DRAW Window (-9,8)               
       DRAW Window (9,8)               
      ELSEIF stories = 3 then                   
       DRAW Window (-9,16)               
       DRAW Window (9,16)               
      END IF              
   CASE 3                        !now, if the user has chosen a 1 story house, he can have a maximum of 2 rooms.
       IF stories = 1 then              !so, if the user has a 1 story home, he will be asked to enter the number of rooms again.          
       PRINT "Too many rooms for a one story house.  Choose 1 or 2 rooms please or else I will choose for you!"              
       INPUT prompt "How many rooms?" : rooms1      !The user is only given one more chance before the program automatically draws 2 windows.         
          IF rooms1 = 1 then         
                 DRAW Window (0,10)          
          ELSE         
                 DRAW Window (-9,8)          
                 DRAW Window (9,8)          
          END IF          
      ELSEIF stories = 2 then              !for a 2 or 3 story house, the 3 room/window operates just as it did in the case of 1 or 2 rooms.          
       DRAW Window (-9,8)               
       DRAW Window (9,8)               
       DRAW Window (0, 16)               
      ELSEIF stories = 3 then                   
       DRAW Window (-9, 8)          
       DRAW Window (9,8)          
       DRAW Window (0,16)          
      END IF              
   CASE 4              
      IF stories = 1 then          !this process is exactly like the one above in case 3    
       PRINT "Too many rooms for a one story house.  Choose 1 or 2 rooms please or else I will choose for you!"         
          INPUT prompt "How many rooms?" : rooms2               
            IF rooms2 = 1 then    
                DRAW Window (0,10)
          ELSE    
                DRAW Window (-9,8)
                DRAW Window (9,8)
          END IF    
      ELSEIF stories = 2 then          !also, this process is exactly like those in case 1,2 and 3.     
       DRAW Window (-9,8)          
       DRAW Window (9,8)     
       DRAW Window (9,16)     
       DRAW Window (-9,16)     
      ELSEIF stories = 3 then         
          DRAW Window (-9,8)          
       DRAW Window (9,8)     
       DRAW Window (9,16)     
       DRAW Window (-9,16)     
      END IF         
   CASE 5         
      IF stories = 3 then          !in case 5, the 3 story house operates as in all other cases.  it draws the number of rooms entered
       DRAW Window (-9,8)     
       DRAW Window (9,8)     
       DRAW Window (-9,16)     
       DRAW Window (9,16)     
       DRAW Window (0, 20)     
      ELSEIF stories = 2 then                        
       PRINT "Too many rooms!"                   
       INPUT prompt "You can have up to four rooms in a two story house.  If you choose more than that, you will not get any windows!  How many rooms?" : rooms3                    
          IF rooms3 = 1 then              
                DRAW Window (0,10)          
          ELSEIF rooms3 = 2 then              
                DRAW Window (-9,8)          
                DRAW Window (9,8)            !here, the user if given one more chance to enter the correct number of rooms for a 2 story house
          ELSEIF rooms3 = 3 then               !before the program does not allow the user user to have any "rooms" or windowss
                DRAW Window (-9,8)          
                DRAW Window (9,8)          
                DRAW Window (0,16)          
          ELSEIF rooms3 = 4 then              
                DRAW Window (-9,8)          
                 DRAW Window (9,8)          
                 DRAW Window (9,16)          
                 DRAW Window (-9,16)     
          ELSE         

          END IF         
      ELSEIF stories = 1 then                   
       PRINT "Too many rooms!"              
       INPUT prompt "You can have up to two rooms.  If you choose more than that, you will not get any windows!  How many rooms?" : rooms4               
          IF rooms4 = 1 then         
                DRAW Window (0,8)     
          ELSEIF rooms4 = 2 then                 !this process is almost the same as in the process for the 2 story home in this case (5).
                DRAW Window (-9,8)     
                DRAW Window (9,8)     
          ELSE         
          END IF         
     END IF              
   CASE ELSE                   
       PRINT "Too many rooms!  No more than 5 rooms please."     !this is printed if the user enters a number higher than 5.                        
       INPUT prompt "How many rooms?": rooms                               
   END SELECT                             
PRINT                             
PAUSE 2                             
 INPUT prompt "Would you like a door?": reply$           !this stores the string variable reply$                   
     SELECT CASE reply$                     !this looks at the string variable reply$ and decides what to do with it    
      CASE "YES", "Yes", "yes", "Y", "y"          !if it fits this case, a door will be drawn.  this door is in a picture statement later in the program.               
         DRAW Door1 (0,4.5)                         
     CASE else                         !otherwise, no door is drawn and the user is instead shown the print statement below.
         PRINT "Alright, interesting choice, but I'll go with it."                        
     END SELECT                        

 PICTURE Door1 (X,Y)                          !this is where the door is drawn    
   LET Xmin = X-2                             
   LET Xmax= X+2                         !I have given the door a location and told it how long to make its lines on both the X and Y axis     
   LET Ymin = Y - 3.5                        
   LET Ymax = Y + 3.5                        
    BOX LINES Xmin, Xmax, Ymin, Ymax                         
    DRAW Circle (0.1,X-1.2,Y-0.4)                !this is the doorknob of the door.  the program knows how to draw circle from the picture circle below.         
END PICTURE                        

 PICTURE Circle (R,X,Y)                          !this is how the program knows how to draw a circle
    BOX CIRCLE X-R, X+R, Y-R, Y+R                         
END PICTURE                        
                           
                            
 PICTURE Window (X,Y)                         
    !Draw a 3 by 3 window centered at X,Y                         
   LET Xmin = X - 1.5                        
   LET Xmax = X + 1.5                         !this is the outline of the window
   LET Ymin = Y - 1.5                        
   LET Ymax = Y + 1.5                   
    BOX LINES Xmin, Xmax, Ymin, Ymax                    
   !Draw window panes                   
    PLOT LINES: X, Y-1.5; X, Y + 1.5                    
    PLOT LINES: X - 1.5,Y ; X + 1.5, Y                   !this is the window panes    
END PICTURE                   
PRINT                   
PAUSE 1                   
 INPUT prompt " Would you like to plant grass around your house?" : reply$      !this variable is also stored for the following               
   SELECT CASE reply$                    
      CASE "Yes", "YES", "Y", "y", "yes"          !this process is exactly like the case statement used previously    
        PRINT              
        PAUSE 1              
         PRINT "Good choice!"                
         BOX LINES -15,-25,0,2                 !here, i am creating 2 new boxes for the grass
         BOX LINES 15,25,0,2               
         SET COLOR "green"                    !here, i am setting the color to green     
         FLOOD -20,1                           !now, i am filling in both boxes that I just created.  since I just set the color to green, these boxes will be filled in in green.
         FLOOD 20,1                                         

     CASE else                         !otherwise, I will create the same boxes but fill them with black
        PRINT                         ! telling the user that they instead can have cement.
        PAUSE 1                        
            PRINT "Fine, you can have cement around your house instead!"                             
         BOX LINES -15,-25,0,2                         
         BOX LINES 15,25,0,2                         
         SET COLOR "black"                        
         FLOOD -20,1                         
         FLOOD 20,1                         
     END SELECT                        

 SET COLOR "black"                             
PRINT                             
PAUSE 2                             
 LINE INPUT prompt "Finally, write something to be displayed wheverever you choose..." : Text$      !this is storing whatever text the user enters to be displayed later                        
PRINT                             
 PRINT "Text will appear wherever you click!"          !now I am telling the user what to do                   
 SET COLOR "cyan"                         !setting the color to cyan    
    DRAW Text (X,Y,Text$)                      ! the program knows how to draw text from a picture statement below.  it uses the users unput to know what to draw and the users "click" to know where to locate the text          
 SOUND 700,2                                !the program makes a sound at this point, because it is cool and why not.
END                             

 

 PICTURE Set (X,Y)                 !here, I am telling the program how to DRAW Set, which it needs to DRAW Text               
   ASK COLOR ColorNum                             
    PLOT POINTS: X,Y                              
   SET COLOR background                             
    PLOT POINTS: X,Y                              
   SET COLOR ColorNum         
END PICTURE         

 PICTURE Text (X,Y,Text$)            !here, I am telling the program how to DRAW Text so that it can display Text$
    DRAW Set (X,Y)          
    GET POINT: X1,Y1          
    PLOT TEXT, AT X1, Y1: Text$          
   LET X = X1-1         
   LET Y = Y1-1         
END PICTURE