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

#1 2008-07-11 21:51:45

programminglover
Scratcher
Registered: 2008-07-11
Posts: 7

New Block

I think that it would be most useful for a <repeat until> block. You see I am making a tank game where I would like the bullet you shoot to come back to the tank and keep up with it but in order to do this I have to make forever go to sprite 2. But I want the bullet to move away from it when you press space.

Offline

 

#2 2008-07-11 21:54:35

deatheater
Scratcher
Registered: 2008-04-11
Posts: 1000+

Re: New Block

<when green flag clicked>
<forever>
<go to[ sprite 2
<if> <key[ space ]pressed?>
<repeat until> <touching[ edge
<move( 5 )steps>

Offline

 

#3 2008-07-12 03:15:56

registeel
Scratcher
Registered: 2008-04-27
Posts: 500+

Re: New Block

their is a repeat until block  tongue

Offline

 

#4 2008-07-12 15:27:13

Kingdaro
Scratcher
Registered: 2008-06-08
Posts: 100+

Re: New Block

Try this:
[blocks]
<when green flag clicked>
<go to[ Sprite2 (so it starts there)
<forever>
<if> <key[ space ]pressed?> (space to launch the bullet)
<point towards( mouse-pointer (use the mouse to aim)
<repeat until> <touching[ edge
<move( 5 )steps> (keep moving until touching the edge)
<end>
<if> <touching[ edge (when touched the edge...)
<go to[ Sprite2 (go to Sprite2)
<end>
<wait until> <key[ space ]pressed?> (so you can do it again.)
<end>
<end>
[/blocks]
I put it in words so you don't get confused.
It's complicated, but it works. I used it in my Oncoming game and my City Attack game.

Last edited by Kingdaro (2008-07-13 14:52:44)

Offline

 

#5 2008-07-12 15:30:19

Kingdaro
Scratcher
Registered: 2008-06-08
Posts: 100+

Re: New Block

deatheater wrote:

<when green flag clicked>
<forever>
<go to[ sprite 2
<if> <key[ space ]pressed?>
<repeat until> <touching[ edge
<move( 5 )steps>

[/blocks]
Where it says [blocks] <go to[ Sprite2 [/blocks] It'll keep doing that forever. So you have to make an "Unless" rule to say NOT to do that if the space key is pressed.

Last edited by Kingdaro (2008-07-12 15:30:54)

Offline

 

#6 2008-07-12 17:56:31

deatheater
Scratcher
Registered: 2008-04-11
Posts: 1000+

Re: New Block

Kingdaro wrote:

deatheater wrote:

<when green flag clicked>
<forever>
<go to[ sprite 2
<if> <key[ space ]pressed?>
<repeat until> <touching[ edge
<move( 5 )steps>

[/blocks]
Where it says [blocks] <go to[ Sprite2 [/blocks] It'll keep doing that forever. So you have to make an "Unless" rule to say NOT to do that if the space key is pressed.

yes it will forever go to sprite 2 until key space pressed then it will repeat until hitting the wall then go to sprite 2 again

Offline

 

Board footer