Just basic manual pdf

Thursday, May 30, 2019 admin Comments(0)

This manual describes the OASIS BASIC programming language interpreter/ re-entered to correct spelling or syntax errors, just modified to the correct form. ICTL for secondary school - just basic V module. 1. MODULE 1. INTRODUCTION TO instructions into code that the computer can understand and execute. Just BASIC free download. the help of a full tutorial and many example programs contained in this software package. aSkysoft PDF to HTML Converter .

Language: English, Spanish, Dutch
Country: Greece
Genre: Health & Fitness
Pages: 360
Published (Last): 08.01.2016
ISBN: 466-3-52075-323-6
ePub File Size: 23.36 MB
PDF File Size: 12.54 MB
Distribution: Free* [*Regsitration Required]
Downloads: 50796
Uploaded by: FLORENTINA

It is intended for educators and assumes that Just Basic is already installed on the computer. Most of this work is a summary of the tutorial to be found in the help . Just BASIC is a programming language for Windows. Create standalone Windows programs royalty free; Full tutorial and many example programs; Large . Programming: Just Basic Tutorials - Ebook download as PDF File .pdf), Text File .txt) Simple Programming with Just Basic Basic Instructions Just BASIC is a.

When a graphicbox is disabled. Window types: Any drawing that does not exist in a closed segment will not be redrawn when the window is repainted. These names can be the same. In the above case, the field lengths must total

When [Enter] is pressed as instructed, dummyVariable receives the value of what is entered. In this case, only [Enter] is pressed, so dummyVariable gets a value of zero for its data. It really doesn't matter what dummyVariable's data is since we don't use the variable in any calculations elsewhere hence the name dummyVariable.

So far, the only kind of variables we have used are for holding number values. There are special variables for holding words and other non-numeric character combinations. Let's look at a very simple program using strings: Once you've typed it and pressed [Enter], it responds with: It's nice to meet you, your-name-here Notice one special thing about our string variable name.

This makes it a string variable. As you can see from our program example, you can both input and print with string variables, as we did earlier with our non-string or numeric variables. We've actually been using strings all along, even before this section about string variables. This is a way to directly express a string in a BASIC program, exactly the way we type numbers directly in, only with characters instead.

A string literal always starts with a quotation mark and always ends with a quotation mark. No quotation marks are allowed in between the starting and ending quotation marks point: NOTE - A string can have zero characters. Such a string is often called an empty string. In BASIC, an empty string can be expressed in a string literal as two quotation marks without any characters between them.

Just as you can manipulate numbers in a computer programming language by adding, subtracting, multiplying, and dividing, and more! Comparing strings - We can compare strings with each other just as we can compare numbers. This means that we can use the if. When comparing strings, a string is considered to be equal to another string when all the characters in one string are exactly the same in both strings.

This means that even if they both print the same onto the screen, they can still be unequal if one has an invisible space on the end, and the other doesn't. Now that we've covered bringing data into your programs with input, displaying data with print, keeping data in string and numeric variables, and controlling program flow with if. Functions provide a means for manipulating program data in meaningful ways.

Look this short program: The len function returns the number of characters in a string. The expression inside of the parenthesis must either be a string literal, a string variable, or an expression that evaluates to be a string.

This identifies len as a string function. There are other string functions for example: The result returns is a number and can be used in any mathematical expression. There are numeric functions as well. The sin function takes the value of count enclosed in parenthesis and returns the sine a function in trigonometry, a branch of mathematics for that value.

Just like the len function above, cos and other numeric functions can be used as parts of bigger expressions. We will see how this works just a little further along. Notice also the way the program counts from 1 to Then the program prints the sine of count the sine of one, in other words. This happens over and over until count reaches a value of 45, and then it doesn't go back to [start] again, but instead having no more lines of code to run, the program stops.

Going back to execute code over again is called looping. We saw this earlier when we first used the goto statement. In our first use of goto, the program always looped back. In this newest example program we see going back to execute code over again, but based on a condition in this case whether count is less than This is called conditional looping you guessed it, the looping that always happens is called unconditional looping, or infinite looping.


