Allegro/C++ 1
Allegro/C++ Tutorial
--------------------------
Difficulty:
0.1/10
NOTE: Do not attempt this if you dont know at least the bear minimum of C++
===============================================
Installing the files
----------------------
Create a new empty "Win 32 Application Project" NOT CONSOLE or FORMS.
Open the Allegro Files.rar and include them into your compiler/project
Add "alleg.lib" as one of the additional dependencies:

===============================================
Creating your first window
-------------------------------
Start off by including "allegro.h"
Start if off like any normal project
Now basically we to tell Allegro that we are starting. Its just one function and it sets everything up for us
Now what does a game require? A keyboard and mouse so add those...
This is basically the hardest part of this lesson. We need to setup the size of the window.
For the first parameter of this function you can input any of these:
They are self expanatory...
For the second and third parameter, these set the size of the window. The last two wont be explained in this lesson, we will talk about it in the future though...
Now because this acts just like a console, we need to add something that will stall the program.
readkey is basically the same as cin.get
Now one last thing that we need to add to ALL our Allegro projects is this
Without END_OF_MAIN() the project wont compile. If you want the actual reason here it is:
===============================================
Complete Source Code
----------------------
==============================================
Conclusion
----------
Ok, if you got this far, compile it and run it. You should have a window that looks like this:

Congratulations. We will actually start to work on our game in the next tutorial. We will be making a platformer game to start off
=============================================
Virus Scans
-----------
Jotti Virus Scan
VirusTotal has high traffic and it would take up to 15 mins for a scan. So yeah, I only have 1. If you dont trust mine then download it from here:
Official Allegro Website

PRESS THANKS!!!

--------------------------
Difficulty:
0.1/10
NOTE: Do not attempt this if you dont know at least the bear minimum of C++
===============================================
Installing the files
----------------------
Create a new empty "Win 32 Application Project" NOT CONSOLE or FORMS.
Open the Allegro Files.rar and include them into your compiler/project
Add "alleg.lib" as one of the additional dependencies:

===============================================
Creating your first window
-------------------------------
Start off by including "allegro.h"
Code:
#include <allegro.h> // You must include the Allegro Header file
Code:
int main()
{
Code:
allegro_init();
Code:
install_keyboard(); install_mouse();
Code:
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640,480,0,0);
Code:
GFX_AUTODETECT GFX_AUTODETECT_FULLSCREEN GFX_AUTODETECT_WINDOWED
For the second and third parameter, these set the size of the window. The last two wont be explained in this lesson, we will talk about it in the future though...
Now because this acts just like a console, we need to add something that will stall the program.
Code:
readkey(); // Wait untill a key is pressed
Now one last thing that we need to add to ALL our Allegro projects is this
Code:
return 0; } END_OF_MAIN()
Code:
It is needed because Windows uses WinMain function as entry point instead of main. The END_OF_MAIN macro makes Windows accept linking against a regular main. First, the END_OF_MAIN macro uses #define main _mangled_main to rename main to _mangled_main, in order to avoid conflicts about the symbol main. Then it creates a WinMain function which calls the _mangled_main function. It's done in such a way that both main() and main(int argc, char** argv) are supported.
Complete Source Code
----------------------
Code:
#include <allegro.h>
int main()
{
allegro_init();
install_keyboard();
install_mouse();
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640,480,0,0);
readkey();
return 0;
}
END_OF_MAIN()
Conclusion
----------
Ok, if you got this far, compile it and run it. You should have a window that looks like this:

Congratulations. We will actually start to work on our game in the next tutorial. We will be making a platformer game to start off
=============================================
Virus Scans
-----------
Jotti Virus Scan
VirusTotal has high traffic and it would take up to 15 mins for a scan. So yeah, I only have 1. If you dont trust mine then download it from here:
Official Allegro Website

PRESS THANKS!!!

Allegro Files.rar