Jump to content
  • Advertisement
Sign in to follow this  

Unity jAllegro - A lousy javascript port of a game programming library

This topic is 1222 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


A lousy javascript port of a game programming library

About jAllegro
jAllegro is a minimal javascript port of a really popular game programming library called Allegro 4 from the first decade of our century. Allegro 4 is a simple game programming library that abstracts a set of functions in C programming language to the developer allowing for simple and rapid creation of video games, without the need to program entity systems, classes and so on. Allegro 5 is the current Allegro version, but it varies greatly in how the API works, thus alienating many hardcore Allegro users. This library aims to provide a simple wrapper for a subset of canvas operations making it look like good old Allegro.
jAllegro background
I wanted to create something that will be easy to use and different from everything that's already out there. Since Allegro and SDL, there haven't been many non-object-oriented game libraries around, especially with the rise of AS3 and Unity. jAllegro is something else, I would like to to be available to both hardcore Allegro freaks and total newcomers who have never made a game before! I don't think this is going to become the new industry standard, but I hope it will allow newcomers to try something simple, old Allegro folks to get a bit nostalgic and maybe move on to browser development, and for game jammers to have something bloat-free that can get the job done, fast and ugly, lean and mean.
Where to get jAllegro
jAllegro Hello World!
Here's a source code of jAllegro "Hello World!" example to give you an idea as to how it works.
function main()
    set_gfx_mode("canvas_id", 640, 480);
    textout_centre(canvas,font,"Hello World!",SCREEN_W/2,SCREEN_H/2,24,makecol(0,0,0));
    return 0;
Here's a output pixture of the above code!
jAllegro example game
Want something more sophisticated? Here's the jAllegro example game code. It's under 50 lines of code!
var man,apple,bg;
var munch;
var apple_x=200,apple_y=200;
var player_x=100,player_y=100;
var score = 0;
function draw()
    textout(canvas,font,"Score: " + score,10,20,24,makecol(255,255,255));
function update()
    if (key[KEY_UP]) player_y-=4;
    if (key[KEY_DOWN]) player_y+=4;
    if (key[KEY_LEFT]) player_x-=4;
    if (key[KEY_RIGHT]) player_x+=4;
    if (distance(player_x,player_y,apple_x,apple_y)<20)
        apple_x = rand()%(SCREEN_W-32);
        apple_y = rand()%(SCREEN_H-32);
        log("Apple eaten!");
function main()
    allegro_init_all("canvas_id", 640, 480);
    man = load_bmp("data/man.png");
    apple = load_bmp("data/apple.png");
    bg = load_bmp("data/grass.jpg");
    munch = load_sample("data/munch.mp3");
    return 0;
And here's a screenshot of the game:
Use jAllegro
Planing to use jAllegro? Have any troubles? Found a bug? Wanna say hi?

Share this post

Link to post
Share on other sites

Congratulations for your release and for the good quality of the documentation.

Can you expand on the advantages of "non-object-oriented game libraries"? What other libraries do you consider too object-oriented?

Share this post

Link to post
Share on other sites

Thank you!


I don't thing either is advantageous, they are just different approaches. Each might be more suitable for given task. I think that non-OOP is slightly better for super-short-time-period game jams, such as 1 hour, two  hour or 0h game jam, since the code overhead is lower (you have to write less stuff to make things happen on screen). 

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!