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

#1 2013-05-05 07:40:33

DavidJames
New Scratcher
Registered: 2013-05-05
Posts: 3

Make bullets move in any direction.

How can I make a rocket, that moves all around the screen and turns 360 degrees in both directions, fire bullets in the direction it's facing and not just up, down, left and right. Any help is greatly appreciated.

Offline

 

#2 2013-05-05 08:55:02

dracae
New Scratcher
Registered: 2013-04-05
Posts: 42

Re: Make bullets move in any direction.

Firstly, is it controlled by the mouse, or arrow keys?

Offline

 

#3 2013-05-05 11:20:53

DavidJames
New Scratcher
Registered: 2013-05-05
Posts: 3

Re: Make bullets move in any direction.

x key turns it left by 15 degrees each press, the c key turns it right 15 degrees each press, the space gives it a boost which ever direction it is going in and z key fires the bullet. I can make the bullets go up, down, left and right but I want more than that. I'm just puzzled how to get the bullet to fire in the direction the rocket is travelling at the time.

Offline

 

#4 2013-05-05 11:44:45

7734f
Scratcher
Registered: 2010-12-23
Posts: 500+

Re: Make bullets move in any direction.

Here is the script for the rocket:


when gf clicked
forever
 if <key [x v] pressed?>
  turn ccw [15] degrees
 end
 if <key [c v] pressed?>
  turn cw [15] degrees
 end
 if <key [space v] pressed?>
  move [7] steps
And the bullet script:

when gf clicked
forever
 point in direction ([direction v] of [rocket v])
 if <key [z v] pressed?>
  repeat until <<touching [enemy v]?> or <touching [edge v] ?>>
   move [5] steps
  end
  go to [rocket v]
 end
Hope that helped!
~7734f


http://internetometer.com/image/38992.png   http://i37.tinypic.com/2qixx6c.png

Offline

 

#5 2013-05-05 11:46:21

Maltese_Falcon
Scratcher
Registered: 2013-03-25
Posts: 100+

Re: Make bullets move in any direction.

7734f wrote:

Here is the script for the rocket:


when gf clicked
forever
 if <key [x v] pressed?>
  turn ccw [15] degrees
 end
 if <key [c v] pressed?>
  turn cw [15] degrees
 end
 if <key [space v] pressed?>
  move [7] steps//Wouldn't that just make it move 7 steps and then be done?
And the bullet script:

when gf clicked
forever
 point in direction ([direction v] of [rocket v])
 if <key [z v] pressed?>
  repeat until <<touching [enemy v]?> or <touching [edge v] ?>>
   move [5] steps
  end
  go to [rocket v]
 end
Hope that helped!
~7734f

Offline

 

#6 2013-05-05 11:53:26

7734f
Scratcher
Registered: 2010-12-23
Posts: 500+

Re: Make bullets move in any direction.

Maltese_Falcon wrote:

7734f wrote:

Here is the script for the rocket:


when gf clicked
forever
 if <key [x v] pressed?>
  turn ccw [15] degrees
 end
 if <key [c v] pressed?>
  turn cw [15] degrees
 end
 if <key [space v] pressed?>
  move [7] steps//Wouldn't that just make it move 7 steps and then be done?
And the bullet script:

when gf clicked
forever
 point in direction ([direction v] of [rocket v])
 if <key [z v] pressed?>
  repeat until <<touching [enemy v]?> or <touching [edge v] ?>>
   move [5] steps
  end
  go to [rocket v]
 end
Hope that helped!
~7734f

If you hold down space then it moves. I think that's what he meant.


http://internetometer.com/image/38992.png   http://i37.tinypic.com/2qixx6c.png

Offline

 

#7 2013-05-05 13:42:08

DavidJames
New Scratcher
Registered: 2013-05-05
Posts: 3

Re: Make bullets move in any direction.

Thanks for the scripts. They wasn't exactly what I wanted but with a few tweeks and bit of luck I finally got what I wanted. Thanks 7734f

Offline

 

Board footer