O'Reilly logo

3D Game Programming for Teens, Second Edition by Eric Grebler, Maneesh Sethi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Goto Command

Before writing a full-fledged game, I want to introduce you to the concept of Goto. Goto is a very simple command, but it can be misused very easily, so I recommend using Goto as sparingly as possible. Almost always, if something can be done by using Goto, it can be done in another way.

Goto works like this: you add a label somewhere in your code, and Goto jumps to that label. (See Figure 2.12.) The best illustration of this is a sample program.

Figure 2.12. Using Goto.

;demo02-10.bb Demonstrates use of Goto .label Print "Hello" selection = Input("Enter 1 if you want me to repeat 'Hello' = => ") If (selection = 1) Goto label ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required