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

#1 2012-07-10 12:30:28

DonutCannon
New Scratcher
Registered: 2012-07-02
Posts: 29

Infinite Distance Gunshot

Hey, so I've been working on a gun that shoots bullets. I have most things done, but now I need a way to make the bullet continue on forever. So far I have a script that shoots a bullet to the mouse using a glide block, but I need it to go until it reaches the border of the screen, even if the mouse isn't there. I hope that makes sense  big_smile

Thanks in advance.

Offline

 

#2 2012-07-10 12:39:21

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

Re: Infinite Distance Gunshot

when i receive [shoot v]
point towards [mouse-pointer v]
repeat until <touching [edge v]?>
 move (5) steps
end

Offline

 

#3 2012-07-10 12:41:16

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Infinite Distance Gunshot

DonutCannon wrote:

Hey, so I've been working on a gun that shoots bullets. I have most things done, but now I need a way to make the bullet continue on forever. So far I have a script that shoots a bullet to the mouse using a glide block, but I need it to go until it reaches the border of the screen, even if the mouse isn't there. I hope that makes sense  big_smile

Thanks in advance.

Instead of using a glide block, use direction and move blocks...something like this should work:

when I receive [shoot v] //This is how I would do it with a bullet, but maybe you did it differently
go to [player v]
point towards [mouse-pointer v]
show
repeat until <touching [edge v]?>
move (number) steps
end
hide
EDIT: Wow, that's scary similar in timing and in script suggestion  smile

Last edited by AtomicBawm3 (2012-07-10 12:42:23)


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#4 2012-07-10 13:17:40

DonutCannon
New Scratcher
Registered: 2012-07-02
Posts: 29

Re: Infinite Distance Gunshot

Ok, trying to make a form of accuracy.

Trying to use

[scratchblocks]
point towards [mouse-pointer]
point towards <<pick random (-20) to (20)> + <direction>
{scratchblocks]

Does not appear to work...

Offline

 

#5 2012-07-10 13:30:46

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Infinite Distance Gunshot

DonutCannon wrote:

Ok, trying to make a form of accuracy.

Trying to use

point towards [mouse-pointer]
point in direction ((pick random (-20) to (20)) + (direction))
Does not appear to work...

fixed (your) [scripts v]


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#6 2012-07-10 13:44:52

DonutCannon
New Scratcher
Registered: 2012-07-02
Posts: 29

Re: Infinite Distance Gunshot

zammer990 wrote:

DonutCannon wrote:

Ok, trying to make a form of accuracy.

Trying to use

point towards [mouse-pointer]
point in direction ((pick random (-20) to (20)) + (direction))
Does not appear to work...

fixed (your) [scripts v]

Thanks. I saw the problem after writing, and I dunno how to edit my posts  sad

Offline

 

#7 2012-07-10 13:53:44

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Infinite Distance Gunshot

DonutCannon wrote:

zammer990 wrote:

DonutCannon wrote:

Ok, trying to make a form of accuracy.

Trying to use

point towards [mouse-pointer]
point in direction ((pick random (-20) to (20)) + (direction))
Does not appear to work...

fixed (your) [scripts v]

Thanks. I saw the problem after writing, and I dunno how to edit my posts  sad

You can't until you're a scratcher, then there's just a box that says "edit" next to report


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#8 2012-07-10 14:08:26

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Infinite Distance Gunshot

For a nice effect, try this:

go to [cannon v]
point in direction ([direction v] of [cannon v])
set [inaccuracy v] to (pick random (-0.10) to (0.10))
set [speedgain v] to (pick random (0.010) to (1.000))
set [speed v] to ((1) - (speedgain))
if <(pick random (1) to (2)) = (1)>
 set [dir v] to [1]
else
 set [dir v] to [2]
end
repeat until <touching [edge v]?>
 move (speed) steps
 change [speed v] by (speedgain)
 if <(dir) = [1]>
  turn cw (inaccuracy) degrees
 else
  turn ccw (inaccuracy) degrees
 end
end

Last edited by SciTecCf (2012-07-10 14:11:13)


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#9 2012-07-10 14:10:20

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Infinite Distance Gunshot

SciTecCf wrote:

For a nice effect, try this:

go to [cannon v]
point in direction ([direction v] of [cannon v])
set [inaccuracy v] to (pick random (-0.10) to (0.10))
set [speedgain v] to (pick random (0.010) to (1.000))
set [speed v] to ((1) - (speedgain))
repeat until <touching [edge v]?>
 move (speed) steps
 change [speed v] by (speedgain)
end

That would give the potential for an accelerating bullet, I guess it depends if you want realism or random


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#10 2012-07-10 14:37:48

DonutCannon
New Scratcher
Registered: 2012-07-02
Posts: 29

Re: Infinite Distance Gunshot

zammer990 wrote:

DonutCannon wrote:

Ok, trying to make a form of accuracy.

Trying to use

point towards [mouse-pointer]
point in direction ((pick random (-20) to (20)) + (direction))
Does not appear to work...

fixed (your) [scripts v]

K, got it to work. Thanks

Finished product here:
http://scratch.mit.edu/projects/DonutCannon/2666366

Of course, this isn't quite a game yet...

Offline

 

Board footer