Wednesday, March 5, 2014

Flappy Ball

# Minimalist version of flappy bird, Work in progress
# Click to jump
graphsize 600,400
Dim obstaclehight(10)

for level = 1 to 5
  # Generate obstacles
   for n = 0 to 9
     obstaclehight[n] = 150+ int(rand*(10+40*level))-20*level
   next n
   # restart point after losing a life
   # End game code
   if lifes = 0 then
       color black
       font "arial",50,50
       text 50,50,"End"
   end if
   pause 1
   # Running code
   for x = 1 to 2200 step 1
       color yellow
       rect 0,0,600,400
       color black
       font "arial",50,50
       text 50-x,50,"Level:"+(level)
       if level < 5 then text 2200-x,50,"Level:"+(level+1)
       if level = 5 then text 2200-x,50,"End"
       # Drawing columns
       for n = 0 to 9
          color darkgreen
          rect 300+n*200-x,0,50,400
          color yellow
          rect 300+n*200-x,obstaclehight[n],50,100
         # Ball death
           if 300+n*200-x=50 or 300+n*200-x=0 then
               if birdy < obstaclehight[n] or birdy > obstaclehight[n]+100 then
                   goto start
                end if
            end if
         next n
   # Ball draw
   color red
   circle 50,birdy,10
   color white
   circle 52,birdy-2,3
   color black
   circle 53,birdy-2,2
   rect 56,birdy+2,5,3
   color black
   font "arial",20,100
   text 10,10,"Lifes"+lifes
   # Movement
   if clickx>0 then dy=-1
  next x
next level