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

#351 2013-01-22 12:56:59

Geek773
New Scratcher
Registered: 2013-01-22
Posts: 5

Re: Scripts Workshop: Give and get help with scripts

Hey, everyone. I'm using scratch to make a Space Invaders game. I want the bullet (this sprite) to glide straight up, even when the gun moves from left to right. But the only command I can find is to send it to one location, no command to allow me to say "If Sprite 1 is here, Sprite 2 goes here when up arrow is pressed." My code is this:

when up arrow key pressed
go to (Sprite1)
show
play sound (Laser1)
glide (1) secs to x: (2) y: (180)
hide
go to (Sprite1)
I can see my current code sends the bullet from the "gun" sprite to the on point at the top-middle of the screen, but I don't know how to add an "if" instruction to vary this finishing point. Please help!

-Geek

Offline

 

#352 2013-01-22 15:17:00

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

Re: Scripts Workshop: Give and get help with scripts

Geek773 wrote:

Hey, everyone. I'm using scratch to make a Space Invaders game. I want the bullet (this sprite) to glide straight up, even when the gun moves from left to right. But the only command I can find is to send it to one location, no command to allow me to say "If Sprite 1 is here, Sprite 2 goes here when up arrow is pressed." My code is this:

when [up arrow v] key pressed
go to (Sprite1)
show
play sound (Laser1)
glide (1) secs to x: (2) y: (180)
hide
go to (Sprite1)
I can see my current code sends the bullet from the "gun" sprite to the on point at the top-middle of the screen, but I don't know how to add an "if" instruction to vary this finishing point. Please help!

-Geek

Well, from what I see, you just need some to alter your script so that it'd actually move upwards, correct? Then this is a simple change:

when [up arrow v] key pressed
go to [Sprite1 v]
show
play sound [Laser1 v]
repeat until (touching [edge v]?)
 change y by (1)//Increase 1 for a faster speed.
end
hide
go to [Sprite1 v]

I hope that this helps! Also, hello Geek773 and welcome to Scratch! I wish you a head-start in your adventure to learn how to program!

Last edited by ErnieParke (2013-01-22 15:19:12)


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

Offline

 

#353 2013-01-22 19:05:35

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Scripts Workshop: Give and get help with scripts

For my online/offline thing, change the f to an F.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#354 2013-01-22 20:47:17

sparky2008123
Scratcher
Registered: 2012-08-06
Posts: 500+

Re: Scripts Workshop: Give and get help with scripts

I have a question about scrolling. How do you program it to make the sprite stay in the middle or to the left of the screen but the screen is scrolling to the right?
Or just how to you make a scrolling screen? Cause several projects I'm working on really could use the scrolling technic.


Where can I find the best book ever?
http://media.tumblr.com/tumblr_mavjipQrj91rrpsd7.gif

Offline

 

#355 2013-01-22 22:45:46

sparky2008123
Scratcher
Registered: 2012-08-06
Posts: 500+

Re: Scripts Workshop: Give and get help with scripts

I want to make a fireball shoot the way my sprite is facing and bounce across the screen, disappearing if it hits another sprite. How would i do this?


Where can I find the best book ever?
http://media.tumblr.com/tumblr_mavjipQrj91rrpsd7.gif

Offline

 

#356 2013-01-23 17:28:10

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

Re: Scripts Workshop: Give and get help with scripts

sparky2008123 wrote:

I have a question about scrolling. How do you program it to make the sprite stay in the middle or to the left of the screen but the screen is scrolling to the right?
Or just how to you make a scrolling screen? Cause several projects I'm working on really could use the scrolling technic.

As for staying in a certain position, just don't make is scroll and have it go to where it needs to be, say (89, 89). As for scrolling, you'll need two variables called ScrollX (for scrolling left/right), and ScrollY (for scrolling up/down). Now, make it so that each ueses this script:

when gf clicked
forever
 go to x: ((ScrollX) + [Offset (240 for half-screen)]) y: ((ScrollY) + [Offset (180 for half-screen)])

Remember, a little bit of tweaking is needed. Also, whenever you want to move everything, just change ScrollX and ScrollY how ever you want.

I hope that this answers you question!


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

Offline

 

#357 2013-01-23 22:21:23

sparky2008123
Scratcher
Registered: 2012-08-06
Posts: 500+

Re: Scripts Workshop: Give and get help with scripts

