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

#1 2012-06-07 07:17:53

Jo_WhizzkidsIT
New Scratcher
Registered: 2012-05-14
Posts: 7

Disappearing Target

Hi all, I'm designing a game in which the player is a shark trying to eat all the little fish.  I have little fish sprites that swim around until they are eaten.  They then disappear and reappear a few seconds later and continue in this manner until the game is over.  I also have two poison fish that will trigger Game Over if you try to eat them.  So far so fun.

The next step I took was trying adding another sprite that is a bonus sprite.  If you eat the bonus sprite you get five points instead of one.  It is designed to wait longer before reappearing than the other small fish.  All this is working fine too. 

My problem is this: I want to make it so that if you don't get to the bonus fish within 3 seconds it dissappears.

I'm still trying to get the hang of writing scratch blocks so I hope you don't mind if I just try to explain in layman's terms what I have:

when gf is clicked
hide
wait (5) seconds
go to x :(pick random -220 to 220) y:(pick random -220 tp 220)
show
forever
move 2 steps
if on edge bounce
if (touching <sprite 1>)
   change (score) by (5)
    hide
    wait (5) seconds
    show

This script means that the bonus fish will just swim around until it is eaten by sprite 1.  If anyone could explain how I could make this fish, if not eaten, dissappear after three seconds and then reappear again after five seconds I would appreicate it.  I've tried a few variations but nothing seems to be working for me.
(Sorry again about the messy script - I'll get the hang of it eventually!)

Offline

 

#2 2012-06-07 07:42:56

Jupitar
New Scratcher
Registered: 2012-06-05
Posts: 27

Re: Disappearing Target

Jo_WhizzkidsIT wrote:

Hi all, I'm designing a game in which the player is a shark trying to eat all the little fish.  I have little fish sprites that swim around until they are eaten.  They then disappear and reappear a few seconds later and continue in this manner until the game is over.  I also have two poison fish that will trigger Game Over if you try to eat them.  So far so fun.

The next step I took was trying adding another sprite that is a bonus sprite.  If you eat the bonus sprite you get five points instead of one.  It is designed to wait longer before reappearing than the other small fish.  All this is working fine too. 

My problem is this: I want to make it so that if you don't get to the bonus fish within 3 seconds it dissappears.

I'm still trying to get the hang of writing scratch blocks so I hope you don't mind if I just try to explain in layman's terms what I have:

when gf is clicked
hide
wait (5) seconds
go to x :(pick random -220 to 220) y:(pick random -220 tp 220)
show
forever
move 2 steps
if on edge bounce
if (touching <sprite 1>)
   change (score) by (5)

    hide
    wait (5) seconds
    show

This script means that the bonus fish will just swim around until it is eaten by sprite 1.  If anyone could explain how I could make this fish, if not eaten, dissappear after three seconds and then reappear again after five seconds I would appreicate it.  I've tried a few variations but nothing seems to be working for me.
(Sorry again about the messy script - I'll get the hang of it eventually!)

I'll answer your question in a minute... Let me just fix the blocking so it's easier to understand...

when gf is clicked
hide
wait
5
seconds
go to x :
pick random -220 to 220
y:
pick random -220 tp 220
show
forever
move 2 steps
if on edge bounce
if
touching <sprite 1>
change
score
by
5
hide
wait
5
seconds
show

I still don't have it right... Let me just get some infomation on this.  smile

Last edited by Paddle2See (2012-06-07 08:14:16)

Offline

 

#3 2012-06-07 07:45:25

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Disappearing Target

when clicked
hide
wait
5
secs
go to x:
pick random
-220
to
220
y:
pick random
-220
to
220
show
forever
move
2
steps
if on edge, bounce
if
touching
sprite 1
?
change
score
by
5
hide
wait
5
secs
show

Fixed your scripts

Last edited by zammer990 (2012-06-07 07:46:08)


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#4 2012-06-07 07:46:24

Jupitar
New Scratcher
Registered: 2012-06-05
Posts: 27

Re: Disappearing Target

I'm afraid I don't know the answer as I can't exactly understand. But - I won't give up! Here is a good tool to use. Scratch Wiki. I'm sure someone will give you an answer, in the meantime I'll try to work it out.

Offline

 

#5 2012-06-07 07:54:55

Jo_WhizzkidsIT
New Scratcher
Registered: 2012-05-14
Posts: 7

Re: Disappearing Target

Thanks guys - zammer990 you got the script exactly.  I'll post again in a while and show what I've tried to do.

Offline

 

#6 2012-06-07 08:29:22

Jo_WhizzkidsIT
New Scratcher
Registered: 2012-05-14
Posts: 7

Re: Disappearing Target

So this is what I've tried to get the sprite to either be eaten or disappear.

when clicked
hide
wait
5
secs
go to x:
pick random
-220
to
220
y:
pick random
-220
to
220
show
if
touching sprite 1
change
score
by
5
hide
wait
5
secs
show
else
wait
3
secs
hide
wait
5
secs
show

It's not working - I haven't had much success understanding the If - Else block so I'm assuming this is where I'm falling down.

Offline

 

#7 2012-06-07 09:10:06

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Disappearing Target

zammer990 wrote:

when clicked
hide
wait
5
secs
go to x:
pick random
-220
to
220
y:
pick random
-220
to
220
show
forever
move
2
steps
if on edge, bounce
if
time shown
=
3
hide
wait
5
secs
if
touching
sprite 1
?
change
score
by
5
set
time shown
to
3
hide
wait
5
secs
show

Fixed your scripts

I fixed the above script, but it still needs this script to work.

when clicked
wait
5
secs
forever
set
time shown
to
0
repeat until
time shown
=
3
wait
1
secs
if
time shown
<
3
change
time shown
by
1
wait
5
secs

This will work if you have both scripts in the bonus sprite, it will appear 5 seconds after the flag is clicked, and stay up for three, or until it is touched, then dissapear.

Last edited by sonicfan12p (2012-06-07 09:15:18)


Why are the secret organizations getting all the attention?  mad

Offline

 

#8 2012-06-07 11:15:57

Jo_WhizzkidsIT
New Scratcher
Registered: 2012-05-14
Posts: 7

Re: Disappearing Target

Thank you so much sonicfan12p - I'm not great with variables so it had me stumped.  Would it be really cheeky to ask how to make this bonus sprite reappear continually? I want this bonus sprite to keep popping up intermittently, thereby giving extra chances to get extra points.

Offline

 

#9 2012-06-07 22:17:02

SOScratch
Scratcher
Registered: 2010-02-01
Posts: 100+

Re: Disappearing Target

Create a whole new script.
Here it is:

when clicked
hide
wait
5
secs
go to x:
pick random
-220
to
220
y:
pick random
-220
to
220
show
wait
3
secs
hide

Plug that in and it should work!

If not, the Scratch community is very nice so feel free to ask!

Last edited by SOScratch (2012-06-07 22:17:28)


-SOScratch
Scratch On!

Offline

 

#10 2012-06-08 03:43:22

JH1010
Scratcher
Registered: 2012-05-31
Posts: 1000+

Re: Disappearing Target

[scratchblocks]
when gf clicked
forever if <touching [sprite 1]>
change [score] by (5)
hide
wait (5) secs
show
end
[\scratchblocks]

Offline

 

#11 2012-06-08 04:02:31

PhirripSyrrip
Scratcher
Registered: 2012-02-11
Posts: 100+

Re: Disappearing Target

JH1010 wrote:

when clicked
forever if
touching
sprite 1
?
change
score
by
5
hide
wait
5
secs
show

fixed

Last edited by PhirripSyrrip (2012-06-08 04:02:56)


http://i46.tinypic.com/ao03lk.png

Offline

 

#12 2012-06-08 05:48:21

Jo_WhizzkidsIT
New Scratcher
Registered: 2012-05-14
Posts: 7

Re: Disappearing Target

Thanks to everybody who helped me out with this one. A comdinbation of all of the above helped me complete my game.  SOScratch your script reminded me to keep things simple.  I got rid of the long complicated script and stuck to basics.  Three very short scirpts later and my fishy is swimming happily.  Thanks for all your help peeps  smile

Offline

 

Board footer