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

#1 2012-03-07 14:18:04

SD7
Scratcher
Registered: 2011-09-15
Posts: 100+

Help making Space Game

Hi I'm working on making a space game where the player commands a small yellow ship that moves along the x-axis at the bottom of the screen while fending off a variety of enemies. I'm running into some problems however with making some things work and figuring out how to do certain commands. This is what I need help with particularly:

1. What I'm trying to do is have a single sprite of each enemy type (red is standard, blue is more powerful, and black is a stealth suicide bomber) but have each one duplicate randomly within a set limit (ie the one Red ship sprite would duplicate 3-6 reds on screen at once, whereas the single blue sprite would only duplicate 1-2 blues). Is this possible or would I have to make all five red ships and have some of them "decide not to show up," that is, make a variable that determines whether the ship will begin to move in on the screen?

2. I've just begun to code in destroying an enemy. But if you look at the uploaded project and try to fire a shot at the black enemy (the only one with code right now), you'll see it explodes and dies, but keeps moving and eventually the explosion goes away and it switches back to its "ship" costume. What I have set up is that when it's touching the player's laser, it explodes, but I realizes it only explodes WHILE the laser is touching, or a short time after. What I want it to do is if the player's laser hits it, it switches to the explosion costume, stops moving for a second so the explosion lingers, then disappears and resets to the top of the screen. Does anyone know code from that? I've tried a bunch of variations but nothing seems to work.

3. Sort of in-line with 1, but with the lasers. I'd like to have the laser sprite duplicate so you can fire multiple shots at once rather than only one at a time. Again, same sort of thing as 1, so if there's a way.

4. Working on the player's own death, I'm running into trouble. I'd like it work like this; if the player is hit by any laser he dies instantly (I want to counteract that by using a shield button that can only be activated for so long). When he dies, I want him to switch to an explosion costume and then stop everything. Two seconds AFTER you die, I'd like to show a "game over" message, with the two second lag added to make the player realize they died before shutting everything down.

5. Lastly, is there any way to orient the layering of the sprites in the game, so that the lasers will show up behind the ships, and the "game over" message will show over everything?

And that should basically solve all the bugs with the game, unless more arise. I'd be grateful to any advice that people can put out on these subjects.

Link to Space Game and code download:
http://scratch.mit.edu/projects/SD7/2377273


http://img834.imageshack.us/img834/4411/signaturespacegame2.png

Offline

 

#2 2012-03-07 16:00:18

turkey3
Scratcher
Registered: 2011-12-04
Posts: 500+

Re: Help making Space Game

I don't think it's possible to duplicate sprites in game. Maybe in scratch 2.0 you'll be able to

Last edited by turkey3 (2012-03-12 15:27:03)

Offline

 

#3 2012-03-07 17:47:36

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Help making Space Game

SD7 wrote:

Hi I'm working on making a space game where the player commands a small yellow ship that moves along the x-axis at the bottom of the screen while fending off a variety of enemies. I'm running into some problems however with making some things work and figuring out how to do certain commands. This is what I need help with particularly:

1. What I'm trying to do is have a single sprite of each enemy type (red is standard, blue is more powerful, and black is a stealth suicide bomber) but have each one duplicate randomly within a set limit (ie the one Red ship sprite would duplicate 3-6 reds on screen at once, whereas the single blue sprite would only duplicate 1-2 blues). Is this possible or would I have to make all five red ships and have some of them "decide not to show up," that is, make a variable that determines whether the ship will begin to move in on the screen?

Cloning is currently impossible, but you could consider stamping all of the ships, and storing their orientation and position in a list.  If you're going to do that, I'd recommend putting all of that in a single sprite, so you can coordinate the "render, clear, render, clear" scripts way easier.  An example is my latest minesweeper game, in which one sprite prints all of the tiles, then clears and reprints every frame

