introduction
Allegro Game Creator(AGC) is a software to develop games.
It has many features for who wanted to develop games as well as a 3D Game, or a game with many levels, or a game with many graphic files or fonts or colors that can be written with C or C++.
It uses a scripting language.
the scripting language allowing us to write games very controlable.
why AGC?
Because:
- It's Open-Source,(see license.txt)
- it provide's many features, from version to next version
- your idea can help the project, (for example, you want a feature, you send an e-mail to me)
- support's artificial intelligence, it means you can create for example an enemy that can find you and kill you
- networking support, you can write games that can use UDP Protocol, and allow's users to play online (TCP maybe added leyter)
- secure, your games that you are writing is very secure and cannot be cracked very well (so, you can distribute your games commertially)
- easy to learn, AGC's Scripting Language is flexible, versatile, and easy to learn (if you are a beginner, you can distribute your games)
- memory management, AGC allow's game writers to manage the memory by using Garbage calection methods (not hard)
- threading management, you can manage threads and control the CPU with the best quality and speed (as same as memory management but boath of them are not required)
- support XML files, you can add XML tags to your game and use XML files for save the levels or variables and use them after the run or use XML For writing the game's configuration and after the load the games, you see wow!
- support INI files, instead of using XML files, you can use INI files to control your games
- serialization support, AGC Support's Serialization for variables and control's them
- Hexedesimal support, AGC support's hex to numbers, numbers to hex characters, words to hex characters, hex characters to words etc
- joystick support, AGC support's joysticks that are connected to the computers without any problem
- support's your selected fonts and colors, AGC support's your fonts and colors that you like, for example, you can write a text with red color and bold font or another text with blue color and with another font
- file reading and writing, you can read from files and write to them (in text or binary)
- math support. it support math operations, complex numbers etc
- support's native dialogs, AGC support's native dialogs like open and save
- support's graphics with OpenGL, AGC support's OpenGL with the graphics, so, you can draw pictures on your games
- support's reading from archived files and write to them, AGC allow's you to read from an archived file and use that file, for example, you can read a sound from an archived file and play it
- drawing support, AGC support's drawing the pictures like rectangles, sircles, etc (with OpenGL)
- support's UTF-8, AGC support's UTF-8 that you can write texts in many languages like write-to-left languages
- debug or release builds, AGC allow's you to build your game as debug or release
- 3D support, with AGC's functions, you can write very very good 3D Games that run without problem
- Regex support, AGC support's Regular expressions that you can write them to files and read them without problem
- support, reading and writing to audio files, AGC support's reading audio files, write to them and read again without any problem
- support CRC Checks, AGC support's CRC that you can check if an archive is correct or not if it is correct, run without problem, if it has a problem give an error
- support's timer, AGC support's time operations, for example after 5 minutes, if the user don't go's to a location, restart the level
- random support, AGC support's random numbers, words etc that you can use for example, generate a random number from 1 to 10
if user guess's the correct number, go's to the next level, if not, restart the level
- support's vectors, AGC support's vectors that you can for example use to make X and Y direction of bord of a chess
- update checker, AGC allow's you to check if an update is available, download a new version
How can i start?
it is very easy to start
just read this help file!
the scripting language
for who wanted to start, this section is very important because i wanted to teach the AGC's Syntax
for who know's, i recommend that see what you don't know and learn it!
note:
in the next versions, more sections will added
because i'll add features to AGC
notice that the scripting language is very easy and as like as C++ but with some differences!
if you know C++, you can learn very easyer than a persen that doesn't know programming
but i teach it for all people who like's programming with AGC
let's get started!
the AGC's script format is *.AGC
so you can double click on it or open it and run and compile it
if your script has error, you must correct it
diferences between errors and wornings:
if your script has error, it cannot be executed or compiled
but if it has worning you may compile or run it
i recommend to correct wornings(if you don't correct them, your game may buggy)
please note that empty lines and spaces are not executed
for example, if i add 2 spaces, it means i write 1 space
comments
comments are very important think in AGC
if you want to say how your code is working, you must use comments
we have 2 types of comments
single line comments
to write a single-line comment, we use 2 slashes (//)
example:
//this is a single-line comment
multi line comments
if are comments has more than one line, we can use 2 methods
1:
/*
this is a comment
another line of that comment
another line again
*/
after we use /*, we can write our comment after that /* and we can end it in that line with */
examples:
/*this is a comment
a new line
*/
or:
/*this is a comment
a new line*/
or:
/*this is a single-line comment*/
2:
use single-line
//this is a comment
//this another line
blocks
blocks are as like as a multi-line comments should be opened and closed
to open a block, we use a open-brace character({), to close it, we use close-brace character(})
example:
{
statements;
}
or:
{statements;}
statements
statements are the rules that you give to your game and they'll executed dirring the process statement by statement
each statement must ended with a semi-colon character(;)
example:
statement1;
statement2;
some of the statements must be in the blocks like if or functions
see sections (if, functions)
you can write your statements in just one line, but i dont recommend it!
expressions
expressions allow games or softwares to comunicate with programmers
for example, you can say to computer if a variable has a value, execute these statements or if hasnt this value, execute another statements
for example:
if x equals to 3, go to next level, if not, restart the game or exit from it
these are thinks that you should know before learn AGC
now we start to learn the programming with AGC
variables:
variables are very important think
for example, you write a game that your user take's point
the points must be taken by variables
or:
a text(name of a level)
if the variable is the name of the level, your game load's that level. if not, load from another level. if it is empty, load the game from first.
the types of variables:
int8
int8 is a type that take's number from -128 to 127
int16
int16 is a variable that take's number from -32,768 to 32,767
int
a variable that take's number from -2,147,483,648 to 2,147,483,647
int64
a variable that take's number from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
uint8
a variable that take's number from 0 to 255
uint16
a variable that take's number from 0 to 65,535
uint
a variable that take's number from 0 to 4,294,967,295
uint64
a variable that take's number from 0 to 18,446,744,073,709,551,615
notice that using of large variables will only take's memory
float
a variable that take's number with points(for example, 1.0)
they don't give integer numbers(1 for example)
double
a variable that take's number with points or integer numbers
double accept's boath float numbers and integers
so we can give 1 or 1.0 or 1.1000000000 to double
string
a variable that only take's text
bool
a variable that must be true or false
void
void doesn't take anythink
it is only for functions that doesn't return any values
see section(functions)
we have other types of variables that dirring the programming of games, we can use them
(we talk about them on the function reference and class refference)
how variables are declared?:
to declare a variable, we must use this sintax:
variable-type variable_name;
note:
we can't use space or sines for variable names
we must use underline (_)
for example, we can't write variable name
we must use variable_name
note:
the names of the variables are case-sensitive
so a is diferent from A
note:
we can't use numbers in the first of the names
for example, 1variable has error, but variable1 or var1iable can be used
notice that variables with same type can be declared by sepporate them by a comma(,) character
for example, int var1, var2, var3, var4;
constants:
for example, you want to write a game that use MP3 for the audio files, JPG for pictures and an integer variable that cannot be changed
so we must use constants
by using keyword const, we can declare a variable that can't be changed
now let's translate are constants variables to code:
const string audio_extension=".mp3";
const string picture_extension=".jpg";
const int variable_that_cannot_be_changed=3;
note:
if you change constants, you will be get a run-time error (an error that dirring the compilation doesn't acur, it acur's while your game is running); so, don't change them or delete the const keyword!
string rules:
to write to a string, you must use 2 quotation marks("")
or 2 ' characters('')
for example, string var1="string1";
or: string var1='string1';
now if you want to write a quotation mark to that string what you can do?
we must use a back-slash(\) + a quotation mark
for example, string var2="my name is \"amir\"";
for opastruff, we use that rule
now if you want to add a new line, what you must do?
you should write \ +n characters
for example, string var3="line1\nline2\nline3";
if you want to write a \ to a string, you must write 2 back-slashes(\\)
for example C:\windows is:
"C:\\windows"
now let's see these keywords!:
\" a quotation mark
\' is a opestruff
\n a new line
\r a return(enter key on the keyboard)
note:
don't use \r in key events
this is only for string rules
\t a tab key on the keyboard( )
note:
like enter, you can't use it in key events
\v a virtical tab
\f a line feed
functions:
to execute a block of code, you must use functions
a function can be created like this:
return-value function-name(parameters_sepparate_by_comma)
{
statements;
}
like variables, functions can't use signs in there names and also parameters, but, it can use underlines
see section(variables and how variables are declared) for more information
example of functions:
void dummy()
{
agc_initialize();
}
another example:
bool init()
{
agc_initialize();
return true;
}
the return keyword can return everything that you give to function:
if for example the function return's a type of int then you write return 1; the function return's 1
for more information about these examples, see section(function refference)
the first example initialize's AGC's functions and allow's you to use them
it doesnt return any values
you can initialize them in any functions like main()
the second example does the same thing, but with a function that return's true and false, and it return's true
example of a function that use's parameters:
void dummy1(string filename)
{
file f;
f.open(filename);
}
for more information about this example, see sections (classes, class refference)
this function use's a string in that parameter and if you want to call it, you must give a parameter to that like this:
string str;
dummy1(str);
note that you can use another names for your strings and functions
you can use handles in your functions, see sections (handles, handles to functions)
if instructions:
sometimes, you need to do some works when the given expression is true
if it isn't true, some other statements will executed
well, this is a feature of programming that every programming language has it
so lets get familiar with if sintax in AGC
if(expression)
{
statements;
}
this is an example of if instructions:
bool expr;
if(expr==true)
{
agc_initialize();
}
else
{
agc_uninitialize();
}
so, lets translate that
first, we declared a variable as type of bool
at second, (in if expression) we say "if expr is equal to true
at third we initialize AGC with initialize() function
then we say if it is other than true, uninitialize the AGC with uninitialize() function
note: we can write else if(expr==false) instead of only a keyword else
now we wanted to see if a integer value is equal to 10 or grater than 10, initialize AGC and if it is less than 10, uninitialize it:
int val;
if(val>=10)
{
agc_initialize();
}
else if (val<10)
{
agc_uninitialize();
}
now we wanted to see if val is equal to 200, uninitialize AGC:
if(val==200)
{
agc_uninitialize();
}
notice that you can use these expressions with another types of variables like float, double, string, and all the types with ==, >=, <=, *=, /=, %=
switch and case:
when your if expressions are very, what do you do?
are you write them and add many lines to your code or you use another thing that can help you
well if you use another thing, that is switch and case
now i write an example in switch and case:
bool a;
switch(a)
{
case true:
agc_initialize();
case false:
agc_uninitialize();
default:
agc_uninitialize();
}
now lets write this example with if:
bool a;
if(a==true)
{
agc_initialize();
}
else if(a==false)
{
agc_uninitialize();
}
else
{
agc_uninitialize();
}
now if you see that, you will know what is changed
but switch and case is the if statements with some changes