When writing very short and simple BASIC programs, it isn't usually difficult to grasp how they work when reading them days or even weeks later. When a program starts to get large then it can be much harder. Since a variable name can be as long as you like and because Run BASIC lets you use upper and lower case letters, variable names can be very meaningful. For example if you are branching to a routine that displays help then use [help] as your branch label.

Or if you are branching to the end of your program you might use [endProgram] or [quit] as branch labels. The rem short for remark statement lets you type whatever you like after it you can even misspell or type gobbledy-gook, it doesn't care! Run BASIC just skips over these lines, but a human reader finds this kind of documentation very helpful. Also see the way that blank lines were added between the different parts of the program? These help to group things together, making the program easier to read.

A more elegant form of the rem statement uses the ' apostrophe, the key just to the left of the Enter key. Instead of typing rem, substitute the ' like so: One extra thing that you can do only with the apostrophe version of rem is to hang it off the end of whatever line you are commenting.

Ask again This optional, but it saves screen space and many prefer it. Learning to document the programs you write takes practice. Try to develop a consistent style. Everyone does it differently and there isn't a right or wrong way to do it. Very small programs may not need any documentation at all. Programs that you intend to share with others should probably be thoroughly documented. Now we will write a simple game using all of the concepts described in this tutorial.

These include: BAS Hi-Lo is a simple guessing game. The computer will pick a number between 1 and Our job is to guess the number in as few guesses as we can. When we guess, the computer will tell us to guess higher or to guess lower depending on whether we guessed too high or too low.

When we finally get it, the computer will tell us how many guesses it took. Let's outline how our program will work before we begin to write code: This can be a useful tool for planning out software before it is written, and it can be very helpful in developing ideas before code is actually written. We will document the code to explain its purpose: The [start] branch label is equivalent to calling this part of the program step Now we have the code that picks the number. We use two functions here to accomplish this task: The rnd function is the key to this line of code.

It picks a random or nearly random number greater than 0 and less than 1 for example 0. Then we add 1 to this. This is necessary because we want to pick a number as small as 1 and as large as The rnd function only gives us a number as large as 0. If you multiply 0. When we have picked the number, we assign its value to the variable guessMe. Notice the use of blank print statements to add space between the title and the instructions and after the instructions also.

What is your guess"; guess Here the branch label [ask] will let us go back here later if the user needs to be asked to guess again. Then we use the input statement to ask the user for a guess. The user's guess is then placed in the guess what else? Each time this code is performed, count's value will increase by one. If they are equal, then we goto [win], which is equivalent to.

If guess is less than guessMe, then display the text "Guess higher. If guess is greater than guessMe, then display the text "Guess lower. It took "; count; " guesses. The beep statement rings the terminal bell once. STEP can be used with both positive and and negative numbers and it is not limited to integer values. For more on While. For more on For. It will continue looping back and executing the code as long as the booleanExpr evaluates to true. The two examples below contains an "IF. THEN" evaluation that.

When it does this it makes a copy of itself. Here is an example of a subroutine which counts down from a number. A factorial is obtained by taking a number and multiplying it in turn by each integer less than itself. Care should be taken to avoid creating an endlessly looping recursive function.

This means that a function can call itself. The numbers get big in a hurry after this. The values are not overwritten.

It also specifies a routine to serve as an event handler. Here is a short example: The timer may be turned off and then back on. Most PCs have a timer with a resolution of approximately 56 milliseconds which ticks 18 times a second. The timer allows the addition of a clock to a program.

One second is milliseconds. There are other uses as well. Here are two literals. There is no practical limit to the length of a variable name. The second is a string of text characters.

Variables Previous Top Next See also: Numeric Variables. The variable names are uppercase and lowercase sensitive. In this example. The first is a number. String Literals and Variables. The value assigned to the variable name may change as the program runs. A variable name can start with any letter and it can contain both letters and numerals.

The program can always access the current value of the variable by refering to its name. The special system variables like WindowWidth. Arrays are dimensioned with the DIM statement. These can be defined as string or numeric arrays.

Learn More - Just BASIC

The extents of the dimensions can be in excess of 2 million elements. To access the value of an element in an array. The element is referred to by its index number. The element at index 2 in the following example is filled with "John. The index may be expressed as a literal number or as a numeric variable. It is still necessary to READ data into a variable.