2. I've just begun to code in destroying an enemy. But if you look at the uploaded project and try to fire a shot at the black enemy (the only one with code right now), you'll see it explodes and dies, but keeps moving and eventually the explosion goes away and it switches back to its "ship" costume. What I have set up is that when it's touching the player's laser, it explodes, but I realizes it only explodes WHILE the laser is touching, or a short time after. What I want it to do is if the player's laser hits it, it switches to the explosion costume, stops moving for a second so the explosion lingers, then disappears and resets to the top of the screen. Does anyone know code from that? I've tried a bunch of variations but nothing seems to work.


Doing stuff this advanced with pasted ships might be more trouble than it's worth, so I would recommend making every enemy ship its own sprite.  Then stick this in:

when gf clicked
forever
do movement
if <touching [laser]?>
explode
wait until respawn
respawn
end


3. Sort of in-line with 1, but with the lasers. I'd like to have the laser sprite duplicate so you can fire multiple shots at once rather than only one at a time. Again, same sort of thing as 1, so if there's a way.


Again, cloning is impossible in the current version of Scratch.  If you want to stamp the lasers, I'd recommend only one sprite to do it, though it would probably be easier to make each laser a sprite.


4. Working on the player's own death, I'm running into trouble. I'd like it work like this; if the player is hit by any laser he dies instantly (I want to counteract that by using a shield button that can only be activated for so long). When he dies, I want him to switch to an explosion costume and then stop everything. Two seconds AFTER you die, I'd like to show a "game over" message, with the two second lag added to make the player realize they died before shutting everything down.

when gf clicked
forever
movement
if<touching [red]?>
explode
wait (2) secs
broadcast [game-over]
wait (2) secs
broadcast [shut-down]
end
end
5. Lastly, is there any way to orient the layering of the sprites in the game, so that the lasers will show up behind the ships, and the "game over" message will show over everything?


Simply dragging a sprite in edit-mode will automatically bring it to the front.  Alternatively, you can use the [go to front] block and make the lasers "go to front" first, then the ships, and lastly the "game over" message.


And that should basically solve all the bugs with the game, unless more arise. I'd be grateful to any advice that people can put out on these subjects.

Link to Space Game and code download:
http://scratch.mit.edu/projects/SD7/2377273


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#4 2012-03-08 11:34:16

SD7
Scratcher
Registered: 2011-09-15
Posts: 100+

Re: Help making Space Game

Thanks. What exactly do the red blocks mean? Those don't exist in my list.... sorry, a little new. Still, the laser only touches it for a brief time, and then explosion continues to move in the direction the ship was going. I want it to get hit by the laser and STOP when it explodes, then reset. Any ideas?


http://img834.imageshack.us/img834/4411/signaturespacegame2.png

Offline

 

#5 2012-03-08 11:45:40

SD7
Scratcher
Registered: 2011-09-15
Posts: 100+

Re: Help making Space Game

I mainly need a script to make the sprite stop moving where it is.

Last edited by SD7 (2012-03-08 11:49:13)


http://img834.imageshack.us/img834/4411/signaturespacegame2.png

Offline

 

#6 2012-03-12 11:29:33

SD7
Scratcher
Registered: 2011-09-15
Posts: 100+

Re: Help making Space Game

So no more ideas on this?


http://img834.imageshack.us/img834/4411/signaturespacegame2.png

Offline

 

#7 2012-03-12 14:36:17

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: Help making Space Game

SD7 wrote:

Link to Space Game and code download:
http://scratch.mit.edu/projects/SD7/2377273

Post a link with

Code:

[url=URL HERE]Link Name[/url]

Meaning

Code:

