Discuss Scratch

Nutmeg2017
Scratcher
4 posts

chasey game

I am making a chasey game, my idea was to have a time limit that the shark has to try to tag the starfish with out going over the time limit of 30 secs.
If the shark doesn't get the star fish 10 times before the timer runs out the star fish wins, but if the the shark tags the starfish 10 times before 30 secs shark wins.
How do I code that?
Please help!!!
My game is Sharks Breakfast
hair444y
Scratcher
46 posts

chasey game

I'd recommend including a link instead of the name of the project. It makes the project more accessible.
Well if you already have the chasing scripts then here is what I suggest:

I'd start by having a script in the stage which acts as a timer:

whenclickedbroadcastStartwhenIreceiveStartsetTimeto30repeatuntilTime<1wait1secschangeTimeby-1

In the shark use the scripts:

whenclickedgotoStarting positionsetShark Scoreto0whenIreceiveStartrepeatuntilTime<1orSharkScore=10iftouchingStarfish?thenchangeShark Scoreby1Movingandsensingscriptshere...ifSharkScore=10thenSharkWinselsechangeStarfish Scoreby1ifStarfishScore=10thenStarfishWinselsebroadcastStart

In the star fish use these scripts:
whenclickedgotoStarting positionsetStar Fish Scoreto0whenIreceiveStartrepeatuntilTime<1orSharkScore=10Movingandsensingscriptshere...
I hope this works

Last edited by hair444y (July 31, 2017 11:13:53)

Nutmeg2017
Scratcher
4 posts

chasey game

Thankyou
hair444y
Nutmeg2017
Scratcher
4 posts

chasey game

Hi, this script is not working and it is the whole point of my game.
whenIreceiveStartiftouchingStarfish?thenchangeSharks Score by (1)
hair444y
Scratcher
46 posts

chasey game

Nutmeg2017 wrote:

Hi, this script is not working and it is the whole point of my game.
whenIreceiveStartiftouchingStarfish?thenchangeSharks Scoreby1
The problem is that the script is only running once as soon as Start is broadcasted.
Fix this by putting this in a loop:
whenIreceiveStartrepeatuntilTime<1iftouchingStarfish?thenchangeSharks Scoreby1
TheArcadeGuy
Scratcher
100+ posts

chasey game

Hi there, you may also want to add a wait until block to prevent the counter from going up if the shark is still touching the fish. Otherwise, the tally would go up instantly.

whenIreceiveStartrepeatuntiltime<1iftouchingStarfish?thenchangeSharks Scoreby1waituntilnottouchingStarfish?
Nutmeg2017
Scratcher
4 posts

chasey game

Thanks,
The Arcade Guy
and
Hair444y

Powered by DjangoBB