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

#1 2011-07-05 09:04:29

spud1998
Scratcher
Registered: 2011-06-07
Posts: 15

Bullet Firing in Direction of Ship

Hi Guys,

I am making a 'Star Wars - ESCAPE THE DEATH STAR!' Scroller, and obviously i want my Tie-Fighter to fire bullets.

How do I make the bullets fire in the direction that the ship is pointed in?

At the moment I have this script for the ship direction:

<when green flag clicked>
<forever>
<if>
<key[ rightarrow ]pressed?>
<switch to costume[ rightface]
<if>
<key[ leftarrow ]pressed?>
<switch to costume[ leftface]

but how do I get the bullets to fire in the direction of the ship (at the moment they only fire right.

thanks for helping

Offline

 

#2 2011-07-05 11:33:02

EdnaC
Scratcher
Registered: 2007-08-28
Posts: 100+

Re: Bullet Firing in Direction of Ship

The bullet can:

GoTo (ship)
Point in Direction (ship)

For the direction, you need to use the "Sensing" block that lets you choose a sprite, then choose its direction from the list of available stuff.

Offline

 

#3 2011-07-05 11:51:23

Sphingo
Scratcher
Registered: 2011-07-01
Posts: 87

Re: Bullet Firing in Direction of Ship

Hi Spud1998! First let me point you in the direction of my game called...
Tanks: http://scratch.mit.edu/projects/Sphingo/1900299
... You will find all you want on the sprite called RED SHELL or GREEN SHELL!!!

Let me just explain...

<when green flag clicked>
<broadcast[ e.g. GO ]


Then...

<when I receive[ GO ]
<hide>
<repeat until><key[ space ]pressed?>
<go to[ tiefighter ]
<play sound[ e.g. blast ]
<show>
<point in direction( direction ) of ( tiefighter )
<repeat until><<<touching[ xwing fighter ]<or><touching[ edge of screen etc.] >>
<move( 8 )steps>
<broadcast[ GO ]

This basically means...

That when it says GO make (this is the script of the bullet/blast by the way) bullet hide( so you can't see it) AND FOLLOW AROUND THE TIEFIGHTER. Then if the shoot button is pushed, a noise is made and the bullet made visible The bullet then poinst and moves in the direction of the tiefighter at that time. It will continue to move in that direction until it hits an xwing fighter(for example) or edge of the screen!!!

I STRONGLY SUGGEST YOU CHECK OUT THE SCRIPT FOR THE GREEN OR RED SHELL IN MY TANK GAME!!! IT IS WHAT I HAVE JUST DECRIBED JUST EASIER TO VIEW AND COPY (I don't mind  tongue  just give me credit!)

I HOPE THIS PROBABLY GIBBERISH HELPS!!! Please reply if it does or doesn't!!!

Offline

 

#4 2011-07-06 03:51:28

jalkan
Scratcher
Registered: 2009-05-14
Posts: 25

Re: Bullet Firing in Direction of Ship

[point in direction (direction of [ship])]

Offline

 

Board footer