To simulate an array of 10 by 10 by CHM 7. These methods can be used to put data into arrays. A DATA statement doesn't actually perform an action when it is encountered in the program's code.

The READ statement will fetch enough items to fill the variable names that the programmer specifies. The values fetched will be converted to fit the variables listed string or numeric. To fill arrays with DATA items.

It cannot be READ directly into arrays. Notice that in the examples above. If an end tag or flag of some sort is not used. This is an excellent way to prevent errors from occuring. Sequential Files. Binary Files. Files can be renamed with the NAME command. Binary Files Files opened for binary access may be read or written.

When a file is being read. Random Files Files opened for random access are read or written one record at a time. For detailed information on using binary files. The length of a file can be retrieved with the LOF function.

It is not possible to read or write a piece of data to the center of the file. For detailed information on using random files see Random Access Files. Random Access Files. String and Numeric Data All data. The length of records in the file is determined in the OPEN statement. Sequential files are opened with the OPEN statement.

When they are no longer needed, or when the program ends, they must be closed with the CLOSE statement. Sequential file access allows data to be read from a file or written to a file from beginning to end. Each subsequent input statement reads the next piece of data in the file. They cannot be written to. See Testing For File Existence. Example Program: INPUT item is: If the file does exist on disk, the previous contents will be overwritten, and therefore lost.

The carriage return may be suppressed by ending the line of code with a semi-colon. Writing data to the file works in the same way when a file is opened for APPEND as when it is opened for OUTPUT, but rather than overwriting data contained in the file, the new data is appended to the end of the file, but does not overwrite data previously written to the file the last time it was opened as open for OUTPUT does.

File Copy A file may be copied using sequential file operations.

Manual just pdf basic

Both files are then closed. Here is an example: To access a file in binary mode, it must be opened with the OPEN statement. When it is no longer needed, and before the program ends, it must be closed with the CLOSE statement.

Filedialog , File Operations , Path and Filename. In binary access mode, bytes are written to the file or read from the file as characters. Use the SEEK command to seek to the desired point in the file for reading or writing. This sets the file pointer to the location specified.

Use the LOC handle function to retrieve the current position of the file pointer. The current position of the file pointer is used when reading or writing data to a binary file.

Binary mode never writes line delimiters when printing to the file. The entire file is divided into many records. Each record has the same length. The length is specified when the file is opened with the LEN parameter. The example below opens a file called "members. OPEN "members. A record may be read or written anywhere in the file.

Pdf just basic manual

A record is written to the file with the PUT statement. These statements are explained in more detail below. Each field is designated by a variable name and given a specified length. When the lengths of all fields are added together, their sum must be equal to the length that was set with the LEN parameter in the OPEN statement. In the above case, the field lengths must total The fields for "members. If the length of a variable in a given field is shorter than the field length specified, blank spaces are added to pad it.

If the length of the variable is larger, it will be truncated to the length specified in the FIELD statement. Here is a short user-defined function which can be used to test if a file exists on disk. It is important to know if a file exists because attempting to access a nonexistent file can cause a program to crash. I need more power! Complete Path and Filename References to a complete path and filename indicate that the drive letter and all folders and sub folders are included in the file specification.

DocumentsProgramsbas Filename Alone. An example is as follows: Filenames are usually designated by including a dot and a file extension that specifies the type of file.

Filenames ending in ". Folders do not typically have extensions.

The names below with extensions indicate files, while the names without extensions indicate folders. Here are some examples of relative paths: Hard-coding Path and Filename The phrase "hard-coding" when referring to path and filename information indicates that the pathname specified in the progarm code contains the entire file specification, including the drive letter and all folder information as well as the filename.

If a program is meant for use by the programmer alone, on a single computer, this method works, as long as no changes are made to the directory structure. When any changes are made to the directory structure or filename, the program code must be changed as well. Caveat It is very unlikely that other users of a program will have the same directory structure on their computers as the programmer who writes the code. For this reason, it is best to use one of the other path naming options listed above that does not depend upon all users having the same directory structure on their computers.

