Okay, I'm creating a game where you have a top down view of a tank. The tank can be moved with the arrow keys, but now I need to make it shoot. My tank shell sprite can be shot easily with space, but it can only shoot north. How could I set it so that the bullet will always face in the direction that my tank is pointing and fire the right way?
First time, I set the bullet to turn at exactly the same rate as the tank when I pressed the arrow keys, but that means it will also turn in mid-flight if you start moving.
Any ideas?
Offline
[blocks]<when green flag clicked>[/blocks]
[blocks]<forever>[/blocks]
[blocks]<point in direction( Direction of tank[/blocks]
[blocks]<if><key[ space ]pressed?>[/blocks]
[blocks]<repeat until><touching[ Edge[/blocks]
[blocks]<move( 10 )steps>[/blocks]
[blocks]<end>[/blocks]
You might need to make it into to scripts. And yes, it is Dingdong's way (or wher I first heard about it anyways)
Last edited by CFCRubiks (2008-06-03 13:35:16)
Offline
CFCRubiks wrote:
[blocks]<when green flag clicked>[/blocks]
[blocks]<forever>[/blocks]
[blocks]<point in direction( Direction of tank[/blocks]
[blocks]<if><key[ space ]pressed?>[/blocks]
[blocks]<repeat until><touching[ Edge[/blocks]
[blocks]<move( 10 )steps>[/blocks]
[blocks]<end>[/blocks]
You might need to make it into to scripts. And yes, it is Dingdong's way (or wher I first heard about it anyways)
That will also make it turn in mid flight. Instead, try this one.
[blocks]<when green flag clicked>[/blocks]
[blocks]<forever>[/blocks]
[blocks]<if><key [space] pressed?>[/blocks]
[blocks]<repeat until><touching[ Edge[/blocks]
[blocks]<move( 10 )steps>[/blocks]
[blocks]<end>[/blocks]
[blocks]<else>[blocks]
[blocks]<point in direction( Direction of tank[/blocks]
[blocks]<end>[/blocks]
[blocks]<end>[/blocks]
Offline
bobby500 wrote:
Look above
Actually, take away the else, and put point in direction under when space is pressed, but before repeat
Offline
CFCRubiks wrote:
bobby500 wrote:
Look above
Actually, take away the else, and put point in direction under when space is pressed, but before repeat
Don't misqoute me!! Actually, that would work best.
Offline
Bobby500 wrote:
CFCRubiks wrote:
bobby500 wrote:
Look above
Actually, take away the else, and put point in direction under when space is pressed, but before repeat
Don't misqoute me!!
Actually, that would work best.
Well, I didn't want to copy ALL of what you and I wrote, so I'm quoting you be redirecting the "viewer".
Offline
CFCRubiks wrote:
Bobby500 wrote:
CFCRubiks wrote:
Actually, take away the else, and put point in direction under when space is pressed, but before repeat
Don't misqoute me!!
Actually, that would work best.
Well, I didn't want to copy ALL of what you and I wrote, so I'm quoting you be redirecting the "viewer".
okay, that is fine.
Last edited by Bobby500 (2008-06-03 15:19:26)
Offline
CFCRubiks wrote:
[blocks]<point in direction( Direction of tank[/blocks]
Actually, that button doesn't exist. Do you mean I should set it to move at the same rate as the tank? Because, that's what I did.
Thanks for yours too Bobby.
Now I got a new question. How do I make a variable actually change things?
Like say,
When (variable x) = 0
Next costume
or something?
Last edited by Moospiker (2008-06-04 13:11:46)
Offline