Methods and Procedures
Methods and procedures are code blocks with the functionality of receiving parameters and returning values. They are essential to every SCI game, and used throughout the entire execution of the game.
All code is either in a method or a procedure. Both have the same functionality, but procedures are not tied to objects. Methods are always members of an object.
Methods give objects functionality and the ability to perform tasks. They can take a virtually unlimited amount of parameters, and have the option of returning a value.
Every object in the template game has methods whether you realize it or not. This is because the base object, "obj", contains a number of them. If a class is derived from another class, it can be called with it's superclass' methods, even if they are not defined in the actual object.
(method (changeScore addScore)This example is a method called "changeScore" with one parameter, labeled"addScore".
(= gScore (+ gScore addScore))
(if (> addScore 0)
For more information on methods, have a look at the section in the SCI Studio help file .
Procedures are just like methods, but are not part of an object. They can take a virtually unlimited amount of parameters, and have the option of returning a value.
Though procedures can be built specifically for use with objects, they generally are not.
(procedure (IsPosOrNeg aNumber)This example is a procedure called "IsPosOrNeg" with one parameter, labeled"aNumber".
(if (< aNumber 0)
(return(> aNumber 0))
For more information on procedures, have a look at the section in the SCI Studio help file .
You should now have a general idea on what methods and procedures are. If you don't fully understand them yet, don't worry. Continue on with the tutorial, doing the step by step examples. When done, you should have a good grasp on them. If you still do not, come back to this chapter and read it again, and look at the links to the help file.