+ Reply to Thread
Page 7 of 7
FirstFirst ... 5 6 7
Results 61 to 69 of 69

Thread: [Flash] Pirate's Space Game Tutorial, Part 1

  1. #61
    Bumbaclot Gavel's Avatar
    Join Date
    Oct 2006
    Location
    sausage&tang........ Hoes: 1,765,786.5
    Posts
    15,928
    Quote Originally Posted by pagdog9 View Post
    i cant make me die
    You obviously didn't read the tutorial properly. Maybe if you actually try to learn from it and understand the actionscript so you can figure out what you did wrong.

  2. #62
    Senior Member
    Join Date
    Apr 2006
    Location
    Australia
    Posts
    4,376
    OMG copy pasta. Yours working now spazzy?

  3. #63
    Religious mice pokit5's Avatar
    Join Date
    Aug 2007
    Location
    Edinburg, Scotland! I shall smite you where you stand!
    Posts
    206
    my spawner only spawns in one spot. all the enemies just come like a waterfall at once. code-

    onClipEvent (load) {
    nextenemy = 0;
    enemynum = 30;
    enemymin = 30;
    enemymax = 50;
    }
    onClipEvent (enterFrame) {
    if (nextenemy == 0) {
    nextenemy = 15+random(40);
    enemynum++;
    _root.enemy.duplicateMovieClip("enemy"+enemynum, enemynum);
    _root["enemy"+enemynum]._x = random(_root.stagex);
    _root["enemy"+enemynum]._y = -40;
    }
    if (nextenemy>0) {
    nextenemy--;
    }
    if (enemynum>=enemymax) {
    enemynum = enemymin;
    }
    }



    no errors on output .any problem?

    Rather Cheesy rules! Pokit likes him because he has "cheese" in his name

  4. #64
    The Scotsman Scorpioxxx's Avatar
    Join Date
    Apr 2006
    Location
    Aberdeen, Scotland
    Posts
    2,831
    In the keyframe have you got a/the 'stagex =' variable.

    ^Deviantart^

  5. #65
    killervirus
    Guest
    This tutorial is awesome. However I've got two questions:
    1.: When part 2 will be done ?
    2.: How should I add more enemy types? Like a mothership or advanced enemies.

  6. #66
    killervirus
    Guest
    Sorry for double posting but I figured out how to add another enemy type and it can be interesting for the others:

    First step:

    View the actions of the spawner in the onClipEvent(load) segment add this:

    Code:
        nextenemy2 = 0;
        enemy2num = 60;
        enemy2min = 60;
        enemy2max = 80;
    Second step: Still in the spawner add this bit of code but now in the enterFrame segment, after the original code:

    Code:
        if (nextenemy2 == 0) {
            nextenemy2 = 15+random(40);
            enemy2num++;
            _root.enemy2.duplicateMovieClip("enemy2"+enemy2num,enemy2num);
            _root["enemy2"+enemy2num]._x = random(_root.stagex);
            _root["enemy2"+enemy2num]._y = -40;
        }
        if (nextenemy2>0) {
            nextenemy2--;
        }
        if (enemy2num>=enemy2max) {
            enemy2num = enemy2min;
        }
    Third step:

    on the shot mc add this code, after the original, but still in the enterFrame segment:

    Code:
        for (a=60; a<=80; a++) {
            if (this.hitTest(_root["enemy2"+a])) {
                _root["enemy2"+a].shield -= 1;
                this.removeMovieClip();
            }
        }
    Fourth step:

    Draw another enemy type and name the instance of it enemy2 on the actions of this mc add these (I made it slower but equipped with stronger shield)

    Code:
    onClipEvent (load) {
        speed = 1+random(5);
        shield = 5;
    }
    onClipEvent (enterFrame) {
        _y += speed;
        if (shield<=0) {
            _root.expnum++;
            _root.explosion.duplicateMovieClip("explosion"+_root.expnum, _root.expnum);
            _root["explosion"+_root.expnum]._x = this._x;
            _root["explosion"+_root.expnum]._y = this._y;
            _root.kills++;
            this.removeMovieClip();
        }
        if (_root.expnum>_root.expmax) {
            _root.expnum = _root.expmin;
        }
        if (this.hitTest(_root.player)) {
            _root.expnum++;
            _root.explosion.duplicateMovieClip("explosion"+_root.expnum,_root.expnum);
            _root["explosion"+_root.expnum]._x = this._x;
            _root["explosion"+_root.expnum]._y = this._y;
            _root.gotoAndStop(2);
            _root.player.removeMovieClip();
            this.removeMovieClip();
        }
    }
    Done. I hope it works for everyone.

    Edit: There is a bug in it (at least for me) sometimes the advanced enemies just disappear, without even shooting on them. Ideas?

  7. #67
    The Master Master-Samus's Avatar
    Join Date
    Feb 2009
    Location
    Australia
    Posts
    90
    The Pirate - contact me plz.

  8. #68
    lean mean drinkn' machine Scarecrow's Avatar
    Join Date
    Oct 2005
    Location
    AUS
    Posts
    10,775
    Quote Originally Posted by Master-Samus View Post
    The Pirate - contact me plz.
    just so you know, The Pirate is inactive these days. I can send you his msn address if you like, but I don't think he uses flash frequently any more.
    Favourite Member 2009, Best Signatures 2009

  9. #69
    Eagle's Peak Arch-Angel's Avatar
    Join Date
    Jan 2007
    Location
    Working on Breaking Point. PM if you want to help.
    Posts
    8,547
    I finished this, and with no flaws I assume.
    Here's all of the code in the game.

    Main Frame on timeline
    stagex = 400;
    stagey = 600;
    expnum = 55;
    expmin = 55;
    expmax = 75;
    Kills = 0;

    Player Ship
    onClipEvent (load) {
    speed = 5;
    shotnum = 10;
    shotmin = 10;
    shotmax = 20;
    reload = 8;
    nextshot = 0;
    }
    onClipEvent (enterFrame) {
    if (this._name == "player") {
    if (_x>_root.stagex) {
    _x = _root.stagex;
    }
    if (_x<0) {
    _x = 0;
    }
    if (_y>_root.stagey) {
    _y = _root.stagey;
    }
    if (_y<0) {
    _y = 0;
    }
    if (Key.isDown(Key.SPACE)) {
    if (nextshot == 0) {
    nextshot = reload;
    shotnum++;
    _root.shot.duplicateMovieClip("shot"+shotnum, shotnum);
    _root["shot"+shotnum]._x = this._x;
    _root["shot"+shotnum]._y = this._y;
    }
    }
    if (nextshot>0) {
    nextshot--;
    }
    if (shotnum>=shotmax) {
    shotnum = shotmin;
    }
    if (Key.isDown(Key.LEFT)) {
    _x -= speed;
    }
    if (Key.isDown(Key.RIGHT)) {
    _x += speed;
    }
    if (Key.isDown(Key.UP)) {
    _y -= speed;
    }
    if (Key.isDown(Key.DOWN)) {
    _y += speed;
    }
    }
    }

    Player's Projectile
    onClipEvent (load) {
    speed = 10;
    }
    onClipEvent (enterFrame) {
    _y -= speed;
    for (a=30; a<=50; a++) {
    if (this.hitTest(_root["enemy"+a])) {
    _root["enemy"+a].shield -= 1;
    this.removeMovieClip();
    }
    }
    }

    enemy
    onClipEvent (load) {
    speed = 4+random(5);
    shield = 3;
    }
    onClipEvent (enterFrame) {
    _y += speed;
    if (this.hitTest(_root.player)) {
    _root.expnum++;
    _root.explosion.duplicateMovieClip("explosion"+_ro ot.expnum, _root.expnum);
    _root["explosion"+_root.expnum]._x = this._x;
    _root["explosion"+_root.expnum]._y = this._y;
    _root.player.removeMovieClip();
    this.removeMovieClip();
    }
    if (shield<=0) {
    _root.expnum++;
    _root.explosion.duplicateMovieClip("explosion"+_ro ot.expnum, _root.expnum);
    _root["explosion"+_root.expnum]._x = this._x;
    _root["explosion"+_root.expnum]._y = this._y;
    _root.kills++;
    this.removeMovieClip();
    }
    if (_root.expnum>_root.expmax) {
    _root.expnum = _root.expmin;
    }
    }

    sspawner
    onClipEvent (load) {
    if (this.hitTest(_root.player)) {
    _root.expnum++;
    _root.explosion.duplicateMovieClip("explosion"+_ro ot.expnum, _root.expnum);
    _root["explosion"+_root.expnum]._x = this._x;
    _root["explosion"+_root.expnum]._y = this._y;
    _root.player.removeMovieClip();
    this.removeMovieClip();
    }
    _root.playerbase.duplicateMovieClip("player", 100);
    _root.player._x = _root.stagex/2;
    _root.player._y = _root.stagey-50;
    nextenemy = 0;
    enemynum = 30;
    enemymin = 30;
    enemymax = 50;
    }
    onClipEvent (enterFrame) {
    if (nextenemy == 0) {
    nextenemy = 15+random(40);
    enemynum++;
    _root.enemy.duplicateMovieClip("enemy"+enemynum, enemynum);
    _root["enemy"+enemynum]._x = random(_root.stagex);
    _root["enemy"+enemynum]._y = -40;
    }
    if (nextenemy>0) {
    nextenemy--;
    }
    if (enemynum>=enemymax) {
    enemynum = enemymin;
    }
    }

    Make sure the instance names are correct for all objects or this won't work.
    In all respect for learning, this should be used as a reference, and not ass a short-cut.

    Jack of Blades

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts