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!
Offline
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]
Last edited by ErnieParke (2013-01-22 15:19:12)
Offline
For my online/offline thing, change the f to an F.
Offline
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.
Offline
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?
Offline
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)])
Offline
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.
Offline
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!
-GeekWell, 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!
Offline
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!
-GeekWell, 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
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
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!
-GeekDone 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]
Offline
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
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!
Offline
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
put it in forever loop , that u r using for ur "gliding" sprite.
Offline
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!
-Geekput it in forever loop , that u r using for ur "gliding" sprite.
Thank you - this solved the problem!
-Geek
Offline
How can i make a Sprite go elliptical orbit ?
Offline
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)
Offline
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
Offline
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
Offline
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?
Offline
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
Offline
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
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...
Offline
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]?)
(touching color [Wall Color]?)
Offline