The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.38 / 5.00 36,385 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.07 / 5.00 13,902 ViewsMy friend is making a game (based around Comet Busters), that is a space shooter. It is in top-down view (EV Nova, EV Override, Radien X kind of view). He is having trouble giving four different ships the ability to shoot.
What he needs:
- Code that works with any ship.
- Bullets will shoot in the direction the ship is pointing, and move independently, not turning as the ship turns unrealistically.
- Bullets are not simple instant A to B shots (Madness Interactive), they spend a good time in the air (space).
Asking for the exact code would be unrealistic, because I don't know the instance names, or the buttons that work for each ship.
Anyone have any help?
Asus P5Q PRO, Intel E8400 @ 3.60 GHz, 4GB DDR2-1000, ATI HD4850
That looks like a good tut, but thi shooting doesnt have to do with the mouse. It is like, rotate your ship with arrow keys, and shoot with space, in the direction the ship is pointing.
At 1/10/07 09:45 PM, PimpinJ wrote: That looks like a good tut, but thi shooting doesnt have to do with the mouse. It is like, rotate your ship with arrow keys, and shoot with space, in the direction the ship is pointing.
So just replace the mouse actions with keyboard actions.
At 1/10/07 09:58 PM, Alacrity wrote: So just replace the mouse actions with keyboard actions.
on frame:
var bc=1000; //bulletcount
_root.onEnterFrame=function(){
if (Key.isDown (Key.SPACE)) {
bc++;
if(bc>1100){ bc=1000; } //Reset bulletcount
duplicateMovieClip("bullet", "b"+bc, bc); //Create dupe bullet
}
}
on bullet clip, instance named bullet:
onClipEvent(load){
spd=20; //bullet speed
_x=_root.ship._x; //Move to ship_x
_y=_root.ship._y; //Move to ship_y
_rotation= _root.ship._rotation; //Point in same direction as ship
}
onClipEvent(enterFrame){
if(_name == "bullet"){
_x = -1000; //Move the original bullet MC offstage
}else{
//Run this movement code on all dupes
if (_rotation>180) {
_y += (spd*Math.cos( Math.PI/180*_rotation));
_x -= (spd*Math.sin( Math.PI/180*_rotation));
} else {
_y -= (spd*Math.cos (Math.PI/180*_rotation));
_x += (spd*Math.sin( Math.PI/180*_rotation));
}
//if(hitTest(_root.enemy)){ blahh; } Not going to address this here, check AS: Main for hitTest threads.
}
if(_x>Stage.width || _x<0 || _y<0 || _y>Stage.height){
//If off-stage, delete the dupe to save CPU
this.removeMovieClip();
}
}
postcount +=1;
Newgrounds Photoshop Headquarters || Don't use MS Paint! Use Aviary!
SING US A SING YOU'RE THE PIANO MAN
I would like to note that for this code:
if (_rotation>180) {
_y += (spd*Math.cos( Math.PI/180*_rotation));
_x -= (spd*Math.sin( Math.PI/180*_rotation));
} else {
_y -= (spd*Math.cos (Math.PI/180*_rotation));
_x += (spd*Math.sin( Math.PI/180*_rotation));
}
you only need this:
_y -= (spd*Math.cos (Math.PI/180*_rotation));
_x += (spd*Math.sin( Math.PI/180*_rotation));
I never knew why the code checks for (_rotation>180) because, in flash the values you can get for _rotation is between 0 to 180 or 0 to -180...
I never knew why the code checks for (_rotation>180) because, in flash the values you can get for _rotation is between 0 to 180 or 0 to -180...
because people dont seem to notice it cause its common for it to goto 360degrees.
only people that use trace functions would notice