Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import flash.display.MovieClip;
- import flash.display.Sprite;
- import flash.events.KeyboardEvent;
- import flash.events.Event;
- import flash.ui.Keyboard;
- import flash.text.TextField;
- public class obli7main extends MovieClip{
- private var ute:Sprite;
- private var inne:Sprite;
- private var sun:Sprite = new Sprite();
- private var hus:Hus;
- private var forgrundUte:LForgrundUte;
- private var bakgrundUte:LBakgrundUte;
- private var fjell:LFjell
- private var doer:LDoer;
- private var haantak:LHaantak;
- private var himmel:LHimmel;
- private var wc3:LWc3; //karakter
- private var blomst1:LBlomst1;
- private var blomst2:LBlomst2;
- private var blomst3:LBlomst3;
- private var rom:LRom;
- var Score:int;
- var scoretext: TextField = new TextField();
- const L:int = 0; // Left
- const W:int = 550; // Width
- const T:int = 0; // Top
- const H:int = 400; // Height
- const R:int = L+W; // Right
- const B:int = T+H;
- var S:Number = 0.3; // skalering av karakter
- public function obli7main()
- {
- inne = new Sprite();
- addChild(inne);
- inne.x = 0;
- inne.y = 0;
- inne.visible = false;
- ute = new Sprite();
- addChild(ute);
- ute.x = 0;
- ute.y = 0;
- leggTilObjektInne();
- leggTilObjektUte();
- wc3 = new LWc3(); //karakter
- wc3.x = 275;
- wc3.y = 260;
- wc3.gotoAndStop(1);
- addChild(wc3);
- wc3.scaleX = wc3.scaleY = S;
- leggTilLyttereUte();
- leggTilLyttereInne();
- scoretext.width = 200;
- scoretext.text = "Score: 0";
- addChild (scoretext) ;
- scoretext.x = 50;
- scoretext.y = 40;
- scoretext.textColor = 0xffffff;
- }
- public function onFrameLoop(e:Event) : void
- {
- wc3.stop();
- plukkBlomster();
- if (ute.visible && blomst1.visible == false && blomst2.visible == false && blomst3.visible == false)
- lyttPaaDoer();
- //trace(wc3.x);
- }
- private function plukkBlomster()
- {
- if (blomst1.visible == true && ute.visible && wc3.hitTestObject( blomst1 ))
- {
- blomst1.visible = false ;
- addScore();
- }
- if (blomst2.visible == true && ute.visible && wc3.hitTestObject( blomst2 ))
- {
- blomst2.visible = false ;
- addScore();
- }
- if (blomst3.visible == true && ute.visible && wc3.hitTestObject( blomst3 ))
- {
- blomst3.visible = false ;
- addScore();
- }
- }
- private function addScore()
- {
- trace ("hit");
- Score = Score +1
- trace ("Score: " + Score);
- scoretext.text = "Score: 0" + Score;
- }
- private function leggTilObjektUte()
- {
- himmel = new LHimmel();
- ute.addChild(himmel);
- fjell = new LFjell();
- ute.addChild(fjell);
- fjell.X = 50;
- fjell.Y = 330;
- bakgrundUte = new LBakgrundUte();
- ute.addChild(bakgrundUte);
- bakgrundUte.X = bakgrundUte.width/2;
- bakgrundUte.Y = bakgrundUte.height/2
- forgrundUte = new LForgrundUte();
- ute.addChild(forgrundUte);
- forgrundUte.x = forgrundUte.width/2;
- forgrundUte.y = B - forgrundUte.height/2;
- sun.graphics.beginFill(0x0FFFF99);
- sun.graphics.drawCircle(210, 90, 50);
- sun.graphics.endFill();
- ute.addChild(sun);
- hus = new Hus();
- ute.addChild(hus);
- hus.x = 155;
- hus.y = 310;
- hus.scaleX = hus.scaleY = 1.5;
- blomst1= new LBlomst1();
- ute.addChild(blomst1);
- blomst1.x = 390;
- blomst1.y = 310;
- blomst1.scaleX = blomst1.scaleY = 1
- blomst2= new LBlomst2();
- ute.addChild(blomst2);
- blomst2.x = 30;
- blomst2.y = 330;
- blomst2.scaleX = blomst2.scaleY = 1
- blomst3= new LBlomst3();
- ute.addChild(blomst3);
- blomst3.x = 450;
- blomst3.y = 330;
- blomst3.scaleX = blomst3.scaleY = 1
- //doer=new Ldoer();
- // ute.addChild(doer);
- // doer.x=128;
- // doer.y=260;
- // doer.scaleX = doer.scaleY = 1.5;
- //
- // haantak= new LHaantak();
- // ute.addChild(haantak);
- // haantak.x=100;
- // haantak.y= 267;
- // haantak.scaleX = haantak.scaleY = 1.5;
- }
- public function onKeyPressed(e:KeyboardEvent) : void
- {
- if (e.keyCode == Keyboard.LEFT)
- {
- wc3.scaleX = -S;
- if(wc3.x > 0)
- {0
- wc3.x = wc3.x - 5;
- wc3.play();
- }
- }
- else if (e.keyCode == Keyboard.RIGHT)
- {
- wc3.scaleX = S;
- wc3.x = wc3.x + 5;
- wc3.play();
- }
- }
- private function leggTilLyttereUte()
- {
- stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressed);
- //stage.addEventListener(KeyboardEvent.KEY_UP, onkeyReleased);
- stage.addEventListener(Event.ENTER_FRAME, onFrameLoop);
- }
- private function leggTilLyttereInne()
- {
- //stage.addEventListener(Event.ENTER_FRAME, onFrameLoop);
- }
- private function lyttPaaDoer()
- {
- if (wc3.hitTestObject(hus.doer.haantak) && blomst1.visible == false && blomst2.visible == false && blomst3.visible == false )
- {
- if (hus.doer.haantak.rotationZ >-60)
- hus.doer.haantak.rotationZ--;
- else if (hus.doer.haantak.rotationZ==-60 && hus.doer.rotationY<55)
- hus.doer.rotationY ++;
- else
- {
- inne.visible = true;
- S = 0.5 ;
- wc3.scaleX = wc3.scaleY = S;
- ute.visible = false;
- }
- }
- // public function onKeyboardMove(me:KeyboardEvent): void
- //{
- //
- //
- //
- // //else
- //
- // }
- }
- private function leggTilObjektInne()
- {
- rom = new LRom();
- //rom.width = 600;
- // rom.height = 400;
- inne.addChild(rom);
- rom.scaleX = 0.8 ;
- rom.scaleY = 0.94;
- }
- }
- }
Add Comment
Please, Sign In to add comment