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

#1 2012-12-03 14:59:34

iaoumeur
Scratcher
Registered: 2012-11-24
Posts: 500+

How to make a tank shoot with the mouse?

Hi I have made a project with a tank that shoots when you press f. I want to make the tank shoot by pressing the mouse which is used to aim. I have tried this before by broadcasting but it was too slow. Plz can someone help? Here is the link to the project: (copy and paste into the address bar) http://scratch.mit.edu/projects/iaoumeur/2932591


The Dot 3 is out!!! Play it here!

Offline

 

#2 2012-12-03 16:33:41

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How to make a tank shoot with the mouse?

Instead of using this in your firing script:

when [f v] key pressed
firing scripts

Try using this instead:

when gf clicked
forever
 if (mouse down?)
  firing scripts
 end

I hope that this helps!


http://i46.tinypic.com/35ismmc.png

Offline

 

#3 2012-12-03 16:39:11

iaoumeur
Scratcher
Registered: 2012-11-24
Posts: 500+

Re: How to make a tank shoot with the mouse?

Thank you soooo much! It's fixed now.


The Dot 3 is out!!! Play it here!

Offline

 

#4 2012-12-03 16:47:14

iaoumeur
Scratcher
Registered: 2012-11-24
Posts: 500+

Re: How to make a tank shoot with the mouse?

And just asking, where do you get the red blocks from? Also does mouse down mean when you click the mouse? Thanks again by the way from before.


The Dot 3 is out!!! Play it here!

Offline

 

#5 2012-12-03 16:47:46

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How to make a tank shoot with the mouse?

iaoumeur wrote:

Thank you soooo much! It's fixed now.

Your welcome! And I wish you good luck on whatever else you'll be doing with it!


http://i46.tinypic.com/35ismmc.png

Offline

 

#6 2013-04-22 23:19:43

Da_Tr0LL1337
New Scratcher
Registered: 2013-04-22
Posts: 2

Re: How to make a tank shoot with the mouse?

i was wondering, how do i make the barrel of the tank to point on the mouse, yet it stays on the tank body and  moves with the boddy as well.

Offline

 

#7 2013-04-23 06:13:16

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: How to make a tank shoot with the mouse?

Da_Tr0LL1337 wrote:

i was wondering, how do i make the barrel of the tank to point on the mouse, yet it stays on the tank body and  moves with the boddy as well.

I would suggest making the tank and barrel two separate sprites. Put the "center" of the tank sprite's costume where the barrel should go, and the center of the barrel sprite's costume in the part that should go where the tank's center is. Did that make sense?
Then, use the following script in the barrel:

when gf clicked
forever
 go to [tank v]
Then it will stay with the tank.

Offline

 

Board footer