ErnieParke wrote:

sparky2008123 wrote:

I have a question about scrolling. How do you program it to make the sprite stay in the middle or to the left of the screen but the screen is scrolling to the right?
Or just how to you make a scrolling screen? Cause several projects I'm working on really could use the scrolling technic.

As for staying in a certain position, just don't make is scroll and have it go to where it needs to be, say (89, 89). As for scrolling, you'll need two variables called ScrollX (for scrolling left/right), and ScrollY (for scrolling up/down). Now, make it so that each ueses this script:

when gf clicked
forever
 go to x: ((ScrollX) + [Offset (240 for half-screen)]) y: ((ScrollY) + [Offset (180 for half-screen)])

Remember, a little bit of tweaking is needed. Also, whenever you want to move everything, just change ScrollX and ScrollY how ever you want.

I hope that this answers you question!

Thanks! One more thing, how do I make my sprites move smoothly and jump like in those good projects? Like how they jump high and can fall down but move while falling?

And how do I make them jump on platforms and fall in holes? You know, like they can bump into walls and jump on stuff without falling through.

Lastly, how on EARTH do I make... Oh wait, I already asked that... hehehe, sorry.


Where can I find the best book ever?
http://media.tumblr.com/tumblr_mavjipQrj91rrpsd7.gif

Offline

 

#358 2013-01-24 03:01:22

Geek773
New Scratcher
Registered: 2013-01-22
Posts: 5

Re: Scripts Workshop: Give and get help with scripts

ErnieParke wrote:

Geek773 wrote:

Hey, everyone. I'm using scratch to make a Space Invaders game. I want the bullet (this sprite) to glide straight up, even when the gun moves from left to right. But the only command I can find is to send it to one location, no command to allow me to say "If Sprite 1 is here, Sprite 2 goes here when up arrow is pressed." My code is this:

when [up arrow v] key pressed
go to (Sprite1)
show
play sound (Laser1)
glide (1) secs to x: (2) y: (180)
hide
go to (Sprite1)
I can see my current code sends the bullet from the "gun" sprite to the on point at the top-middle of the screen, but I don't know how to add an "if" instruction to vary this finishing point. Please help!

-Geek

Well, from what I see, you just need some to alter your script so that it'd actually move upwards, correct? Then this is a simple change:

when [up arrow v] key pressed
go to [Sprite1 v]
show
play sound [Laser1 v]
repeat until (touching [edge v]?)
 change y by (1)//Increase 1 for a faster speed.
end
hide
go to [Sprite1 v]

I hope that this helps! Also, hello Geek773 and welcome to Scratch! I wish you a head-start in your adventure to learn how to program!

Urm...... tried this but didn't work? There's no "glide" script so that the sprite actually moves - all I think I need are some "if" scripts, so that if "Sprite1" (the moving gun in my space invaders game) is in one position, "Sprite2" would fire straight up, as opposed to always to top-middle, like it does right now. The current glide code (see my previous code) works fine when the gun is in the middle, but when I move it (by using the arrow keys) it still fires to top middle. I think I need something like this:

when [up arrow] key pressed
go to [Sprite1]
show
play sound [Laser1]
if
glide [1] secs to x: [170] y: [180]
if
glide [1] secs to x: [2] y: [180]
if
glide [1] secs to x: [-170] y: [180]
Great - now I just need something to go with my "if"s relating to the position of a DIFFERENT sprite - and the first part of my game will work!

Please help!

-Geek  big_smile

Offline

 

#359 2013-01-24 03:12:33

Geek773
New Scratcher
Registered: 2013-01-22
Posts: 5

Re: Scripts Workshop: Give and get help with scripts

Geek773 wrote:

ErnieParke wrote:

Geek773 wrote:

Hey, everyone. I'm using scratch to make a Space Invaders game. I want the bullet (this sprite) to glide straight up, even when the gun moves from left to right. But the only command I can find is to send it to one location, no command to allow me to say "If Sprite 1 is here, Sprite 2 goes here when up arrow is pressed." My code is this:

when [up arrow v] key pressed
go to (Sprite1)
show
play sound (Laser1)
glide (1) secs to x: (2) y: (180)
hide
go to (Sprite1)
I can see my current code sends the bullet from the "gun" sprite to the on point at the top-middle of the screen, but I don't know how to add an "if" instruction to vary this finishing point. Please help!

