fn Main
will appear in the program code window.
endfn
This is the main function. All programs have a main function.
A program may have additional functions after the Main function.
All functions start with a line such as
fn AnyThing
and ends with a line
endfn
The Main function does not do anything yet.
A function does not do anything unless it has at least one line in he middle. A function can have any number of lines in the middle.
To make the program do something, add the line
print "Hello world"
Run the program by pressing the function key F5.
"Hello world" will be displayed in the output window (though without the quotation marks).
In the Help window you will see
3 lines executed. Program ended.displayed.
You can save your program by selecting Save from the File menu. The default name for your program is noname.ezy. Change this to hello.ezy. The suffix .ezy shows that this file is an Easy C program.
Quit the program by selecting Exit from the File menu.
Restart the program. Select Open from the File menu. A list of .ezy files will be displayed. Select hello.ezy. You will see the program code displayed.
You can test a program by pressing the function key F4. This does not run the program but will list any errors.
Pressing F2 causes all the lines within blocks of code to be indented. This makes code easier to read. Pressing Shift + F2 does the opposite.
Pressing F2 also causes certain words to change from lower case to titlecase. Titlecase uses a mixture of uppercase and lowercase letters. The first letter in a word is uppercase while the remaining letters are lowercase. If there are several words joined together then the first letter of each word is uppercase.
Pressing the enter key when the cursor is at the end of the line will complete a template. If the keywords fn, if or while are at the start of the line then endfn, endif or wend will be added on a new line.
F5 or the Run menu tests the program. If there are no errors then the program starts. If there are any errors then they will be displayed and the program will not run.
Selecting Debug puts you into Debug mode.
F6 allows you to quit a program if you wish to end it early.
When the program runs the statements are executed (the computer performs the instructions) in order.
code>
fn Main
print "Hello world" ' this is a comment
endfn
If you select open from the file menu you can run
one of the sample programs.
Double clicking on a word will display help
on it if it is available.
Tokens can be keywords, literals, operators,
variables, function calls, libray function calls etc.
In addition to keywords, you can create your own names.
Only certain letters can be used in names.
Names must start with a letter. Other characters can be numbers or letters.
Names cannot be keywords or names used in the function library.
Names can be used for variables, constants, arrays and functions.
A $ dollar can be placed at the end of a name to indicate its a string.
(The $ looks a bit like s, which is the first letter in the word string.)
There are 2 types of variables
Number variables, which can hold a positive or negative value.
String variables, which hold the value of a literal string.
A variable can be created by using the var keyword.
Assigning Values
You can give a variable a value by using an equals sign.
The plus symbol is the only mathematical symbol that can be used with strings.
The first token can be a keyword, variable (constant), libray sub call.
If the first token is a variable then the second token must be =
followed by what it is being assigned. This could be variables,
literals for function calls.
The first token cannot be a literal or operator.
Tokens can be keywords, literals, operators,
variables, function calls, libray calls etc.
The last token cannot be an operator.
A condition is either true or false. Conditions are comparisons
between two things. Comparison operators are used to compare the
left side and the right side.
The left side can be a variable or a function call.
The right side can be a variable or literal or a function call.
A decision always starts with an if statement and ends with an endif statement.
if condition is true
statements
else
statements
endif
A decision can include the else keyword. The else keyword can only be used within an
if...endif block. When else is used then either the statements before the else are
executed or the statements after the else are executed. There will always be some
staements in the block executed.
A decision can also include one or more elseif keywords.
elseif is followed by a condition, just like an if.
Like else, elseif can only used within an if...endif block.
it is possible to use else and elseif in the same if block.
Tokens
Each statement is composed of one or more
tokens. Tokens are seperated by spaces or commas.
Keywords
A programming language has its own special words called
keywords. Keywords are always in lowercase.
If a statement includes a keyword then the keyword is always the first word in the statement.
Some keywords are always on their own.
Other keywords always use other words.
Literal Strings
A literal string is any text within a pair of double quotes.
"Hello world"
is a literal string.
The quotes are not part of the string, but show where the string starts and ends.
Literal Numerics
A number like 187 is a literal numeric.
Operators
Operators are symbols that can act on variables and literal values.
These include the arithmetic operators:
The comparison operators:
The assignment operators:
Variables
A variable is something that can take on different values.
Its value varies.
var x
creates a number variable called x.
var a$
creates a string variable called a.
The $ is needed to show a is a string variable.
x = 1
gives x a value of 1.
a$ = "hello"
gives a$ a value of "hello".
Note that the = sign can be used in two different ways:
Arithmetic
You can use arithmetic with number variables.
x = x + 1 'adds one to x.
x = x - 1 'subtracts 1 from x.
x = x * 2 'multiplies x by 2.
x = x / 2 'divides x by 2.
Concatenation
You can join strings together by using the plus symbol.
a$ = "hello" + "world"
Constants
Constants are very like variables, except that they can never change their value.
Syntax
A keyword can only be the first token in a statement (though the first token could be something else).
Decisions
A decision means that the program will decide to execute a block of statements if a condition is true.
a = b
If a has the same value as b then the condition is true else it is false.
a <> b Is a not equal to b?
a > b Is a greater than b?
a < b Is a less than b?
a >= b Is a greater than or equal to b?
a <= b Is a less than or equal to b?
if condition is true
statements
endif
If the condition is true then the statements will be executed otherwise they will be passed over.
Nesting
Nesting means to place something within something else. If blocks can be nested.
indenting lines makes it easier to read nested statements.
if condition 1
if condition 2
statements
endif
endif
Loops
Loops allow the same statements to be repeated. There is one type of loop the
while loop. A while loop always ends with a wend statement. A while loop looks like
this:
while condition is true statements wend
If the condition is false to begin with, then the statements in the block will never be executed.
break
break causes the program to jump out of a loop.
while condition is true statements if condition break endif wend
while condition 1 is true while condition 2 is true statements wend wendLoops can also be nested with if blocks.
return 6
returns the number 6
return x
returns the value of the variable named x
return "abc"
returns the string "abc"
return a$
returns the value of the variable named a$
Arguments can be passed to library functions and user functions (functions created by the programmer.) If more than one argument is passed to a function then they are seperated by commas. Arguments can be literal numbers or strings, variables or functions.
The number of arguments passed to a function must be the same number as what the function is expecting.
var boxs[100]
creates a number array called boxs
which has 100 elements.
var month$[12]
creates a string array called month which has 12 elements.
boxs[12] = 99
assigns the value of 99 to the number 12 element of the boxs array.
month$[1] = "Jan"
assigns the value of "Jan" to the number 1 element of the month$ array.
For example, Print is used to used to print text on the screen.
SetFont can change the current font.
The x co-ordinate of the left hand side is 0 and increases to the right. The y co-ordinate of the top is 0 an increases to the bottom.
The co-ordinates are important for drawing on the screen.
Line can be used to draw lines.
Circle can be used to draw circles.
Ellipse can be done to draw ellipses.
Rect can be use to draw rectangles (which may be filled or empty).
Polygon and PolyFill can be used to draw polygons. Polygons can have up to 10 x and 10 y co-ordinates.
Paint can be used to start filling the screen with a certain colour. The colour will continue until the border colour is reached.
Point can be used to see what the colour of a pixel is.
Colours can be set by using prefined values. These are:
Colours can created by using the rgb function. Rgb stands for the red, blue and green values that are used to create a colour. Values can range between 0 and 255.
If the 3 values are the same then the colour will range from black (colour zero) to white (255 255 255) with shades of grey in between.
Using 3 different colours ceates 255 x 255 x 255 possible colours.
Cls clears the screen and fills it with the given colour.
Blit copies one rectangular area of he screen to another. The rectangles may be the same size. If the destination rectangle is larger than the source then the image will be stretched. If the destination image is smaller then the image will be shrunk.
The image can be flipped or inverted.
loadsprite filename$ n loads a sprite bitmap into memory and assigns it a number. This speeds up the use of a sprite as once it has been loaded into memory it doesn't have to be reloaded each time it is used.
Sprites can be placed anywhere on the screen. places sprite at position 100 200. All sprites use masks. A mask file is a bitmap file that has the same dimensions as the image file. The mask file has only 2 colours, white and black. The mask file has black where the image file has white and vice versa.
Image
|
Mask
|
A sprite can be made to move automatically by setting its dx and dy values. (The d is short for difference.)
To make a sprite move diagonally change both the dx nd the dy values.
To make a sprite move slowly make the dx and/or dy values small (1 or -1).
To make a sprite move faster use larger dx and dy values. (say 4 or 8)
If the dx and dy values are too large then the movement may become jerky.
You might want something to happen when a sprite collides with another sprite. This could be done by using SpriteCol with an if statement.
Sprites move every time the screen is updated.
Smaller sprites and sprites composed of fewer colours will move faster.
Sprites do not have to move. Sprites that don't move can be used in the background. For example they could be used for platforms in a platform game.
Sprites can be made visible or invisible by using SpriteOn and SpriteOff.
Different sprites can use the same image.
A sprite can use different images. This is used to create animation.
Refresh can be used to cause the screen to be redrawn.
Changing both together will create a diagonal scroll.
Tiles and sprites will scroll with the screen.
A map file contains data representing a two dimensional map.
The tiles allow different types of terrain to fit together.
For example, imagine there is a map consisting of land and sea. The letter "a" in the map file represents land while the letter "b" represents sea.
Say part of the map file looks like this: bbb bab bbb
Each letter in the map file corresponds to 4 tiles which fit together in a 2x2 square. The program automatically selects the 4 tiles needed for each square in the map. The 4 tiles it selcts will depend on the adjacent squares.
LoadTiles loads a bitmap into memory that will be used for tiles. LoadMap loads a map that will use the tiles. loadtiles and loadmap must always be used together. The same tiles bitmap can be used with different maps. loadmap gives the starting position of the map. TileScreen fills the screen with tiles.
MouseButton gives what the last mousebutton pressed was.
MouseX and mousey give the co-ordinates of the mouse.
Zones are rectangular areas on the screen. Zones can be created to detect where the mouse or a sprite is.
Wait can be used to pause a program for the given number of milliseconds.
SpriteCol can be used to see if one sprite has collided with another. SpriteCols can be used to see if one sprite has collided with any other.
Abs returns the absolute value of a number.
Sgn returns the sign of a number (-1 or 1).
Power gives the power of x to y.
Sqr gives the square root of a number.
Rnd generates a random decimal point number between 0 and 1
CurrentDir returns the current directory.
Masks are only 2 colours, black and white. The colour black in the sprite corresponds to the colour white in the mask. all other colours correspond to black in the mask.
Sprites are not drawn immediately to the front screen. Any tiles are drawn to the background screen. Sprites (and their masks) are drawn on top of the background. The background screen is then copied to the foreground screen.
This is done to prevent flicker. If sprites were drawn immediately to the front screen then there would be considerable flicker.
Sprites can move over tiles.
The Tile Editor is not functional yet.
00 | 01 | 02 | 03 |
04 | 05 | 06 | 07 |
08 | 09 | 10 | 11 |
12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
32 | 33 ! | 34 " | 35 # |
36 $ | 37 % | 38 & | 39 ' |
40 ( | 41 ) | 42 * | 43 + |
44 , | 45 - | 46 . | 47 / |
48 0 | 49 1 | 50 2 | 51 3 |
52 4 | 53 5 | 54 6 | 55 7 |
56 8 | 57 9 | 58 : | 59 ; |
60 < | 61 = | 62 > | 63 ? |
64 @ | 65 A | 66 B | 67 C |
68 D | 69 E | 70 F | 71 G |
72 H | 73 I | 74 J | 75 K |
76 L | 77 M | 78 N | 79 O |
80 P | 81 Q | 82 R | 83 S |
84 T | 85 U | 86 V | 87 W |
88 X | 89 Y | 90 Z | 91 [ |
92 \ | 93 ] | 94 ^ | 95 _ |
96 ` | 97 a | 98 b | 99 c |
100 d | 101 e | 102 f | 103 g |
104 h | 105 i | 106 j | 107 k |
108 l | 109 m | 110 n | 111 o |
112 p | 113 q | 114 r | 115 s |
116 t | 117 u | 118 v | 119 w |
120 x | 121 y | 122 z | 123 { |
124 | | 125 } | 126 ~ | 127 |
128 | 129 | 130 | 131 |
132 | 133
| 134 | 135 |
136 | 137 | 138 | 139 |
140 | 141 | 142 | 143 |
144 | 145 | 146 | 147 |
148 | 149 | 150 | 151 |
152 | 153 | 154 | 155 |
156 | 157 | 158 | 159 |
160 | 161 ¡ | 162 ¢ | 163 £ |
164 ¤ | 165 ¥ | 166 ¦ | 167 § |
168 ¨ | 169 © | 170 ª | 171 « |
172 ¬ | 173 | 174 ® | 175 ¯ |
176 ° | 177 ± | 178 ² | 179 ³ |
180 ´ | 181 µ | 182 ¶ | 183 · |
184 ¸ | 185 ¹ | 186 º | 187 » |
188 ¼ | 189 ½ | 190 ¾ | 191 ¿ |
192 À | 193 Á | 194 Â | 195 Ã |
196 Ä | 197 Å | 198 Æ | 199 Ç |
200 È | 201 É | 202 Ê | 203 Ë |
204 Ì | 205 Í | 206 Î | 207 Ï |
208 Ð | 209 Ñ | 210 Ò | 211 Ó |
212 Ô | 213 Õ | 214 Ö | 215 × |
216 Ø | 217 Ù | 218 Ú | 219 Û |
220 Ü | 221 Ý | 222 Þ | 223 ß |
224 à | 225 á | 226 â | 227 ã |
228 ä | 229 å | 230 æ | 231 ç |
232 è | 233 é | 234 ê | 235 ë |
236 ì | 237 í | 238 î | 239 ï |
240 ð | 241 ñ | 242 ò | 243 ó |
244 ô | 245 õ | 246 ö | 247 ÷ |
248 ø | 249 ù | 250 ú | 251 û |
252 ü | 253 ý | 254 þ | 255 ÿ |