The sprite is a basic element intended to automatically carry out animations of moving objects. It is defined
as a sequence of pictures that alternate after a certain period (i.e. the animation is effectuated). The individual pictures are called animation phases. The picture appearance may be defined as being different for different movement directions or turning positions. A separate picture sequences are defined for the quiescent condition and for the movement.
By sprite declaration in the field of variables a sprite object is created that can be displayed in the program window. The sprite can be moved within the window, and its visibility can be switched on and off. By assigning a sprite to another sprite only the sprite appearance and sprite animation definition is transferred, not the information about its present state. It enables to redefine sprite appearance with preservation of its activity. Similarly, the comparison operation compares the sprite appearance object only, regardless of its instantaneous state.
During the sprite declaration in the field of variables dependent sprite variables are created defining the sprite's instantaneous state. Setting state variables when editing the program does not influence the initial state at the program start, the sprites being always invisible and having (0,0) coordinates, when the program is started.
The horizontal and vertical elements are numeric variables representing the sprite coordinates. By setting the variables the sprite movement to a specified coordinate is initiated (the lower left sprite corner being decisive). If the visibility is on, the movement will take place in the slow mode with animation. If the visibility is off, the movement will take place immediately. By reading the coordinates the instantaneous sprite position (even during the movement) can be found out. By setting the coordinates to their values found by reading (i.e. by assigning the coordinates to themselves) an immediate stoppage of the sprite will be provided.
element represents the direction of the sprite having been rotated. The direction is indicated in radian (the perigon of 360 degrees corresponding to approximately 6.28). This element can be utilized like a normal numeric variable. By using it in a numeric term the current direction of the sprite can be found. By using this element as a command the direction of the sprite can be set. At the same time the sprite direction is modified to equal the nearest value admissible pursuant to the definition of number of sprite directions. To facilitate the direction usage the predefined angle constants
can be made use of. Using these constants numeric operations (e.g. addition or division) can be carried out.
The visible element represents the flag of the sprite visibility. If the sprite is visible, its movement over the sheet is animated in compliance with the sprite definition. The sprite visibility being switched off, the sprite movements over the sheet take place immediately. The visibility element can be utilized like a normal logic variable, that means it can be tested or adjusted.
The moving element returns a logic flag informing, whether the sprite is moving, i.e. whether it is shifting to its preset target position. The stoppage of the sprite movement may be attained by setting the target coordinates to the instantaneous coordinate value (i.e. by assigning the coordinates to themselves).
The phase element indicates the future (i.e. not the current) phase of the sprite animation. The element can be utilized as a normal numeric variable; it can be read or adjusted. The phases are numbered from 0, and include phases for the quiescent state as well as those for the movement.
The state element serves as a state indicator of the object represented by the sprite. This element may be used as a numeric variable. By setting its value to 0 till 1 the state indicator is displayed above the sprite. As to the indicator color, the indicator is represented in green in the range from (including) 0.5 till 1, in yellow in the range from (including) 0.25 till 0.5, in red in the range from 0 till 0.25. By setting the state to -1 the state indicator will be switched off.
Full Html Context Help of The Peter - Gemtree Software & Children Programming