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

#1 2008-01-23 19:12:05

AllScratchedUp
Scratcher
Registered: 2008-01-20
Posts: 47

How Do You Make It So You Can Shoot In Scratch?

I am making a game in where you are a spaceship, and you shoot enemies. But, I don't know how you make it so you shoot a lazer or anything at all. Please Help!!!!!!!!! :-(


"Sometimes I lie awake at night, and I ask, "Where have I gone wrong?" Then a voice says to me, "This is going to take more than one night.""-Charles Schultz
http://smileyjungle.com/smilies/violent23.gif http://smileyjungle.com/smilies/celebrate3.gif

Offline

 

#2 2008-01-23 19:28:56

rockie
Scratcher
Registered: 2007-11-18
Posts: 100+

Re: How Do You Make It So You Can Shoot In Scratch?

this is for the bullet:
<when[ space ]key pressed>
<go to[ spaceship
<point in direction( 90
<repeat until><touching[ edge
<move( 10 )steps>


No signature currently stored in profile.

Offline

 

#3 2008-01-23 19:57:53

AllScratchedUp
Scratcher
Registered: 2008-01-20
Posts: 47

Re: How Do You Make It So You Can Shoot In Scratch?

THANKS ROCKIE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


"Sometimes I lie awake at night, and I ask, "Where have I gone wrong?" Then a voice says to me, "This is going to take more than one night.""-Charles Schultz
http://smileyjungle.com/smilies/violent23.gif http://smileyjungle.com/smilies/celebrate3.gif

Offline

 

#4 2008-01-23 19:59:54

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: How Do You Make It So You Can Shoot In Scratch?

For shooting a laser, you can just change costumes to one that has the laser beam turned on.
You can use "color touching color" to see if the laser beam is touching a sprite.

Offline

 

#5 2008-01-24 17:37:23

AllScratchedUp
Scratcher
Registered: 2008-01-20
Posts: 47

Re: How Do You Make It So You Can Shoot In Scratch?

Also, how do you make more than one level? I never figured that out.


"Sometimes I lie awake at night, and I ask, "Where have I gone wrong?" Then a voice says to me, "This is going to take more than one night.""-Charles Schultz
http://smileyjungle.com/smilies/violent23.gif http://smileyjungle.com/smilies/celebrate3.gif

Offline

 

#6 2008-01-25 01:02:17

Agito
Scratcher
Registered: 2008-01-22
Posts: 3

Re: How Do You Make It So You Can Shoot In Scratch?

Instead of making the background your level, you draw your level by hand as a sprite and draw all other levels after that as costumes for that sprite.. Then when your character hits the end of a level, you can say switch to costume 2 or something and it will switch to another level that you drew.
For instance: When I recieve Area 2>switch to costume 2.

Offline

 

#7 2008-01-25 06:10:44

EdnaC
Scratcher
Registered: 2007-08-28
Posts: 100+

Re: How Do You Make It So You Can Shoot In Scratch?

The background can actually have costumes (just like sprites), so you can just change the background.  One easy way to do this is to watch the "x position" of your player sprite.  If the sprite gets near the right edge, you can switch the background costume and send the sprite to the other edge of the screen.  (It will walk off the right edge, then enter a new scene from the left side.)

In the Sprite:

If "x position" > 238
set x to ("x position" * -.95)
Broadcast "NextBackground"

In the Background:

If I receive "NextBackground"
next costume

You could go the other way by monitoring for x < -238 and broadcasting a message to the background to tell it to go to the previous costume.  Of course, you'll need to check to see that there is a next (or previous) background to "jump" to.

-MrEd

Offline

 

#8 2008-01-29 22:47:34

ILikeFood
Scratcher
Registered: 2008-01-29
Posts: 1

Re: How Do You Make It So You Can Shoot In Scratch?

The laser help was great for me, but I want to do something slightly more complicated: I have a character standing on the ground, and I want the bullet to appear at his front and then move in the direction that the cursor was pointing when it was clicked. How do I do that without having the bullet follow the mouse?

Offline

 

#9 2008-01-30 01:53:27

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: How Do You Make It So You Can Shoot In Scratch?

Hi ILikeFood,

you could let the bullet glide to the location of the mouse pointer.
In your bullet-sprite you could try scripting something like this:

[blocks]
<when green flag clicked>
<hide>
<forever if><mouse down?>
<go to x sad  <{ startX }> )y sad  <{ startY }>
<show>
<glide( 0.2 )secs to x sad  <mouse x> )y sad  <mouse y>
<hide>
<end>
[/blocks]

This script will make the sprite glide towards the position of the mouse at time it was clicked. Moving the mouse afterwards will not affect the movement's destination. To make the sprite go faster you could experiment with different values in the glide-block. For example, if you want the bullet to move at the same speed regardless of how far it has to go, you could replace the number in the glide block by the following expression:

[blocks]
(( 0.002 <*> <distance to[ mouse pointer ))
[/blocks]

Did that help?


Jens Mönig

Offline

 

Board footer