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

#1 2012-08-30 20:01:16

Vladimir-7
New Scratcher
Registered: 2012-08-30
Posts: 2

can you involve your mouse when programming a game, and how?

i want to know how to program my game to use my mouse ( i.e. instead of the space bar or down arrow). this, i would mainly use for aiming.

Offline

 

#2 2012-08-30 20:08:18

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: can you involve your mouse when programming a game, and how?

This should go in "Questions about Scratch" (reported to be moved), but you can use some blocks such as:

when [sprite1 v] clicked
move [3] steps

when gf clicked
if <(mouse x) > [5]>
move [3] steps
end

Last edited by jvvg (2012-08-30 20:08:45)


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#3 2012-08-30 20:59:55

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: can you involve your mouse when programming a game, and how?

You can retrieve the current mouse coordinates with the (mouse x) and (mouse y) blocks under the sensing tab.  You can also check to see if the mouse is pressed. 

(mouse x)
(mouse y)
<mouse down?>

Offline

 

#4 2012-08-30 21:15:13

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: can you involve your mouse when programming a game, and how?

You can also have a sprite follow the mouse...

when gf clicked
forever
point towards [mouse-pointer v]
move (3) steps
end


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#5 2012-08-30 21:18:15

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

Re: can you involve your mouse when programming a game, and how?

Paddle2See wrote:

You can also have a sprite follow the mouse...

when gf clicked
forever
 point towards [mouse-pointer v]
 move (3) steps

Fixed.

Anyway, another block you could use is:

(touching [mouse pointer v]?)

Last edited by ErnieParke (2012-08-30 21:21:20)


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

Offline

 

#6 2012-08-30 21:21:54

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: can you involve your mouse when programming a game, and how?

For a crosshairs for aiming, you would use this script.

when gf clicked
forever
go to [mouse pointer v]
if <mouse down?>
broadcast [fire! v] and wait
end
This will work for a shooting game of some sort.  smile


Why are the secret organizations getting all the attention?  mad

Offline

 

#7 2012-08-31 02:52:26

BirdByte
Scratcher
Registered: 2012-07-07
Posts: 1000+

Re: can you involve your mouse when programming a game, and how?

As was pointed out above, there are plenty of blocks that can help you incorporate the mouse into the game. Here are all the blocks that you can use:

(mouse x)
(mouse y)
<mouse down?>
go to [mouse-pointer v]
<touching [mouse-pointer v]?>
point towards [mouse-pointer v]
(distance to [mouse-pointer v])


http://i50.tinypic.com/312u714.jpg

Offline

 

Board footer