Filenames Used in Code Some commands that use path and filename specifications are: Functions that require a numeric input can also use any of these forms, as long as the expression evaluates to a number. Here is the ABS function used as an example: Arithmetic Arithmetic operators are as follows: Order Expressions are evaluated in this order:.

A floating point value will be converted to an integer if its fractional part is zero when it is assigned to a variable. When first referenced, numeric variables equal 0. Values are assigned to variables with the equals sign. Adding 8 to it in the next line gives it a value of Negative numbers.

Just BASIC does not support changing the sign of a variable directly by preceding it with a negative sign "". The special system variables like WindowWidth, WindowHeight, etc. This function returns the square root of the number or numeric expressioin n. This function returns n the absolute value of n. This function returns the natural log of n.

This function removes the fractional part of number. Numbers such as 0. The function will always return an arbitrary number between 0 and 1. This function returns a random number between 0 and 1. The number parameter is usually set to 1. This function seeds the random number generator in a predictable way.

The seed numbers must be greater than 0 and less than 1. Trigonometry Previous Top Next Tip: The return value is expressed in radians. A formula to convert degrees to radians is: This function returns the arc tangent of the number or numeric expression n. This function returns the arc sine of the number or numeric expression n.

This function returns the arc cosine of the number or numeric expression n. This function returns the cosine of the angle n. The angle n should be expressed in radians. This function returns the sine of the angle n. The angle n should be expressed in radians Usage: This function returns a string expressing the result of numericExpression.

If not. If there are more digits contained in a number than allowed for by the template string. This function formats numericExpression as a string using templateString. The template string must be contained within double quotation marks. A template string looks like this: VAL stringExpression Description: The template string consists of the character " " to indicate placement for numerals.

The following two examples produce the same result: Some forms return a string. Text and Characters Previous Top Next This section of the help system explains the use and manipulation of text as literal strings of characters or as string variables. It also details commands for text windows and text editors. Hello World String Variables There are special variables for holding words and other non-numeric character combinations.

String Literals and Variables Previous Top Next Literal Strings A string literal always starts with a quotation mark and always ends with a quotation mark. Any other special symbols like: Letters of the alphabet. Such a string is often called an empty string. No quotation marks are allowed in between the starting and ending quotation marks.

Hello World. A string can have zero characters. Here is an example that prints a string literal in the mainwin. In the case of a CRLF as described here. The following code inserts a carriage return. To cause a double quotation mark to print. A combination of carriage return and line feed causes text printed after it to display on the next line down. It is also possible to use the semi-colon. If the starting parameter is included. If string2 occurs more than once in string1.

This function returns the position of string2 within string1. This function returns a one character long string. This function returns the length in characters of string. If number is 0. If number is zero or less. If number is greater than or equal to the number of characters in string.

If string is "hello there". This function returns a sequence of characters from the right hand side of string using number to determine how many characters to return.

This function permits the extraction of a sequence of characters from string starting at index. If number is not specified. Earth And: If number is specified. This function returns a copy of the contents of string. This can be useful for cleaning up data entry among other things. It is useful when producing formatted output to a file or printer. By default. The next time data is displayed. It is also possible to write rudimentary text mode programs. Here is a simple example: What's your name? To prevent the cursor from moving immediately to the next line.

This prevents the cursor from being moved down a line when the expressions are displayed. Here is how to set 40 columns and 20 rows: In the simple form input limit. If it is necessary to obtain input without a prompt and without a question mark.

Please enter the upper limit? Commas contained within quotation marks do not signal new columns. Here is a short demo: These coordinates refer to the column and row of text. Anything printed to a text window is displayed exactly as sent. To distinguish commands sent to a text window from text that is to be diplayed in the window. It is also possible to omit the word "print" and to omit the comma after the handle when printing to a text window or texteditor. They are used to force carriage returns when printing text.

Understanding Syntax. This means that the word "print" and the comma following the handle are optional. Using variables in text commands: Literal values are placed inside the quotation marks: When printing text.

The semicolon at the end of a printed command is now optional. BAT" for text as aetext open "C: BAT" for input as autoexec print aetext. This command clears the text window of all text. This command has two forms as described above.

