Page 1 of 1

How to fire ammo in all four directions?

PostPosted: Fri Jan 09, 2009 8:35 pm
by BloodRedDragon
I am making an awesome game with tanks, a bit like the minigame in Crash Bash, but i am having some problems. I want the tank to be able to fire in all four directions, the direction corresponding to the arrow key you are pressing or have pressed. I have tried making a Move To event, where the ball moves toward a target but I cant get it to work for four directions. I have also tried using angle and directional velocity variables but I cant get that 2 work. Pleaz help! :(

Re: How to fire ammo in all four directions?

PostPosted: Fri Jan 09, 2009 11:20 pm
by DST
For the Turret:
make turret a 4 frame animation, with frame 0 being facing right;

Key down> left >
angle=180;
Key down> down>
angle=270;
do this for all directions;

Draw Actor>
animpos=angle/90;
x=tank.x;
y=tank.y;

Key Down>(fire key)>
CreateActor("bullet, etc);


For the bullet:
CreateActor>
angle=creator.angle;
directional_velocity=5;

This code works. If it doesn't work, then there is something else wrong.
Is anyone a child of someone else? things get hairy when you child something.
Always better to us the x=actor.x etc. instead of childing (except for very fast moving actors, as they may lag behind the other actor).

Re: How to fire ammo in all four directions?

PostPosted: Sat Jan 10, 2009 10:59 pm
by BloodRedDragon
Thnks a lot m8. Heres's a screenshot from my game. It might not be what it looks like when its finished becuase I will have 2 make some changes.