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

#1 2008-08-22 17:25:31

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Tip & Tricks: Your first game (tutorial)

I know when I started Scratch, it seemed really confusing. It's not. I'll be posting a simple game here. Lets make it a shooting games with enemies, a stationed gun in the center, and bullets. This first posts will break down and show you the gun script.

Make a new sprite (under the white stage area there is a button to bring up the paint editor). Make your gun and hit OK. Now add this script to it:

<when green flag clicked>
<forever>
<point towards( mouse pointer
<if><key[ space  ]pressed?>
<broadcast[ shoot
<end>
<end>

This will make your gun aim at the mouse pointer (or perpendicular if you drew your gun facing up not to the right). Whenever you press space, you will shoot (once you add the bullet scripts). Now the breakdown:

<when green flag clicked>
<forever>
<end>

So what does that do? Well, that starts your game.

<when green flag clicked>  is when your game is fully loaded in the Java player, or
when you click the green flag in the Scratch program. You need it to start your game/animation

<forever>
<end>        What this is is a forever loop. It is kinda self explanatory. Forever, this will
happen. In this case, it will always point towards your mouse pointer.

<if><key[ space  ]pressed?>
<broadcast[ shoot
<end>                       In a forever loop, this will keep checking whether this is true or
not. If it is true (you press space) you will shoot. What is that broadcast thing there though? Well, think of it like an intercom. When someone talks in an intercom at school, each classroom can hear. In this case, each classroom is a sprite, so you send a message to each sprite. I'll talk about how to hear that message over the intercom later.

Last edited by Bluestribute (2008-08-22 21:18:06)


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#2 2008-08-22 21:17:35

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: Tip & Tricks: Your first game (tutorial)

O.K., time for ammo. Put these scripts on a new sprite called ammo (after you draw it in the paint editor):

<when green flag clicked>
<hide>

<when I receive[ shoot
<go to[ gun
<point in direction( direction of gun
<show>
<repeat until><< <touching[ edge  <or> <touching[ enemy  >>
<move( 10 )steps>
<end>
<hide>

Now for the breakdown of some new blocks:

<when I receive[ shoot    Remember when we broadcasted shoot, and I used the intercom analogy? Well, you can't hear the intercom without it being on, and this is how. With this block, you have now turned on the intercom so you can say "Oh, time to shoot".

<repeat until>    Repeat until that condition is true. In this case, touching the edge or enemy

Those are really the blocks you will need to know- the control blocks. The others are self explanatory


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#3 2008-08-23 22:42:01

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: Tip & Tricks: Your first game (tutorial)

Now for a hitTest on the enemy (not movement, just to see whether it got shot):


<when green flag clicked>
<show>
<forever>
<wait( <pick random( 1 )to( 5 )secsc>
<show>
<if><touching[ bullet
<hide>
<wait( <pick random( 1 )to( 5 )secsc>
<show>
<end>
<end>

See, very simple


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#4 2008-08-24 07:06:18

matthewjose
Scratcher
Registered: 2008-07-16
Posts: 100+

Re: Tip & Tricks: Your first game (tutorial)

Thanks for posting this guide  smile   smile  I made something out of this guide! SEE IT: http://scratch.mit.edu/projects/matthewjose/248855 Thanks for always being a helpful scratcher!


My chat room, and join a Critique Group for feedback on your projects.

Offline

 

#5 2008-08-24 08:48:20

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: Tip & Tricks: Your first game (tutorial)

matthewjose wrote:

Thanks for posting this guide  smile   smile  I made something out of this guide! SEE IT: http://scratch.mit.edu/projects/matthewjose/248855 Thanks for always being a helpful scratcher!

Cool! I'll look at it later, cause I can't right now. Anyways, I'll post enemy moving later


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#6 2008-08-24 13:17:16

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: Tip & Tricks: Your first game (tutorial)

OK, enemy movement time! This is the most basic of AI's cause I am really bad at them (artificial intelligence or Computer Player), but anyways, I used this method for my Turret game:

<when green flag clicked>
<hide>
<forever>
<wait( <pick random( 1 )to( 5 )secsc>
<go to x sad  Where you want )y sad  Where you want
<point towards( player
<show>
<move( 10 )steps>
<end>

That should be the movement script, though I'll need to see if it is correct…
Later I'll show you how to add this script to your hitTest

Last edited by Bluestribute (2008-08-24 13:17:39)


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#7 2008-08-24 17:52:04

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: Tip & Tricks: Your first game (tutorial)

Ok, to add the above script to your hitTest, do this:

<when green flag clicked>
<hide>
<forever>
<wait( <pick random( 1 )to( 5 )secsc>
<go to x sad  starting X )y sad  starting Y
<point towards( player
<show>
<move( 10 )steps>
<if><touching[ bullet
<hide>
<go to x sad  starting X )y:(starting Y
<wait( <pick random( 1 )to( 5 )secsc>
<show>
<end>
<end>

That should work. And theres your first game- a shoot 'um up


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

Board footer