This second form is useful for reading large text files quickly into the window. Here is an example of the second form: Here are the text window commands: Most of the commands listed below work with windows of type "text" and also with the "texteditor" control except where noted.

After this command is issued. This command returns a string either "true" or "false" that indicates whether any data in the text window has been modified. This command sets the font of the text window to the specified name and size. Returns the text at line n. In the code above. If an exact match cannot be found. For more on specifying fonts read How to Specify Fonts print handle. This is useful for checking to see whether to save the contents of the window before closing it.

If n is less than 1 or greater than the number of lines the text window contains. This command returns the number of lines in the text window. This command returns the entire text of the window. This command tells Just BASIC to continue execution of the program at branchLabel if the user double clicks on the system menu box or pulls down the system menu and selects "close.

This command causes the current text window origin to be returned. This causes Windows to give input focus to this control. This means that. This command forces the origin of the window to be row and column. The origin is the upper left corner of the texteditor or textwindow. This causes everything in the text window to be selected highlighted. Row and column must be literal numbers. This means that the row and column specified will appear in the upper left corner of the texteditor or text window.

To use variables for these values. When a text window is first opened. This command returns the highlighted text from the window.

The result is contained in the variables rowVar and columnVar. Graphics Previous Top Next See also: The segments which have been closed will be used to redraw the drawn graphics when the window needs to be repainted. The pen moves. Here is an example of a graphics window: The color that covers the control may be set.

Drawn Text Graphics commands include the ability to place text on the graphics control at the location desired. Any drawing that does not exist in a closed segment will not be redrawn when the window is repainted.

The pen can be up or down. Drawing operations are queued up into the current drawing segment. Possible drawing operations include: Turtle Graphics Turtle graphics are drawn by a pen that moves about the screen from one location to another. Turtle graphics are good for drawing graphics and iterative objects. The pen defaults to the up position. There are two kinds of controls that accept drawing commands.

Drawn Objects Objects such as boxes. If the pen is up. Color and Size The size width of the drawing pen may be set. There are two ways to delete these unwanted drawing commands. The first segment ID is 1. Each segment has a number. The number of the currently active segment is retrieved with the segment command: If drawing segments are not deleted. This method will not clear the graphics. CLS The simplest way to delete drawing commands is to issue the CLS command before new graphics drawing commands are issued: If the graphics window is maximized after the drawing is complete.

This is similar to the. Segment and Delsegment It is possible to delete any segments that are no longer needed. When a window is closed. Here is the world's smallest painting program! In order to capture keyboard input the graphics device must have focus. MouseY wait [letter] print w. When the leftButtonDown event happens the draw subroutine gets called. DisplayHeight draw "horizscrollbar on 0 ". Sometimes it is necessary to force the input focus using the setfocus command: When the leftButtonDown event happens the program branches to the [draw] routine.

Mouse coordinates are contained in MouseX and MouseY. DisplayWidth draw "down". When the characterInput event happens the keyCheck subroutine gets called. When the characterInput event happens the program branches to the [keyCheck] routine. Just BASIC allows mutliple commands to be listed in a single command statement if they are separated by semicolons. In order to draw. Most of these commands work only with windows of type graphics and with the graphicbox control.

When graphictext is designated by the use of the or character. It is not advisable to place controls within them. Here is an example using a graphics window: It should be noted that graphics windows and graphicboxes are intended for drawing graphics. The following example shows several graphics commands. If there is a need for text display within a graphicbox or graphics window. See below for more information. Using variables in commands: To use literal values.

It can no longer capture mouse and keyboard events. If an application continually draws raphics. To create a green blue color for example. If the user resizes the window. This means that any keypresses will be directed to the control.

To prevent this. This only works with display modes greater than colors. The cls. When a graphicbox is disabled. This storage function uses memory. Graphics commands in alphabetical order: To learn more about using sprites. When drawing to a graphics window or graphic box.

To create a violet color for example. Buttonface is the default background color currently set on a user's system. Here is a graphical representation of the named colors: The memory that was used by the drawn segment is reclaimed by the operating system. When the window is redrawn the deleted segment will not be included in the redraw. The segment command retrieves the ID number of the current segment.

