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

Started by: The Pirate | Replies: 65 | Views: 18,425

Gavel
2

Posts: 6,675
Joined: Oct 2006
Rep: 10

View Profile
Sep 1, 2007 8:24 PM #56060
Quote from pagdog9
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.
Steyene

Posts: 2,060
Joined: Apr 2006
Rep: 10

View Profile
Sep 1, 2007 11:11 PM #56113
OMG copy pasta. Yours working now spazzy?
pokit5
2

Posts: 18
Joined: Aug 2007
Rep: 10

View Profile
Sep 5, 2007 1:56 AM #56837
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?
Scorpioxxx
2

Posts: 1,454
Joined: Apr 2006
Rep: 10

View Profile
Sep 5, 2007 9:16 PM #56923
In the keyframe have you got a/the 'stagex =' variable.
killervirus

Posts: 0
Joined: Jul 2026
Jan 12, 2008 6:18 PM #77790
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.
killervirus

Posts: 0
Joined: Jul 2026
Jan 12, 2008 8:59 PM #77801
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:


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:


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:


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)


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?