;fix lives
;apple and superapple
;hal9000 apple

program{
  states{
    begin{
      initialize{
        setstate title
      }initialize
    }begin
    title{
      initialize{
        setbackground game "title.jpg"
        ;setmusic game "title.wav"
        set counter$level 1
        set counter$lives 3
        set counter$score 0
      }initialize
      loop{
        if keyboard.Q = "true" {
          setstate end
        }else{
          if keyboard.anykey = "true" {
            setstate play
          }if
        }if
      }loop
    }title
    play{
      initialize{
        destroyall
        set counter$points 0
        create bob 0 "bob.spr" 90 1 -90 0 -20
        create joe 1 "joe.spr" 270 1 80 0 20
        create JOE 2 "joe.spr" 270 1 90 0 20
        create apple 3 "apple.spr" 180 0 0 0 0 
        set counter$invincible 100
      }initialize
      loop{

      }loop
    }play
    win{
      initialize{
        destroyall
        setbackground game "youwin.bmp"
        SETMUSIC game "youwin.wav"
      }initialize
      loop{
        if keyboard.anykey = "true"{
          setstate title
        }if
      }loop
    }win
    gameover{
      initialize{
        destroyall
        setbackground game "youlose.bmp"
        setmusic game "youlose.wav"
      }initialize
      loop{
        setstate end
      }loop
    }gameover
  }states
  classes{
    bob{
      create{
      }create
      mapchange{
        if me.white = "true"{
          unmove me
        }if
      }mapchange
      Normal{
        IF counter$invincible > 0{
          change counter$invincible -1
        }IF
        if keyboard.right = "true"{
          moveright me 2
        }if
        if keyboard.left = "true"{
          moveleft me 2
        }if
        if keyboard.up = "true"{
          moveup me 2
        }if
        if keyboard.down = "true"{
          movedown me 2
        }if
      }normal
      collision{
        if it.class = joe{
          Destroy me
        }if
        if it.class = apple{
          change counter$points +1000
        }if
        if it.class = superapple
         change counter$points +1000
          set counter$invincible 100
          destroy it
        }if
        if it.class = morelivesapple{
        change counter$lives +1
        }if
      }collision
    }bob

    apple{
    }apple
    
    superapple{
    }superapple
    
    morelivesapple{
    }morelivesapple
    
    hal9000apple{
    }hal9000apple
    joe{
      create{
      }create
      normal{
      }normal
      mapchange{
      }mapchange
      collision{
      }collision
    }joe
  }classes
}program





