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
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...
I still don't have it right... Let me just get some infomation on this.when gf is clickedhidewait5secondsgo to x :pick random -220 to 220y:pick random -220 tp 220showforevermove 2 stepsif on edge bounceiftouching <sprite 1>changescoreby5hidewait5secondsshow
Last edited by Paddle2See (2012-06-07 08:14:16)
Offline
Fixed your scriptswhenclicked
hidewait5secsgo to x:pick randomy:-220to220pick random-220to220showforevermove2stepsif on edge, bounceiftouchingsprite 1 ▼?changescore ▼by5hidewait5secsshow
Last edited by zammer990 (2012-06-07 07:46:08)
Offline
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
Thanks guys - zammer990 you got the script exactly. I'll post again in a while and show what I've tried to do.
Offline
So this is what I've tried to get the sprite to either be eaten or disappear.
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.whenclicked
hidewait5secsgo to x:pick randomy:-220to220pick random-220to220showiftouching sprite 1changescoreby5hidewait5secsshowelsewait3secshidewait5secsshow
Offline
zammer990 wrote:
Fixed your scriptswhenclicked
hidewait5secsgo to x:pick randomy:-220to220pick random-220to220showforevermove2stepsif on edge, bounceiftime shown=3hidewait5secsiftouchingsprite 1 ▼?changescore ▼by5settime shown ▼to3hidewait5secsshow
I fixed the above script, but it still needs this script to work.
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.whenclicked
wait5secsforeversettime shown ▼to0repeat untiltime shown=3wait1secsiftime shown<3changetime shown ▼by1wait5secs
Last edited by sonicfan12p (2012-06-07 09:15:18)
Offline
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
Create a whole new script.
Here it is:
Plug that in and it should work!whenclicked
hidewait5secsgo to x:pick randomy:-220to220pick random-220to220showwait3secshide
Last edited by SOScratch (2012-06-07 22:17:28)
Offline
[scratchblocks]
when gf clicked
forever if <touching [sprite 1]>
change [score] by (5)
hide
wait (5) secs
show
end
[\scratchblocks]
Offline
JH1010 wrote:
whenclicked
forever iftouchingsprite 1 ▼?changescore ▼by5hidewait5secsshow
fixed
Last edited by PhirripSyrrip (2012-06-08 04:02:56)
Offline
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
Offline