Constants
A constant is a data structure can hold one piece of data. Once set, the data never changes
Referencing Data with Constants
Constants are good for referencing data that you never expect to change.
Screen Size Example
For example, if you set your game's resolution once, and never expect it to change, it's a good idea to store it in a couple of constants for easy reference.
; create constants
Constant SCREEN_WIDTH = 800
Constant SCREEN_HEIGHT = 600
; open a game window
OpenScreen SCREEN_WIDTH, SCREEN_HEIGHT, 32, 1
; wait for the player to press a key
WaitKey
MAX_NUMBER Example
Constants are also useful for using as the end value of a For Loop Loop where you have stored your game objects or particles in an array and have written your engine to handle an maximum number of game objects / particles.
Related Pages
Links
- Constant at the PlayBasic Wiki
| Categories: Data : Data Structures : Programming |
page_revision: 5, last_edited: 1237658581|%e %b %Y, %H:%M %Z (%O ago)