See also the commands cls. The pen must be DOWN to cause graphics to be displayed. Each time a flush command is issued after one or more drawing operations. Each time a segment is flushed. The second form specifies a pure RGB color. This command reactivates the drawing process. Each segment of drawn items has an ID number. Discard does not force an immediate redraw. The ellipse is filled with the color specified using the command backcolor see above.

Zero degrees points to the right east. The control will not update its size and location until a refresh command is sent to the window. Without these parameters the default range is set to 0 and the width of the graphics view in pixels. BAS example program.

A large scrollbar range allows the graphics window to scroll a long distance. A line will be drawn if the pen is down. When no longer needed.

When turning on the scrollbar the optional parameters for min and max set the minimum and maximum scrollbar range in pixels these parameters do nothing when turning the scrollbar off. It resides in memory.

This is effective when the control is placed inside a window of type "window". If the value is "off". This assigned name can be used in later commands to manipulate the segment. If the value is "on". For more on specifying fonts read How to Specify Fonts Example: When printing a graphics window which has had the fill command applied. The pie slice will begin at angle1. When graphics will be sent to the printer. See DUMP. Use the DUMP command to cause printing to begin immediately.

No graphics will be drawn. Bitmap fonts stay at their native resolution when printing. Any items drawn since the last flush will not be redrawn either. It will scale the graphics based on the size they appear on the display monitor. Only TrueType fonts scale when printing. The size argument is optional and it not dependent upon the user's display resolution. Segment ID numbers are useful for manipulating different parts of a drawing.

Each additional in the text will cause a carriage return and line feed. It is also possible to use Windows constants to select a drawing rule as shown above. To get the segment ID of the last segment flushed. The text is located with its lower left corner at the pen position. Here are the constants that Windows defines: The default is 1. This will affect the thickness of lines and figures plotted with most of the commands listed in this section.

See Reading Mouse Events and Keystrokes. If the expression print handle. Example of turning off the leftButtonDown event handler: An event can also be the user pressing a key while the graphics window or graphicbox has the input focus see the setfocus command.

A can be positive or negative. MouseX and MouseY variables are passed into the designated subroutine. Sending "when leftButtonDown startDraw" to a graphics window or graphicbox tells the window to call the subroutine startDraw if the mouse is inside that window when the user presses the left mouse button.

These events occur when a user clicks. Controls and Events Sending print handle. It can however be reinstated at any time. The eventHandler can be a valid branch label or the name of a subroutine. Without these parameters the default range is set to 0 and the height of the graphics view in pixels. Any other drawing commands will simply be ignored until the pen is put back down. Whenever a mouse event is trapped. Whenever a keyboard event is trapped.

The values represent the number of pixels in x and y the mouse was from the upper left corner of the graphic window display pane. This provides a really simple mechanism for controlling flow of a program which uses the graphics window.

The graphicbox handle. If keyboard input is trapped. If a program needs graphicboxes that trap keyboard events. Sprite Commands What is a Sprite? User License: Using "1" will cause the list to cycle forward. This causes all visible sprites to be drawn on the background and it updates the display. This sets the background for sprites to be the loaded bitmap called BmpName.

This adds a sprite with name SpriteName from loaded bitmap called BmpName.

Basic manual pdf just

Using the optional "once" parameter will cause the sprite to cycle through its image list only one time. Using "-1" will cause the list to cycle backwards.

This causes the named sprite to be removed from the collection of sprites. This causes the sprite called SpriteName to be shown as the image from its image list called BmpNameX. This adds a sprite with name SpriteName from loaded bitmaps.. Sprite Commands Previous Top Next Only one graphicbox or graphics window in a program may use sprites.

This causes the sprite called SpriteName to be oriented in one of the four directions: SpriteName" input w. This causes the sprite called SpriteName to be visible if "on" is used. SpriteName x y" This obtains the coordinates of the sprite called SpriteName and places them into the variables x and y. What is a Sprite? Previous Top Next Here is a background image: Bitmaps are rectangular images.

