Advertisement
Yung_Hotwheel

Untitled

Mar 8th, 2014
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Mouse.hide();
  2. //input stuff
  3. stage.addEventListener(KeyboardEvent.KEY_DOWN, tap1);
  4.  
  5. function tap1(event):void{
  6.     startGame();
  7. }
  8. function startGame():void{ 
  9.     var jumpLevel:int=-30
  10.     var jumpLevelCap:int=36
  11.    
  12.     stage.removeEventListener(KeyboardEvent.KEY_DOWN, tap1);
  13.  
  14.     stage.addEventListener(Event.ENTER_FRAME, update);
  15.     stage.addEventListener(KeyboardEvent.KEY_DOWN, tap2);
  16.    
  17.     function update(event):void{
  18.         bird.y+=jumpLevel;
  19.         //gravity
  20.         if (jumpLevel<jumpLevelCap){
  21.             jumpLevel+=6;
  22.         }
  23.         //rotation
  24.         if (bird.rotation<100 && bird.rotation>-90 && jumpLevel>0){
  25.             bird.rotation+=jumpLevel;
  26.         }
  27.         if (bird.rotation<100 && bird.rotation>-100 && jumpLevel<0){
  28.             bird.rotation+=jumpLevel*2;
  29.         }
  30.         if (bird.rotation>=100){
  31.             bird.rotation=99;
  32.         }
  33.         if (bird.rotation<-90){
  34.             bird.rotation=-89;
  35.         }
  36.         //out of bounds
  37.         if (bird.y<1){
  38.             killBird();
  39.         }
  40.     }
  41.    
  42.     function tap2(event):void{
  43.         jumpLevel=-30;
  44.     }
  45.    
  46.     function killBird():void{
  47.        
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement