|
|
|
#1 |
|
Member
Join Date: Sep 2006
Posts: 70
|
[F8] Making a shooting game
Hello, i have a quick question.
I'm making a shooting game where you play as a man with a gun and the view is an eagle-eye view (you can only see the man's head). The gun has 8 angles (up, down, left, right and diagonals) and the 'bullet' which I want the gun to shoot is a straight line. I made it so the bullet is the same angle as the gun, but what I can't do is make it move in the right way i want it to move (ex. Move up when the gun is pointing up). Is there a code for this? |
|
|
|
|
|
#2 |
|
Member
Join Date: Sep 2006
Posts: 70
|
please help!! ive been wondering about this for a very long time
|
|
|
|
|
|
#3 |
|
Total Universe Man
Join Date: Jul 2000
Location: NaN
Posts: 2,061
|
Just make a gun clip and attach the bullet inside the clip. That way you only have to move the bullet forward on its local space. Then you can just rotate your gun clip to change the direction.
|
|
|
|
|
|
#4 |
|
Member
Join Date: Sep 2006
Posts: 70
|
that would work, but lets say you point left and shoot. If you turn to the right, the bullet will turn too.
|
|
|
|
|
|
#5 |
|
Member
Join Date: Sep 2006
Posts: 70
|
please help!!!
|
|
|
|
|
|
#6 |
|
Member
Join Date: Sep 2006
Posts: 70
|
Can anyone help!??
|
|
|
|
|
|
#7 |
|
Modulator
Join Date: Nov 2003
Location: A shoebox outside of SM Megamall
Posts: 149
|
Since your Bullet is moving, I'm assuming you've put in an element of speed. So lets see here:
Code:
vel = the speed you want the bullet to travel Code:
UP speedY = -vel; speedX = 0; DOWN speedY = vel; speedX = 0; LEFT speedY = 0; speedX = -vel; RIGHT speedY = 0; speedX = vel; So, all you need to do is get the direction the man is facing: Code:
function getFacing(){
you should be able to
figure something out
here, otherwise just email
me, or just say so.
return x, y; /*tell us whether x is going to be positive,
negative or zero, and do the same for y. That should send
our projectiles in the right direction.
*/
}
Now all you need to do is shoot the bullet in that direction e.g. Actions for an MC named bullet_034, where vel = 5 or whatever, and the man is facing LEFT: Code:
onClipEvent(load){//You don't really need this onClipEvent(load).
speedX = -vel;//When you create your bullet using attachMovie(),
speedY = 0;//You can tell it these properties anyways.
}
onClipEvent(enterFrame){
this._x += speedX;
this._y += speedY;
}
__________________
As a Gamer, you play by the rules. As a Programmer, you play as God. |
|
|
|
|
|
#8 |
|
Member
Join Date: Sep 2006
Posts: 70
|
thanks it did!
|
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|