7 Replies Latest reply on Jul 12, 2011 1:48 AM by prodigalmaster

    How do you create a scoring system??

    smidgesarah97

      i am making a shooting game for ict and i dont know how to make a scoring system or where to put the code this is my code:

      stop();

      var numEnemy = 3;

      var fire = false;

      //attach pause

      _root.attachMovie("pause","pause",1000);

      _root.pause._x=250;

      _root.pause._y=150;

      //make pause invisible

      _root.pause._visible = false;

      //make pause variable

      var paused = false;

      //sound variables

      var sound_on=true;

      //get sounds

      var laser=new Sound();

      laser.attachSound("laser");

      var explode=new Sound();

      explode.attachSound("explode");

      var music=new Sound();

      music.attachSound("musicloop");

      music.start();

      //define a listener

      var listener = new Object();

      listener.onKeyUp = function() {

      var code = Key.getCode();

      if (code == 80) {

      if (paused == false) {

      paused = true;

      } else {

      paused = false;

      }

      }

      };

      Key.addListener(listener);

      //add shooting sound

      var shoot=new Sound();

      shoot.attachSound("shoot");

      //add explosion sound

      var explode=new Sound();

      explode.attachSound("explode");

      function moveHero(speed) {

      //check if key is down

      if (Key.isDown(Key.UP)) {

      _root.hero._y -= speed;

      } else if (Key.isDown(Key.LEFT)) {

      _root.hero._x -= speed;

      } else if (Key.isDown(Key.DOWN)) {

      _root.hero._y += speed;

      } else if (Key.isDown(Key.RIGHT)) {

      _root.hero._x += speed;

      }

      if (Key.isDown(Key.SPACE)) {

      if (fire == false) {

      fireBullets();

      }

      }

      }

      var i = 1;

      function fireBullets() {

      i++;

      if (i==10){

      i=0;

      }

      fire = true;

      _root.hero.gotoAndPlay(2);

      //start sound

      laser.start();

      //name bullets

      var newname = "bullet"+i;

      _root.attachMovie("bullet", newname, i*100);

      _root[newname]._y = _root.hero._y+13;

      _root[newname]._x = _root.hero._x+55;

      _root[newname].onEnterFrame = function() {

      if (paused == false) {

      var bullet_speed = 9;

      this._x += bullet_speed;

      if (this._x>555) {

      this.removeMovieClip();

      }

      for (var h = 1; h<=numEnemy; h++) {

      if (this.hitTest(_root["enemy"+h])) {

      this.removeMovieClip();

      _root["enemy"+h].play();

      //trace("enemy"+h);

      //play explode

      explode.start();

      }

      }

      }

      };

      }

      function Enemys() {

      for (j=2; j<=numEnemy; j++) {

      var name = "enemy"+j;

      _root.enemy1.duplicateMovieClip(name, j);

      }

      }

      Enemys();

      _root.onEnterFrame = function() {

      if (paused == false) {

      _root.pause._visible = false;

      moveHero(8);

      } else {

      _root.pause._visible = true;

      }

      if(sound_on!=true){

      stopAllSounds();

      }

      };

      music.onSoundComplete = function() {

      music.start();

      }