-Geek

Well, from what I see, you just need some to alter your script so that it'd actually move upwards, correct? Then this is a simple change:

when [up arrow v] key pressed
go to [Sprite1 v]
show
play sound [Laser1 v]
repeat until (touching [edge v]?)
 change y by (1)//Increase 1 for a faster speed.
end
hide
go to [Sprite1 v]

I hope that this helps! Also, hello Geek773 and welcome to Scratch! I wish you a head-start in your adventure to learn how to program!

Urm...... tried this but didn't work? There's no "glide" script so that the sprite actually moves - all I think I need are some "if" scripts, so that if "Sprite1" (the moving gun in my space invaders game) is in one position, "Sprite2" would fire straight up, as opposed to always to top-middle, like it does right now. The current glide code (see my previous code) works fine when the gun is in the middle, but when I move it (by using the arrow keys) it still fires to top middle. I think I need something like this:

when [up arrow] key pressed
go to [Sprite1]
show
play sound [Laser1]
if
glide [1] secs to x: [170] y: [180]
if
glide [1] secs to x: [2] y: [180]
if
glide [1] secs to x: [-170] y: [180]
Great - now I just need something to go with my "if"s relating to the position of a DIFFERENT sprite - and the first part of my game will work!

Please help!

-Geek  big_smile

Done it! Problem solved with following code:

when [up arrow] key pressed
go to [Sprite1]
show
play sound [Laser1]
if <(x position of [Sprite1]) = [170]
   glide [1] secs to x: [170] y: [180]
if (x position of [Sprite1]) = [0]
   glide [1] secs to x: [2] y: [180]
if (x position of [Sprite1]) = [-170]
   glide [1] secs to x: [-170] y: [180]
hide
go to [Sprite1]
Hurrah! No more replies needed :p

Offline

 

#360 2013-01-24 16:00:50

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

Re: Scripts Workshop: Give and get help with scripts

Geek773 wrote:

Geek773 wrote:

ErnieParke wrote:

Well, from what I see, you just need some to alter your script so that it'd actually move upwards, correct? Then this is a simple change:

when [up arrow v] key pressed
go to [Sprite1 v]
show
play sound [Laser1 v]
repeat until (touching [edge v]?)
 change y by (1)//Increase 1 for a faster speed.
end
hide
go to [Sprite1 v]

I hope that this helps! Also, hello Geek773 and welcome to Scratch! I wish you a head-start in your adventure to learn how to program!

Urm...... tried this but didn't work? There's no "glide" script so that the sprite actually moves - all I think I need are some "if" scripts, so that if "Sprite1" (the moving gun in my space invaders game) is in one position, "Sprite2" would fire straight up, as opposed to always to top-middle, like it does right now. The current glide code (see my previous code) works fine when the gun is in the middle, but when I move it (by using the arrow keys) it still fires to top middle. I think I need something like this:

when [up arrow] key pressed
go to [Sprite1]
show
play sound [Laser1]
if
glide [1] secs to x: [170] y: [180]
if
glide [1] secs to x: [2] y: [180]
if
glide [1] secs to x: [-170] y: [180]
Great - now I just need something to go with my "if"s relating to the position of a DIFFERENT sprite - and the first part of my game will work!

Please help!

-Geek  big_smile

Done it! Problem solved with following code:

when [up arrow] key pressed
go to [Sprite1]
show
play sound [Laser1 v]
if <([x position v] of [Sprite1 v]) = [170]>
   glide [1] secs to x: [170] y: [180]
end
if <([x position v] of [Sprite1 v]) = [0]>
   glide [1] secs to x: [2] y: [180]
end
if <([x position v] of [Sprite1 v]) = [-170]>
   glide [1] secs to x: [-170] y: [180]
end
hide
go to [Sprite1 v]
Hurrah! No more replies needed :p

You do know that that could've been simplified inot this?

when [up arrow] key pressed
go to [Sprite1]
show
play sound [Laser1 v]
   glide [1] secs to x: ([x position v] of [Sprite1 v]) y: [180]
hide
go to [Sprite1 v]

Anyway, it's great that you found a solution to your problem.  smile


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

Offline

 

#361 2013-01-25 01:24:45

JH1010
Scratcher
Registered: 2012-05-31
Posts: 1000+