[url=http://scratch.mit.edu/]Scratch Homepage[/url]

would make
Scratch Homepage

Offline

 

#8 2012-03-12 16:26:55

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Help making Space Game

SD7 wrote:

Thanks. What exactly do the red blocks mean? Those don't exist in my list.... sorry, a little new. Still, the laser only touches it for a brief time, and then explosion continues to move in the direction the ship was going. I want it to get hit by the laser and STOP when it explodes, then reset. Any ideas?

The red blocks are abbreviations/pseudo-code.  "move" means "stick your current movement script here".


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#9 2012-03-12 21:11:59

MaxFlyboy
Scratcher
Registered: 2011-11-07
Posts: 100+

Re: Help making Space Game

SD7 wrote:

Hi I'm working on making a space game where the player commands a small yellow ship that moves along the x-axis at the bottom of the screen while fending off a variety of enemies. I'm running into some problems however with making some things work and figuring out how to do certain commands. This is what I need help with particularly:

1. What I'm trying to do is have a single sprite of each enemy type (red is standard, blue is more powerful, and black is a stealth suicide bomber) but have each one duplicate randomly within a set limit (ie the one Red ship sprite would duplicate 3-6 reds on screen at once, whereas the single blue sprite would only duplicate 1-2 blues). Is this possible or would I have to make all five red ships and have some of them "decide not to show up," that is, make a variable that determines whether the ship will begin to move in on the screen?

no cloning yet, maybe in Scratch 2.0

2. I've just begun to code in destroying an enemy. But if you look at the uploaded project and try to fire a shot at the black enemy (the only one with code right now), you'll see it explodes and dies, but keeps moving and eventually the explosion goes away and it switches back to its "ship" costume. What I have set up is that when it's touching the player's laser, it explodes, but I realizes it only explodes WHILE the laser is touching, or a short time after. What I want it to do is if the player's laser hits it, it switches to the explosion costume, stops moving for a second so the explosion lingers, then disappears and resets to the top of the screen. Does anyone know code from that? I've tried a bunch of variations but nothing seems to work.

when gf clicked
forever
if <touching[myships laser v]>
explosion 
hide
wait <pick random (1) to (5)> secs
go to x: <pick random (-210) to (210)> y: (180)
end
end
3. Sort of in-line with 1, but with the lasers. I'd like to have the laser sprite duplicate so you can fire multiple shots at once rather than only one at a time. Again, same sort of thing as 1, so if there's a way.

No, no cloning yet

4. Working on the player's own death, I'm running into trouble. I'd like it work like this; if the player is hit by any laser he dies instantly (I want to counteract that by using a shield button that can only be activated for so long). When he dies, I want him to switch to an explosion costume and then stop everything. Two seconds AFTER you die, I'd like to show a "game over" message, with the two second lag added to make the player realize they died before shutting everything down.

Well, if the explosion is long enough you can just have it like this
when gf clicked
forever
if <touching[enemy laser v]>
explosion
wait (1) secs
switch to costume [game over v]
stop all
end
end
assuming of course, that you have a game over costume for the ship

5. Lastly, is there any way to orient the layering of the sprites in the game, so that the lasers will show up behind the ships, and the "game over" message will show over everything?

Yes, there is a
go back (1) layers
block that is built into scratch


And that should basically solve all the bugs with the game, unless more arise. I'd be grateful to any advice that people can put out on these subjects.

Link to Space Game and code download:
http://scratch.mit.edu/projects/SD7/2377273

All of the red blocks and such are ones that you should make yourself, or, ones that I do not know how to put into the scratchblocks

Last edited by MaxFlyboy (2012-03-12 21:15:59)


http://cdn.voodoofilm.org/images/upload/thumb/viral-video-2011.jpg click the picture for an AMV

Offline

 

#10 2012-03-13 11:53:33

SD7
Scratcher
Registered: 2011-09-15
Posts: 100+

Re: Help making Space Game

Ok, so there's no "respawn" code available? What I have set up is that if it's touching the player's shot, it will switch to the explosion costume for a second, then hide for two seconds, but while it's in the explosion, it continues to move around the random paths, rather than just blowing up and staying there. I just can't get a code that says "stop all movements." Sure, there's "stop script" but I want to the script to keep going- I just need it to stop moving for that brief second that it has exploded, and nothing I've tried seems to have that effect.
Also on a similar note the enemies sometimes continue to fire off lasers while they are dead. How can I get this fixed? (code linked in first post)






Splodgey wrote:

SD7 wrote:

Link to Space Game and code download:
http://scratch.mit.edu/projects/SD7/2377273

Post a link with

Code:

[url=URL HERE]Link Name[/url]

Meaning

Code:

[url=http://scratch.mit.edu/]Scratch Homepage[/url]

would make
Scratch Homepage

You realize in the time it took you to tell a completely competent person how to do something he already knows, you could have just copied the url into a new tab? I just did that in two seconds, as opposed to the two minutes you took to explain it. And again, I know full well how to apply basic codes like that.


http://img834.imageshack.us/img834/4411/signaturespacegame2.png

Offline

 

#11 2012-03-13 12:01:59

SD7
Scratcher
Registered: 2011-09-15
Posts: 100+

Re: Help making Space Game

Oh, and another thing, is there any command that makes it so it performs a certain script once upon touching something, rather than constantly whilst touching it?
Example, IF->laser has TOUCHED enemy
-----------------> then, change score by 1, etc.

Right now, the current code makes it so that as long as the player's laser is touching an enemy the score continues to rise, so rather than getting 1 point for hitting a red enemy, you get about 20, because it keeps upping the score while the laser is in contact. Can I make it so it only runs the script once upon meeting the conditions of touching an enemy?


http://img834.imageshack.us/img834/4411/signaturespacegame2.png

Offline

 

#12 2012-03-13 12:26:25

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: Help making Space Game

SD7 wrote:

Ok, so there's no "respawn" code available? What I have set up is that if it's touching the player's shot, it will switch to the explosion costume for a second, then hide for two seconds, but while it's in the explosion, it continues to move around the random paths, rather than just blowing up and staying there. I just can't get a code that says "stop all movements." Sure, there's "stop script" but I want to the script to keep going- I just need it to stop moving for that brief second that it has exploded, and nothing I've tried seems to have that effect.
Also on a similar note the enemies sometimes continue to fire off lasers while they are dead. How can I get this fixed? (code linked in first post)






Splodgey wrote:

SD7 wrote:

Link to Space Game and code download:
http://scratch.mit.edu/projects/SD7/2377273

Post a link with

Code:

[url=URL HERE]Link Name[/url]

Meaning

Code:

[url=http://scratch.mit.edu/]Scratch Homepage[/url]

would make
Scratch Homepage

You realize in the time it took you to tell a completely competent person how to do something he already knows, you could have just copied the url into a new tab? I just did that in two seconds, as opposed to the two minutes you took to explain it. And again, I know full well how to apply basic codes like that.

Then why not use it? Don't criticize people trying to help...  hmm

Offline

 

#13 2012-03-13 15:44:33

SD7
Scratcher
Registered: 2011-09-15
Posts: 100+

Re: Help making Space Game

You're not helping with the code, you're filling up this page with things that don't apply to what I'm trying to work on. Even if you thought making a physical link in the text was so necessary, you should have send it via a private message or other means.


http://img834.imageshack.us/img834/4411/signaturespacegame2.png

Offline

 

#14 2012-03-13 15:49:11

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: Help making Space Game

SD7 wrote:

You're not helping with the code, you're filling up this page with things that don't apply to what I'm trying to work on. Even if you thought making a physical link in the text was so necessary, you should have send it via a private message or other means.

Oh well I'm sorry(!)  hmm

Offline

 

#15 2012-03-13 20:22:31

MaxFlyboy
Scratcher
Registered: 2011-11-07
Posts: 100+

Re: Help making Space Game

For the pausing movement, it would take a while. You would have to have a "stop movement?" variable and put if's in all the movement. If someone who knows what I'm talking about please explain it more.


http://cdn.voodoofilm.org/images/upload/thumb/viral-video-2011.jpg click the picture for an AMV

Offline

 

#16 2012-03-13 22:26:09

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Help making Space Game

MaxFlyboy wrote:

For the pausing movement, it would take a while. You would have to have a "stop movement?" variable and put if's in all the movement. If someone who knows what I'm talking about please explain it more.

Put every other script that can possibly move the sprite into an if statement:

if<(can i move?) = [true]>
move
end
Then, to make it stop moving, just set "can i move?" to "false" (or any value other than true).


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#17 2012-03-14 05:12:32

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: Help making Space Game

MoreGamesNow wrote:

MaxFlyboy wrote:

For the pausing movement, it would take a while. You would have to have a "stop movement?" variable and put if's in all the movement. If someone who knows what I'm talking about please explain it more.

Put every other script that can possibly move the sprite into an if statement:

if<(can i move?) = [true]>
move
end
Then, to make it stop moving, just set "can i move?" to "false" (or any value other than true).

better if multiple movements are in 1 script;

repeat until <whatever> //or whatever the repeat stuff is...
move
other move
if <(can i move?) = [false]>
wait until <(can i move?) = [true]>
this time it has to be "true" or "false".

Last edited by Splodgey (2012-03-14 05:13:26)

Offline

 

#18 2012-03-15 11:35:08

SD7
Scratcher
Registered: 2011-09-15
Posts: 100+

Re: Help making Space Game

Tried what you suggested and it still won't stop moving. I think it may be due to the complete overriding command that I have set up (although I don't know why it's word is law)
What I have set up to make the enemy ships move randomly across the screen is
Glide [5] seconds to x=[random -250 to 250] y=[random -100 to 250]
so they constantly buzz around in the space above the player. But that commands seems to overwrite anything else I try to tell it. Is there a way to make it not overwrite or a better movement command I could use?

Thanks for any help


http://img834.imageshack.us/img834/4411/signaturespacegame2.png

Offline

 

#19 2012-03-15 11:52:39

SD7
Scratcher
Registered: 2011-09-15
Posts: 100+

Re: Help making Space Game

Actually it stops moving but won't explode, and won't stop for about 3 seconds. I don't know what wrong. If anyone has to the time to download the code and tell me what the hell is wrong....


http://img834.imageshack.us/img834/4411/signaturespacegame2.png

Offline

 

#20 2012-03-15 13:07:40

SD7
Scratcher
Registered: 2011-09-15
Posts: 100+

Re: Help making Space Game

Ok, unless anyone can download this and offer some insight, I don't know what else to do to fix it.

http://scratch.mit.edu/projects/SD7/2377273


http://img834.imageshack.us/img834/4411/signaturespacegame2.png

Offline

 

#21 2012-03-15 18:23:21

itsmomito
Scratcher
Registered: 2008-03-28
Posts: 100+

Re: Help making Space Game

Hey SD7,

I'll take a look at the code and help you out  smile  I'll post again with my thoughts later.  smile

Offline

 

#22 2012-03-15 19:35:03

itsmomito
Scratcher
Registered: 2008-03-28
Posts: 100+

Re: Help making Space Game

Yay! I fixed a bunch of the errors:

1) No game over when you start the game on accident. This happened because the enemy lasers did not reset their positions before the game over script. Fixed with a wait .5 sec in the game over script

2) Sprite explosions keep moving is fixed. Instead of changing costume to explosion and waiting a small time, they now stamp the explosion and then hide while they move. :)

3) All enemy lasers used to hide on the destruction of one enemy, fixed with three separate broadcasts

4) Enemy ships used to not die when the laser touches them. Now they do

5) Player's laser script is fixed so that when it touches the edge, it returns. This eliminates killing enemies when you didn't really kill them.

6) I also modified some of the numbers :)

Well, I hope all this is okay with you. If you ever need any help, just ask :) I uploaded the project here:  http://scratch.mit.edu/projects/itsmomito/2399670

If you would like, I can help you add the duplicate shots, layer corrections or whatever else. Check the comments to see what I changed and why.

Last edited by itsmomito (2012-03-15 19:37:59)

Offline

 

Board footer