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...
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 showI still don't have it right... Let me just get some infomation on this.
Last edited by Paddle2See (2012-06-07 08:14:16)
Offline
when gf 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 v]?> change [score v] by (5) hide wait (5) secs showFixed your scripts
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.
when gf 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 endIt'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
zammer990 wrote:
when gf 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 end if <touching [sprite 1 v]?> change [score v] by (5) set [time shown v] to [3] hide wait (5) secs showFixed your scripts
I fixed the above script, but it still needs this script to work.
when gf clicked wait [5] secs forever set [time shown v] to [0] repeat until <(time shown) = [3]> wait [1] secs if <(time shown) < [3]> change [time shown v] by [1] end end wait [5] secsThis 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)
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:
when gf clicked hide wait (5) secs go to x: (pick random (-220) to (220)) y: (pick random (-220) to (220)) show wait (3) secs hidePlug that in and it should work!
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:
when gf clicked forever if <touching [sprite 1 v] ?> change [score v] by (5) hide wait (5) secs show end
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