Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Mouse.hide();
- //input stuff
- stage.addEventListener(KeyboardEvent.KEY_DOWN, tap1);
- function tap1(event):void{
- startGame();
- }
- function startGame():void{
- var jumpLevel:int=-30
- var jumpLevelCap:int=36
- stage.removeEventListener(KeyboardEvent.KEY_DOWN, tap1);
- stage.addEventListener(Event.ENTER_FRAME, update);
- stage.addEventListener(KeyboardEvent.KEY_DOWN, tap2);
- function update(event):void{
- bird.y+=jumpLevel;
- //gravity
- if (jumpLevel<jumpLevelCap){
- jumpLevel+=6;
- }
- //rotation
- if (bird.rotation<100 && bird.rotation>-90 && jumpLevel>0){
- bird.rotation+=jumpLevel;
- }
- if (bird.rotation<100 && bird.rotation>-100 && jumpLevel<0){
- bird.rotation+=jumpLevel*2;
- }
- if (bird.rotation>=100){
- bird.rotation=99;
- }
- if (bird.rotation<-90){
- bird.rotation=-89;
- }
- //out of bounds
- if (bird.y<1){
- killBird();
- }
- }
- function tap2(event):void{
- jumpLevel=-30;
- }
- function killBird():void{
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement