View Full Version : problem with a parachute game.
adit2789
02-23-2008, 04:22 PM
Hi, I actually need help. Those of you who know how the parachute game works, the launcher rotates and shoots in the angle it is in. Mine relies on the mouse rather than the keys to rotate the launcher. I was wondering how i would go about getting the bullet to follow the angle of the launcher, and launch in that direction
this is my whole game and its as files.
http://www.megaupload.com/?d=65EK2WVD
If anyone could help it would be greatly appreciated
scarce
02-23-2008, 05:01 PM
Hi, I actually need help. Those of you who know how the parachute game works, the launcher rotates and shoots in the angle it is in. Mine relies on the mouse rather than the keys to rotate the launcher. I was wondering how i would go about getting the bullet to follow the angle of the launcher, and launch in that direction
this is my whole game and its as files.
http://www.megaupload.com/?d=65EK2WVD
If anyone could help it would be greatly appreciated
this.onMouseMove = function() {
myRadians = Math.atan2(_root._ymouse-shooter._y, _root._xmouse-shooter._x);
myDegrees = Math.round((myRadians*180/Math.PI));
if (myDegrees<-10 && myDegrees>-165) {
shooter._rotation = myDegrees;
}
};
this.onMouseDown = function() {
if (myDegrees<-10 && myDegrees>-180) {
radian = Math.PI/180;
slopex = Math.cos(myDegrees*radian)*30;
slopey = Math.sin(myDegrees*radian)*30;
}
};
this.onEnterFrame = function() {
yourMCName._x += slopex;
yourMCName._y += slopey;
};
I'm working on an angle shooter game as well, this is what I did primarily, I had more to it but it was to suit my game, this is the bare bones of it.
What it's doing is assosiating the rotating shooter with the mouse, then setting the degree of rotation based on the x and y of the mouse. Then it's restricting it to only be able to move 90 degrees left and right.
Scarce your code is not bad but I can see already what's gonna happen when you click a second time while your bullet is moving.
adit2789
02-23-2008, 07:36 PM
how would you fix it?
scarce
02-23-2008, 11:00 PM
how would you fix it?
go = 0;
this.onMouseMove = function() {
myRadians = Math.atan2(_root._ymouse-shooter._y, _root._xmouse- shooter._x);
myDegrees = Math.round((myRadians*180/Math.PI));
if (myDegrees<-10 && myDegrees>-165) {
shooter._rotation = myDegrees;
}
};
this.onMouseDown = function() {
if (myDegrees<-10 && myDegrees>-180) {
go = 0
radian = Math.PI/180;
slopex = Math.cos(myDegrees*radian)*30;
slopey = Math.sin(myDegrees*radian)*30;
}
};
this.onEnterFrame = function() {
if(yourShotMC.hitTest(yourShotAtMC)){
go = 1
}
if(go==0){
yourMCName._x += slopex;
yourMCName._y += slopey;
}
};
adit2789
02-24-2008, 12:07 AM
is "go" a boolean variable? also where does go=0 at the very top fall under? The class?
scarce
02-24-2008, 01:12 AM
is "go" a boolean variable? also where does go=0 at the very top fall under? The class?
are you using as2 or as3...
if as3, then go would be an int
var go:int=0
and it would go however you have your thing set up, where the rest of that code goes, it goes above all that to establish the variable...
adit2789
02-24-2008, 05:12 PM
i was wondering how would u code it so that if 30 seconds pass, more enemies are created. If someone could look through the code i have and tell me, that would be great
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.