View Full Version : GTA TYPE (rotate and shoot in that direction)
AephorA
January 11th, 2005, 11:07 PM
Hey, Ive been working on a GTA 1 type game (topview one), and Im having trouble getting the man to shott in the direction that he's facing (the man can rotate 360 degrees)... if anyone knows a tutorial that could help or anything, that would be great !
thx
RyxiaN
January 12th, 2005, 10:44 AM
that isn't very hard right? I think I have seen that on Tonypa
signifer123
January 12th, 2005, 08:39 PM
Tonypa is a tile based tuts though arn't they ?
i've gotten pretty far on a tut on this but its not based on rottation its face north, south etc...
and have it as a root var and use a if statement to tell how it flies
the problem is shooting out of a car
i need help
March 30th, 2005, 10:16 AM
Hey, Ive been working on a GTA 1 type game (topview one), and Im having trouble getting the man to shott in the direction that he's facing (the man can rotate 360 degrees)... if anyone knows a tutorial that could help or anything, that would be great !
thx
im havin the exact same problem....i found a tutorial that was perfect for moving the car but im havin the same problem as u with the shooting...tell me if u solve it:puzzled:
Sirisian
March 31st, 2005, 08:27 PM
http://www.kirupa.com/forum/showthread.php?t=90734 look here I explained my code 2nd post is this what u mean. If so Im really good at them just ask questions http://www.kirupa.com/forum/showthread.php?t=90504
i need help
April 1st, 2005, 09:59 AM
http://www.kirupa.com/forum/showthread.php?t=90734 look here I explained my code 2nd post is this what u mean. If so Im really good at them just ask questions http://www.kirupa.com/forum/showthread.php?t=90504
is the code you wrote supposed to make the character shoot??
i need help
April 1st, 2005, 10:15 AM
Tonypa is a tile based tuts though arn't they ?
i've gotten pretty far on a tut on this but its not based on rottation its face north, south etc...
and have it as a root var and use a if statement to tell how it flies
the problem is shooting out of a car
wat tut have u been workin on??
Sirisian
April 1st, 2005, 12:39 PM
my code is for rotation. The shooting code should use duplicateMovieClip and then set the rotation fo the bullet equal to the person that fired it. It should then move the bullet using trig code
Lomadrian
April 1st, 2005, 05:24 PM
If you have the basic movement down and your car's pointing right when _rotation = 0, then this code should be able to make it shoot:
var bullet:Object = {counter:0, speed:10};
var setShootdelay:Number = 10;
var shootDelay:Number = setShootdelay;
_root.onEnterFrame = function():Void {
shootDelay = Math.max(shootDelay-1, 0);
if (Key.isDown(Key.SPACE) && shootDelay == 0) {
shootDelay = setShootdelay;
bullet.counter++;
if (bullet.counter>50) { bullet.counter = 1; }
var bullet_mc:MovieClip = _root.attachMovie("bullet", "bullet_"+bullet.counter, bullet.counter);
bullet_mc._x = character._x;
bullet_mc._y = character._y;
var angle:Number = character._rotation*Math.PI/180;
bullet_mc.xmov = Math.cos(angle)*bullet.speed;
bullet_mc.ymov = Math.sin(angle)*bullet.speed;
bullet_mc.onEnterFrame = function():Void {
this._x += this.xmov;
this._y += this.ymov;
if (this._x<0 || this._y<0 || this._x>Stage.width || this._y>Stage.height) {
this.removeMovieClip();
}
};
}
};
In this, the instance name of your character is character. It's written in AS 2.0, and uses "attachMovie" instead of "duplicateMovieClip".
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.