DECLARE SUB background2 (x4%, y4%, c4%)
DECLARE SUB background (x4%, y4%, c4%)
DECLARE SUB time ()
DECLARE SUB menu (x%, y%, c%)
DECLARE SUB movement (sx%, sy%, c%, screenchange$)
DECLARE SUB treeobsticle (x2%, y2%, c2%)
DECLARE SUB background (x%, y%, c%)
DECLARE SUB rockobsticle (x3%, y3%, c2%)
DECLARE SUB skier (x%, y%)
CLS
SCREEN 12
RANDOMIZE TIMER

  CALL menu(x%, y%, c%)

CLS

 sceenchange$ = "N"
 c% = INT(RND * 15) + 1
 c2% = INT(RND * 15) + 1
 c3% = INT(RND * 15) + 1
 c4% = INT(RND * 15) + 1

 sx% = 350
 sy% = 50

 x2% = 200
 y2% = 200
 
 x3% = 400
 y3% = 300

 x4% = 0
 y4% = 400

 DIM tree(17, 2)
 DIM rock(17, 2)
 t! = INT(TIMER)
 counter% = 0

 DO
                 counter% = counter% + 1
                 CALL background(x%, y%, c%)

 r% = INT(RND * 17) + 1                           ' randomizing tree obsticles
 FOR k% = 1 TO r%
         x2% = INT(RND * 640) + 1
         y2% = INT(RND * 330) + 150
         CALL treeobsticle(x2%, y2%, c2%)
         tree(k%, 1) = x2%
         tree(k%, 2) = y2%
 NEXT k%

         
 r2% = INT(RND * 17) + 1                           ' randomizing rock obsticles
 
 FOR j% = 1 TO r2%
         x3% = INT(RND * 640) + 1
         y3% = INT(RND * 330) + 150
         CALL rockobsticle(x3%, y3%, c2%)
         rock(j%, 1) = x3%
         rock(j%, 2) = y3%
 NEXT j%
 
 
DO

    
           ans3% = TIMER - t!
           LOCATE 1, 3
           PRINT ans3%
        
       
         CALL skier(sx%, sy%)
         CALL movement(sx%, sy%, c%, screenchange$)
        
FOR k% = 1 TO r%
       
      x2% = tree(k%, 1)
      y2% = tree(k%, 2)
       
        IF ABS(x2% - (sx% - 15)) < 20 AND ABS(y2% - (sy% + 10)) < 35 THEN
         CLS
         PRINT "YOU HIT A TREE YOU CAPPY! WATCH OUT NEXT TIME!"
         END
      
       ELSEIF ABS(x2% - (sx% - 10)) < 20 AND ABS(y2% - (sy% + 10)) < 35 THEN
         CLS
         PRINT "YOU HIT A TREE YOU CAPPY! WATCH OUT NEXT TIME!"
         END
         END IF

NEXT k%

 FOR j% = 1 TO r2%
       
         x3% = rock(j%, 1)
         y3% = rock(j%, 2)
         IF ABS(x3% - (sx% - 30)) < 20 AND ABS(y3% - (sy% + 30)) < 35 THEN
          CLS
          PRINT "YOU HIT A ROCK YOU CAPPY! WATCH OUT NEXT TIME!"
          END
       
        ELSEIF ABS(x3% - (sx% - 10)) < 20 AND ABS(y3% - (sy% + 30)) < 35 THEN
          CLS
          PRINT "YOU HIT A ROCK YOU CAPPY! WATCH OUT NEXT TIME!"
          END
       
        END IF

 NEXT j%

                                                          
 LOOP UNTIL screenchange$ = "Y" OR ans3% = 35                        ' TIMER
  
 CLS
 screenchange$ = "N"


IF counter% = 4 THEN
            CALL background2(x4%, y4%, c4%)

END IF


LOOP UNTIL ans3% = 35 OR counter% = 5                                             'loop until you run out of time                      
CLS
IF ans3% < 40 THEN
        PRINT "you made it in ", ans3%
ELSE
        PRINT "YOUR TIME HAS RUN OUT CAPPY!"

END IF

SUB background (x%, y%, c%)
PAINT (1, 1), 7, 15
END SUB

       SUB background2 (x4%, y4%, c4%)
PAINT (0, 0), 7
LINE (x4%, y4%)-STEP(640, 0), 0
LINE STEP(0, 40)-STEP(-640, 0), 0
LINE (300, 440)-STEP(0, -30), 0        'F
LINE STEP(0, 0)-STEP(15, 0), 0
LINE STEP(-15, 10)-STEP(10, 0), 0
LINE STEP(10, 20)-STEP(0, -30), 0      'I
LINE STEP(5, 30)-STEP(0, -30), 0       'N
LINE STEP(0, 0)-STEP(10, 30), 0
LINE STEP(0, 0)-STEP(0, -30), 0
LINE STEP(5, 30)-STEP(0, -30), 0        'I
LINE STEP(15, 0)-STEP(-10, 0), 0        'S
LINE STEP(0, 0)-STEP(10, 30), 0
LINE STEP(0, 0)-STEP(-10, -5), 0
LINE STEP(15, 5)-STEP(0, -30), 0       'H
LINE STEP(0, 15)-STEP(10, 0), 0
LINE STEP(0, -15)-STEP(0, 30), 0

