How to fire ammo in all four directions?

Non-platform specific questions.

How to fire ammo in all four directions?

Postby BloodRedDragon » Fri Jan 09, 2009 8:35 pm

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! :(
Current projects:
Techno-Tank Arena: on hold
Techno-Tank SuperPortal (working title): 0.1%
Bowels of Galaxies: 35% (was a bit too optimistic)
User avatar
BloodRedDragon
 
Posts: 123
Joined: Tue Jan 29, 2008 10:07 pm
Location: The Underworld
Score: 5 Give a positive score

Re: How to fire ammo in all four directions?

Postby DST » Fri Jan 09, 2009 11:20 pm

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).
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: How to fire ammo in all four directions?

Postby BloodRedDragon » Sat Jan 10, 2009 10:59 pm

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.
Attachments
taster.PNG
My game! Should be finished February
Current projects:
Techno-Tank Arena: on hold
Techno-Tank SuperPortal (working title): 0.1%
Bowels of Galaxies: 35% (was a bit too optimistic)
User avatar
BloodRedDragon
 
Posts: 123
Joined: Tue Jan 29, 2008 10:07 pm
Location: The Underworld
Score: 5 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron