Jump to content

Help With Scratch Program

CPT_BEEMO

Hey guys.

 

I enrolled in an online self paced course from Harvard University, CS50 Intro to Computer Science.

 

My problem set for this week's lecture is to make a basic program using Scratch, containing 2 sprites, min. 3 scripts, one condition, one loop, one variable and one sound. I am about halfway through programming a short game where a diver must click on fish to catch them. The score increases by one per fish caught. After the 2nd fish being clicked, a shark will appear and attempt to eat the diver.

 

 

Here's where things start to get a little tricky for me.

 

I am trying to figure out how to have the shark chase the diver (diver follows closely to cursor), cant seem to figure this out.

 

I am also trying to shorten the length of time from when a fish is clicked to when a new fish appears. I have adjusted the wait time from 3 seconds down to 0.5 and the length of time does not change.

 

Finally, I am trying to write the script so that when the shark touches the diver, the game is over, followed by a chomp sound. I have tried multiple different things to get this to work (specifically stoping all code when the shark touches diver) but I cannot seem to make it work the way I want it to.

 

Any help would be really appreciated. I attached the scratch file.

Scratch Project (1).sb3

CPU: Ryzen 7 3800X GPU: Reference 5700XT (Asus) Motherboard: Asus ROG Strix X470-F RAM: Corsair 32GB Vengeance 3600Mhz PSU: Corsair RM850X White

Cooling: Corsair H115i RGB Storage: 500GB WD SN750 M.2, 4TB Samsung EVO SSD Case: NZXT H500i White

Keyboard: Asus ROG Strix Flare (MX Red) Mouse: Corsair Sabre RGB

 

Link to comment
Share on other sites

Link to post
Share on other sites

idk what your code looks like but presuming there are no obstacles...

The shark just needs to move in the direction of the player.Since it's 2D I imagine it's going to have a very similar screen to the game "Fishy" where you eat smaller fish to get bigger.

 

If player is to the left, set shark to go left.

If player is above, set shark to go up.

 

Should get you going.

 

For fish spawning, you have to see how you're spawning fish. It might be somewhere in there.

 

I'm guessing it's not detecting collision. How do you check collision without a collision engine?

If distance between shark & player are less than n, shark got player.

 

You'll need to do some math, so I hope you're prepared.

Edit:
I'm not downloading any of your  files.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×