Here is the bitmap of the frog. A program might need to put a picture of a hopping frog onto this background. Here is the picture of a frog: The frog is a bitmap also. When done with sprites. That doesn't look very convincing! It is possible to make it look like the frog is part of the picture by using sprites. How Do Sprites Work? Previous Top Next As was explained in the previous section. Realistic graphics require a way to place the image from a bitmap onto a background without including the image's own background.

The mask is directly above the sprite. There are two versions of the image. TO A mask has a white background. A mask is a black and white image. The shape of the image is the actual mask. It is not displayed on the screen in this form: Here is a mask for the frog image: This is a single bitmap: It is possible to add a mask to the sprite image using Paint. Add a mask here.

If this were to be done with an actual picture a piece paper. The mask is placed on the background bitmap in memory. This can be done with bitmaps. The programmer does not need to deal with these operations. This cutout could then be pasted onto the background.

To avoid flickering.

Programming: Just Basic Tutorials

When an entire frame of animation is built. The mask is now in place. The next layer adds the sprite. Here is an example. Only one graphicbox or graphics window in a program may use sprites. Note that simply setting the background bitmap does not cause the background image to display on the screen. The height of the bitmap is less than the height of the graphicbox.

CHM 0. See the section on Drawing and Collision Detection to find out about updating the display. If the height of the bitmap is less than the height of the graphicbox or graphics window.

The width of the following bitmap is greater than the width of the graphicbox. One way is to use a loaded bitmap as the background. The background image will be stretched to fit the given dimensions. If the width of the bitmap is less than the width of the graphicbox or graphics window. It is possible to create a graphicbox whose dimensions are much larger than the window that contains it. This command updates the display. Even if there are no sprites in use.

This example uses a graphicbox whose width is and height is The example gets the bitmap from the graphicbox at 0. To set a new bitmap called "mountains" as the background. Note that the width and height appear to be less than the width and height of the graphicbox.

None of the properties of the "guy" sprite change when the image is changed. The spritename is used to refer to this sprite when setting its properties. These names can be the same. It designates the NAME to give this sprite. Bitmaps can be used multiple times within one sprite designation. It is possible to have several different versions of a sprite image. For each frame of animation. The versions might look like this: Now the sprite with the NAME of "frog" contains three individual frog images.

When the image moves. To show any image from the list. The bitmaps for the frog look like this: The code to load them looks like this: Note that "frog2" is used twice here: Learn about updating the display in Drawing adn Collision Detection. In this manner. A frame of animation is built entirely offscreen.

A value of "1" will cause the sprite to cycle through all images in its list from first listed to last listed. To change the size of a sprite to be one and one-half times the width and height of the loaded bitmap: A value of "-1" will cause the sprite to cycle through all of its images in the reverse order from which they were listed. After the single cycle through frames. A value equal to one of the images in the list will cause the sprite to cycle to that image.

To cycle forward through all images: Sprites have several other properties that can be set by the programmer. This is useful for animations such as explosions. A percentage of will cause the sprite to appear twice the original width and height. It is easy to cause them to appear as a mirror image of the loaded bitmap.

The following command moves the sprite named "smiley" 5 pixels in the x direction and 2 pixels in the y direction each time a new animation frame is drawn. See the section on Drawing and Collision Detection! It is not possible to rotate 90 or degrees. Sprites can have alterations in both scale and orientation at one time.

The frog sprite has touched one of the bug sprites. The second line reports that "smiley" collided with "smiler" and "smiles" during that frame of animation. This command must be given each time it is necessary to draw another frame of animation. The sprite names are returned in a single string with spaces between them. If the background image is to be moved. The fourth line reports that "smiley" did not collide with any other sprites during that frame of animation.

If this were a game. See the section on backgrounds for more information. The third line reports that "smiley" collided only with the sprite named "smiler" during that frame of animation. Knowing this. It can be followed by an input statement. If a sprite is to be out of action for a time. Sprite graphics are temporary. Invisible sprites may be used to set up a screen area for collision detection. For instance. This might be done after a sprite collides with another sprite.

To learn about making sprite graphics remain in a graphicbox or graphics window. It looks like this in a program: If the sprites are part of an animated display. The "flush" command consumes memory. It is rarely necessary to flush animated graphics.

It first requires a command to: