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

#1 2008-06-16 15:12:41

Dan01
Scratcher
Registered: 2008-06-11
Posts: 100+

Shooting using the mouse for aiming

Hey!

I'm making a platform shooting game that involves using the mouse for aiming.

For example: When I move the mouse upwards the gun will point in that direction.

But my question is, how do I make it so the bullet fires in that direction also. I have tried it and it half works. However, when ever I move the mouse again, the bullet follows it.

So what I really want is for the bullet to fire in the direction of the mouse and not change direction again.

This is what I've got:

<when I receive[ shoot1]>
<forever if><<  <not> touching[ enemy1 ]>
<repeat until><touching[ enemy1 ]>
<show>
<point towards( mouse pointer)>
<glide( 1 )secs to x sad  <mouse x> )y sad  <mouse y> )
<if><touching[ enemy1 ]>
<hide>
<broadcast[ death ]>

Note: the bullet is a seperate sprite.

Last edited by Dan01 (2008-06-16 15:13:34)


http://img3.imageshack.us/img3/4743/ubd6522wp8.png
http://img3.imageshack.us/img3/4667/ubd3758ox2.png

Offline

 

#2 2008-06-16 15:15:32

Tutorial_Maker
Scratcher
Registered: 2008-06-15
Posts: 8

Re: Shooting using the mouse for aiming

Easy. Don't repeat the point towards mouse pointer. So it's like this:

[blocks]<when I receive[ shoot[/blocks]
[blocks]<point towards( mouse pointer[/blocks]

and then the rest of the script

Offline

 

#3 2008-06-16 15:20:26

Dan01
Scratcher
Registered: 2008-06-11
Posts: 100+

Re: Shooting using the mouse for aiming

Tutorial_Maker wrote:

Easy. Don't repeat the point towards mouse pointer. So it's like this:

[blocks]<when I receive[ shoot[/blocks]
[blocks]<point towards( mouse pointer[/blocks]

and then the rest of the script

Thanks!

However, it stops when the bullet reaches where the mouse was at the point of firing. Is there a way to make it continue firing in that direction?

~ Dan01  wink


http://img3.imageshack.us/img3/4743/ubd6522wp8.png
http://img3.imageshack.us/img3/4667/ubd3758ox2.png

Offline

 

#4 2008-06-16 15:23:13

Tutorial_Maker
Scratcher
Registered: 2008-06-15
Posts: 8

Re: Shooting using the mouse for aiming

Don't do the glide to mouse X/Y. instead, use the  [blocks]<move( 10  )steps>[/blocks]  block

Offline

 

#5 2008-06-16 15:27:06

Dan01
Scratcher
Registered: 2008-06-11
Posts: 100+

Re: Shooting using the mouse for aiming

Tutorial_Maker wrote:

Don't do the glide to mouse X/Y. instead, use the  [blocks]<move( 10  )steps>[/blocks]  block

Thanks so Much!  big_smile

~ Dan01  wink


http://img3.imageshack.us/img3/4743/ubd6522wp8.png
http://img3.imageshack.us/img3/4667/ubd3758ox2.png

Offline

 

#6 2008-06-16 15:28:21

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: Shooting using the mouse for aiming

No problem


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#7 2008-06-16 15:41:19

Dan01
Scratcher
Registered: 2008-06-11
Posts: 100+

Re: Shooting using the mouse for aiming

http://scratch.mit.edu/projects/Dan01/190059

That is the shortcut for the trailer of the game.

Please leave some comments.

Thanks

~ Dan01  wink


http://img3.imageshack.us/img3/4743/ubd6522wp8.png
http://img3.imageshack.us/img3/4667/ubd3758ox2.png

Offline

 

Board footer