END SUB

        SUB menu (x%, y%, c%)
INPUT " Do you wish to play skier? y/n", ans$
IF ans$ = "y" THEN

ELSE
        END
END IF

INPUT "do you wish to know how to play SKIER? y/n.", ans2$

IF ans2$ = "y" THEN
        PRINT " Use the number pad to move the skier away from the obsticles , If you hit an obsticle you die."
        PRINT " Do this before the timer hits 35."
        

ELSE

END IF


END SUB

         SUB movement (sx%, sy%, c%, screenchange$)
   DO
      
       key$ = INKEY$

       CIRCLE (sx% - 20, sy%), 10, c%   'head
       LINE STEP(0, 10)-STEP(0, 30), c%
       LINE STEP(0, -15)-STEP(-15, 0), c%    'left arm
       LINE STEP(0, 0)-STEP(-10, -10), c%
       LINE STEP(25, 10)-STEP(15, 0), c%    'right arm
       LINE STEP(0, 0)-STEP(10, -10), c%
       LINE STEP(-25, 25)-STEP(-20, 20), c%    'left leg and ski
       LINE STEP(0, -10)-STEP(0, 20), 0
       LINE STEP(20, -30)-STEP(20, 20), c%     'right leg and ski
       LINE STEP(0, -10)-STEP(0, 20), 0
       start! = TIMER
       DO
       LOOP UNTIL (TIMER - start!) > .05
       CIRCLE (sx% - 20, sy%), 10, 7   'head
       LINE STEP(0, 10)-STEP(0, 30), 7
       LINE STEP(0, -15)-STEP(-15, 0), 7    'left arm
       LINE STEP(0, 0)-STEP(-10, -10), 7
       LINE STEP(25, 10)-STEP(15, 0), 7    'right arm
       LINE STEP(0, 0)-STEP(10, -10), 7
       LINE STEP(-25, 25)-STEP(-20, 20), 7    'left leg and ski
       LINE STEP(0, -10)-STEP(0, 20), 7
       LINE STEP(20, -30)-STEP(20, 20), 7     'right leg and ski
       LINE STEP(0, -10)-STEP(0, 20), 7
       
       IF key$ = "6" THEN
        sx% = sx% + 10

       ELSEIF key$ = "2" THEN
        sy% = sy% + 10

       ELSEIF key$ = "4" THEN
        sx% = sx% - 10

       ELSEIF key$ = "8" THEN
        sy% = sy% - 10

       ELSEIF key$ = "7" THEN
        sx% = sx% - 10
        sy% = sy% - 10

       ELSEIF key$ = "9" THEN
        sx% = sx% + 10
        sy% = sy% - 10

       ELSEIF key$ = "1" THEN
        sx% = sx% - 10
        sy% = sy% + 10

       ELSEIF key$ = "3" THEN
        sx% = sx% + 10
        sy% = sy% + 10
      
     
END IF
 IF sy% >= 480 THEN
  sy% = 11
  screenchange$ = "Y"
  END IF


LOOP UNTIL key$ <> ""
END SUB

     SUB rockobsticle (x3%, y3%, c2%)
CIRCLE (x3%, y3%), 10, 0
PAINT (x3%, y3%), 0, 0

END SUB

SUB skier (sx%, sy%)
CIRCLE (sx% - 20, sy%), 10, 0    'head
LINE STEP(0, 10)-STEP(0, 30), 0
LINE STEP(0, -15)-STEP(-15, 0), 0     'left arm
LINE STEP(0, 0)-STEP(-10, -10), 0
LINE STEP(25, 10)-STEP(15, 0), 0     'right arm
LINE STEP(0, 0)-STEP(10, -10), 0
LINE STEP(-25, 25)-STEP(-20, 20), 0     'left leg and ski
LINE STEP(0, -10)-STEP(0, 20), 0
LINE STEP(20, -30)-STEP(20, 20), 0      'right leg and ski
LINE STEP(0, -10)-STEP(0, 20), 0


END SUB

SUB treeobsticle (x2%, y2%, c2%)
LINE (x2%, y2%)-STEP(10, 10), 2
LINE STEP(0, 0)-STEP(-10, 10), 2
LINE STEP(0, 0)-STEP(20, 20), 2
LINE STEP(0, 0)-STEP(-20, 20), 2
LINE STEP(0, 0)-STEP(0, 20), 2
LINE STEP(0, 0)-STEP(-10, 0), 2
LINE STEP(0, 0)-STEP(0, -20), 2
LINE STEP(0, 0)-STEP(-20, -20), 2
LINE STEP(0, 0)-STEP(20, -20), 2
LINE STEP(0, 0)-STEP(-10, -10), 2
LINE STEP(0, 0)-STEP(10, -10), 2
LINE STEP(0, 0)-STEP(11, 0), 2
PAINT STEP(-5, 5), 2, 2

END SUB