Re: Scripts Workshop: Give and get help with scripts

Sorry I haven't been active over the past few days. I have decided that this thread wil move to 2.0 on Monday. The 1.4 thread will still be open and be open until the end but for a while at least our main activity will be on the 2.0 site.

Offline

 

#362 2013-01-25 03:01:31

Geek773
New Scratcher
Registered: 2013-01-22
Posts: 5

Re: Scripts Workshop: Give and get help with scripts

Hey everyone! Space Invaders game problems - part 2!|-( Gun shoots at target sprites - so I've tried to use this code to get the target sprites to "die" (hide and play a noise) when they get hit by the bullet sprite:-

if <(touching [Sprite2])>
      hide
      play sound (Laser2)
But for no apparent reason, the script just won't do anything, the sprites get hit by the bullet while its gliding, but stay where they are as if nothing happened!

Please help!

-Geek  big_smile

Offline

 

#363 2013-01-25 03:34:52

Auto007
Scratcher
Registered: 2012-11-25
Posts: 100+

Re: Scripts Workshop: Give and get help with scripts

Geek773 wrote:

Hey everyone! Space Invaders game problems - part 2!|-( Gun shoots at target sprites - so I've tried to use this code to get the target sprites to "die" (hide and play a noise) when they get hit by the bullet sprite:-

if <(touching [Sprite2])>
      hide
      play sound (Laser2)
But for no apparent reason, the script just won't do anything, the sprites get hit by the bullet while its gliding, but stay where they are as if nothing happened!

Please help!

-Geek  big_smile

put it in forever loop , that u r using for ur "gliding" sprite.

Offline

 

#364 2013-01-25 11:53:13

Geek773
New Scratcher
Registered: 2013-01-22
Posts: 5

Re: Scripts Workshop: Give and get help with scripts

Auto007 wrote:

Geek773 wrote:

Hey everyone! Space Invaders game problems - part 2!|-( Gun shoots at target sprites - so I've tried to use this code to get the target sprites to "die" (hide and play a noise) when they get hit by the bullet sprite:-

if <(touching [Sprite2])>
      hide
      play sound (Laser2)
But for no apparent reason, the script just won't do anything, the sprites get hit by the bullet while its gliding, but stay where they are as if nothing happened!

Please help!

-Geek  big_smile

put it in forever loop , that u r using for ur "gliding" sprite.

Thank you - this solved the problem!  smile

-Geek  big_smile

Offline

 

#365 2013-01-27 01:24:21

Auto007
Scratcher
Registered: 2012-11-25
Posts: 100+

Re: Scripts Workshop: Give and get help with scripts

How can i make a Sprite go elliptical orbit ?

Offline

 

#366 2013-01-27 02:46:28

Aditya007
Scratcher
Registered: 2012-11-27
Posts: 63

Re: Scripts Workshop: Give and get help with scripts

Geek773 wrote:

Hey, everyone. I'm using scratch to make a Space Invaders game. I want the bullet (this sprite) to glide straight up, even when the gun moves from left to right. But the only command I can find is to send it to one location, no command to allow me to say "If Sprite 1 is here, Sprite 2 goes here when up arrow is pressed." My code is this:

when up arrow key pressed
go to (Sprite1)
Point in direction ([direction v] of [sprite arrow v])
show
play sound 
Repeat until <<touching [edge v]> or <touching [invader v]>>
Move [10] steps
End
hide
go to (Sprite1)
I can see my current code sends the bullet from the "gun" sprite to the on point at the top-middle of the screen, but I don't know how to add an "if" instruction to vary this finishing point. Please help!

-Geek

Last edited by Aditya007 (2013-01-27 02:47:49)


Wolf_OS!!!  smile  Check My Stuff  tongue  Need Help?  Currently, I am http://blocks.scratchr.org/API.php?user=Aditya007&amp;action=onlineStatus&amp;type=square
http://i49.tinypic.com/15gy1j6.jpg

Offline

 

#367 2013-01-27 11:42:47

Aditya007
Scratcher
Registered: 2012-11-27
Posts: 63

Re: Scripts Workshop: Give and get help with scripts

sparky2008123 wrote:

I have a question about scrolling. How do you program it to make the sprite stay in the middle or to the left of the screen but the screen is scrolling to the right?
Or just how to you make a scrolling screen? Cause several projects I'm working on really could use the scrolling technic.

Just don't take a background, take sprites which will be moving as the background, check the scrolling Demo in the sample projects of scratch


Wolf_OS!!!  smile  Check My Stuff  tongue  Need Help?  Currently, I am http://blocks.scratchr.org/API.php?user=Aditya007&amp;action=onlineStatus&amp;type=square
http://i49.tinypic.com/15gy1j6.jpg

Offline

 

#368 2013-01-27 11:46:01

Aditya007
Scratcher
Registered: 2012-11-27
Posts: 63

Re: Scripts Workshop: Give and get help with scripts

sparky2008123 wrote:

I have a question about scrolling. How do you program it to make the sprite stay in the middle or to the left of the screen but the screen is scrolling to the right?
Or just how to you make a scrolling screen? Cause several projects I'm working on really could use the scrolling technic.

Just don't take a background, take sprites which will be moving as the background, check the scrollingDemo in the sample projects of scratch 1.4


Wolf_OS!!!  smile  Check My Stuff  tongue  Need Help?  Currently, I am http://blocks.scratchr.org/API.php?user=Aditya007&amp;action=onlineStatus&amp;type=square
http://i49.tinypic.com/15gy1j6.jpg

Offline

 

#369 2013-01-27 13:07:37

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

Re: Scripts Workshop: Give and get help with scripts

Auto007 wrote:

How can i make a Sprite go elliptical orbit ?

Well, there are two ways. Do you want the more complicated (math wise), more easily edited version or the simpler, harder to edit version?


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

Offline

 

#370 2013-01-28 10:01:16

Auto007
Scratcher
Registered: 2012-11-25
Posts: 100+

Re: Scripts Workshop: Give and get help with scripts

ErnieParke wrote:

Auto007 wrote:

How can i make a Sprite go elliptical orbit ?

Well, there are two ways. Do you want the more complicated (math wise), more easily edited version or the simpler, harder to edit version?

Gosh !! You always confuse me . Here and in idea shop also !
Can't you tell me both methods ?

Offline

 

#371 2013-01-28 12:27:02

JH1010
Scratcher
Registered: 2012-05-31
Posts: 1000+

Re: Scripts Workshop: Give and get help with scripts

Offline

 

#372 2013-01-28 16:22:09

carloszhu
New Scratcher
Registered: 2013-01-28
Posts: 5

Re: Scripts Workshop: Give and get help with scripts

Hello All!
I am making Pacman and I am about done with it, yet I just need to tweak one minor detail. I have walls in my game but I can't seem to find the right script to make the pacman stop when it gets to the wall. ie. it passes through the wall. Please note that one side of my wall is the edge, yet one side is not part of the edge.

Offline

 

#373 2013-01-28 17:26:02

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

Re: Scripts Workshop: Give and get help with scripts

carloszhu wrote:

Hello All!
I am making Pacman and I am about done with it, yet I just need to tweak one minor detail. I have walls in my game but I can't seem to find the right script to make the pacman stop when it gets to the wall. ie. it passes through the wall. Please note that one side of my wall is the edge, yet one side is not part of the edge.

Well there are a few ways. The easiest of which would be this:

if (key [right arrow v] pressed?)//Note, this should be your movement script.
 Movement script here...
 if (touching [wall v]?)//New Part
  Do reverse of movement script above...
 end
end
if (key [left arrow v] pressed?)//Note, this should be your movement script.
 Movement script here...
 if (touching [wall v]?)//New Part
  Do reverse of movement script above...
 end
end
So on...

If that didn't make sense, just say what confused you and I'll be back.

I hope that this helps!


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

Offline

 

#374 2013-01-28 18:23:58

carloszhu
New Scratcher
Registered: 2013-01-28
Posts: 5

Re: Scripts Workshop: Give and get help with scripts

Thanks, but the wall is part of my background. Also, by movement script, do you mean "move 10 steps"

Offline

 

#375 2013-01-28 18:31:39

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

Re: Scripts Workshop: Give and get help with scripts

carloszhu wrote:

Thanks, but the wall is part of my background. Also, by movement script, do you mean "move 10 steps"

Well I meant whatever script you had, so if you have [move (10) steps], the yes. And about the fact that you're wall is part of you background, just change these conditionals:

(Touching [wall v]?)

Into this:

(touching color [Wall Color]?)


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

Offline

 

Board footer