I'm working on a shooter game based on Gradius. I'm not too far in, but I already have a couple problems:
I have a stary background that looks really nice and everything, but whenever I shoot, some of the stars disappear. here are the codes that I'm using:
background:
for (c=0; c<100; c++) {
var star:MovieClip = this.createEmptyMovieClip("star"+c, c);
star._x = random(600);
star._y = random(375);
with (star) {
_yscale = random(40)+40;
_xscale = star._yscale;
lineStyle(3, 0xFFFFFF);
lineTo(0, 1);
}
star.onEnterFrame = function() {
this._x -= this._xscale*0.015;
if (this._x<0){
this._x = 620;
this._y = random(375);
}
};
}
and gun:
if (Key.isDown(Key.SPACE)) {
if (fire === true) {
fire = false;
shotCounter++;
_root.shot.duplicateMovieClip("shot"+sho tCounter, shotCounter);
_root["shot"+shotCounter]._visible = true;
_root.shot.gotoAndStop (2)
}
}
if (fire === false) {
reload++;
}
if (reload>reloadTime) {
fire = true;
reload = 0;
}
onClipEvent (load) {
bulletSpeed = 30;
this._y = _root.VicViper._y+2;
this._x = _root.VicViper._x+28;
}
onClipEvent (enterFrame){
this._x += bulletSpeed;
if (this._x>=+620) {
this.removeMovieClip();
}
if (this.hitTest( _root.fan)){
_root.score+=100;
_root.fan.gotoAndPlay( 10 );
this.removeMovieClip();
}
}
On a side note, I'm also having trouble with hitTest on the enemies (fans).
If anyone can help me out, it would be greatly appreciated!