This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2008-06-03 12:46:35

Moospiker
Scratcher
Registered: 2008-06-03
Posts: 3

Rotation

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

 

#2 2008-06-03 12:51:24

CFCRubiks
Scratcher
Registered: 2008-05-11
Posts: 100+

Re: Rotation

[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

 

#3 2008-06-03 13:01:37

Moospiker
Scratcher
Registered: 2008-06-03
Posts: 3

Re: Rotation

Thanks.

Offline

 

#4 2008-06-03 14:37:09

Bobby500
Scratcher
Registered: 2008-04-19
Posts: 1000+

Re: Rotation

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

 

#5 2008-06-03 14:59:03

CFCRubiks
Scratcher
Registered: 2008-05-11
Posts: 100+

Re: Rotation

bobby500 wrote:

Look above

Actually, take away the else, and put point in direction under when space is pressed, but before repeat

Offline

 

#6 2008-06-03 15:05:49

Bobby500
Scratcher
Registered: 2008-04-19
Posts: 1000+

Re: Rotation

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!!  tongue   Actually, that would work best.

Offline

 

#7 2008-06-03 15:08:12

CFCRubiks
Scratcher
Registered: 2008-05-11
Posts: 100+

Re: Rotation

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!!  tongue   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

 

#8 2008-06-03 15:19:12

Bobby500
Scratcher
Registered: 2008-04-19
Posts: 1000+

Re: Rotation

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!!  tongue   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

 

#9 2008-06-04 13:07:49

Moospiker
Scratcher
Registered: 2008-06-03
Posts: 3

Re: Rotation

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

 

Board footer