Fish Catch Game using MBLOCK

 

Code for Fish Sprite

blocks

Copy code

when green flag clicked

go to x: (pick random -240 to 240) y: (pick random -180 to 180)

show

forever

    glide (pick random 1 to 3) seconds to x: (pick random -240 to 240) y: (pick random -180 to 180)

end

 

when I receive [caught v]

wait (2) seconds

go to x: (pick random -240 to 240) y: (pick random -180 to 180)

show


Code for Net Sprite

blocks

Copy code

when green flag clicked

forever

    go to [mouse-pointer v]

end


 

Code for Catching Fish (Net)

blocks

Copy code

when green flag clicked

forever

    if <touching [Fish v]> then

        broadcast [caught v]

        hide

        play sound [pop v]

        change [Score v] by (1)

    end

end


Code for Scoring System

1.Create a variable: Score.

2.Place the following in the Net sprite:

blocks

Copy code

when green flag clicked

set [Score v] to (0)


 

 

Code for Timer (Optional)

1.Create a variable: Timer.

2.Place the following in the Net sprite:

blocks

Copy code

when green flag clicked

set [Timer v] to (30)

repeat until <(Timer) = (0)>

    wait (1) seconds

    change [Timer v] by (-1)

end

broadcast [game over v]


Code for Game Over

1.Add this to the stage or any sprite:

blocks

Copy code

when I receive [game over v]

stop [all v]

say [Game Over! Final Score: (Score)] for (2) seconds


Setup in mBlock

1.Add a Fish Sprite: Assign the fish-related code.

2.Add a Net Sprite: Assign the net-related code.

3.Create Variables: Add Score and Timer variables to track progress.

4.Test the Game: Run the game, catch fish, and check the score and timer.

 

Comments

Last 7 Days

Creating a Ping Pong Game in mBlock

Unit-1 Computer Network

Grade-3 (KEYBOARD)