sprockets Learn to keyframe animate chains of bones. Gerald's 2024 Advent Calendar! The Snowman is coming! Realistic head model by Dan Skelton Vintage character and mo-cap animation by Joe Williamsen Character animation exercise by Steve Shelton an Animated Puppet Parody by Mark R. Largent Sprite Explosion Effect with PRJ included from johnL3D
sprockets
Recent Posts | Unread Content
Jump to content
Hash, Inc. - Animation:Master

Recommended Posts

  • Hash Fellow
Posted

Chapter 21 Break and Continue

Break and Continue give you ways to bypass instructions in a loop

When break is encountered the program skips to the end of the loop and regards the loops as finished

 

Exercise: copy your Week 10 X-maker program code to a new project and modify it with break so that it only prints a maximum of 10 Xs

Example output

Making Xs!


How many Xs do you want? 6

XXXXXX

How many Xs do you want? 2

XX

How many Xs do you want? 25

XXXXXXXXXX

How many Xs do you want? 57

XXXXXXXXXX

How many Xs do you want? 0


I'm done!

 

 

When continue is encountered, execution skips to the end of the loop, but then returns to the start of the loop and continues iterating the loop as before.

Exercise: Write a program that prints out a range of numbers and after each one prints "is not a multiple of 3"... unless the number IS a multiple of 3, for which it prints nothing after the number. Use continue to skip the that message.

Hint: This program probably makes some use of the modulo operation (%).

sample output:

Multiple of Three?

1 is not a multiple of 3.
2 is not a multiple of 3.
3
4 is not a multiple of 3.
5 is not a multiple of 3.
6
7 is not a multiple of 3.
8 is not a multiple of 3.
9
10 is not a multiple of 3.
11 is not a multiple of 3.
12
13 is not a multiple of 3.
14 is not a multiple of 3.
15
16 is not a multiple of 3.
17 is not a multiple of 3.
18
19 is not a multiple of 3.

@Roger @Shelton @Rodney

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...