Jump to content
  • Advertisement
Sign in to follow this  
Sos_the_latter

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

This topic is 1077 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

jAllegro

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()
{
    allegro_init();
    set_gfx_mode("canvas_id", 640, 480);
    clear_to_color(canvas,makecol(255,255,255));
    textout_centre(canvas,font,"Hello World!",SCREEN_W/2,SCREEN_H/2,24,makecol(0,0,0));
    return 0;
}
END_OF_MAIN(); 
 
Here's a output pixture of the above code!
 
exhello.jpg
 
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()
{
    draw_sprite(canvas,bg,0,0);
    draw_sprite(canvas,man,player_x,player_y);
    draw_sprite(canvas,apple,apple_x,apple_y);
    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)
    {
        play_sample(munch);
        apple_x = rand()%(SCREEN_W-32);
        apple_y = rand()%(SCREEN_H-32);
        score++;
        log("Apple eaten!");
    }
}
 
function main()
{
    enable_debug('debug');
    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");
 
    ready(function(){
        loop(function(){
            update();
            draw();
        },BPS_TO_TIMER(60));
    });
    return 0;
}
END_OF_MAIN();
 
And here's a screenshot of the game:
 
exgame.jpg
 
Use jAllegro
 
Planing to use jAllegro? Have any troubles? Found a bug? Wanna say hi?
 
 
Bonus!
 

Share this post


Link to post
Share on other sites
Advertisement

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!