- Online Community Forums » The Depot » wip screenshot fun

This thread is locked; no one can reply to it. rss feed Print
wip screenshot fun
Mark Oates
Member #1,146
March 2001

Though I'm usually reluctant to post anything that hasn't maintained some polish, per 23's request I'm going to post a screenshot of something I'm working on. Basically I'm finishing off the core baseline of my framework. I'm thinking about releasing a version so I can use it in SpeedHack without having to include it in the entry. What you see in the screenshots dosn't represent any capability of the framework itself, more of a test-use that came together quickly.



About the Screenshot

Obviously it some kind of platform game. I put together an absolute-basic tilemap because I hadn't yet done that in A5. Minus the framework, this working demo has come together in about 2 days. The tall rectangle in the middle is the player's bounding box, and the smaller rectangles are bats.

The second screenshot applies 3 filters: desaturate, a 1px blur, and a paper texture using multiply blending. This was more for fun than anything else. I think it looks awesome but I wouldn't want to use it in any full-length game.

The thing I'm most stoked about is that there are only 5 tiles in this example! TILE_NONE, TILE_GRASS, TILE_BLOCK, TILE_PILLAR, and TILE_DIRT. All of the borders, shading, and grass edging are calculated on render and drawn using the component graphics. Makes things a lot quicker when putting together a level. :) ("Mehuh >:( I was doing that back in 1992! >:( meauh!" yea shuddup! :P)

About the Framework

  • The purpose is to have something that fully sets up Allegro 5 out of the box, and remains separated from the game you're working on. (I don't like forgetting to call al_init_font_addon(), chasing down the error, and the like.)

  • includes a font_bin, sample_bin, and image_bin for very fast error-proof loading/retrieval by filename.

  • useful functions and classes like tostring(), vec2d, animate(), profiling_timer, etc.

  • the Framework class has function pointers that you use to interface with your program. They're optional, and get called when their corresponding ALLEGRO_EVENTs are fired.

For the program in the screenshot, my main() looks like this:

int main(int argc, char *argv[])
  Framework *framework = new Framework(/* optional .cfg filename */);
  framework->timer_func = my_timer_func;
  framework->key_up_func = my_key_up_func;
  framework->key_down_func = my_key_down_func;
  framework->mouse_axes_func = my_mouse_axes_func;
  return 0;

a typical timer func looks like this:

void my_timer_func(Framework *f, ALLEGRO_TIMER_EVENT *ev)


   /* update stuff here */

   /* draw stuff here */



Here's what the framework looks like at the moment:

1#ifndef __FRAMEWORK_HEADER 2#define __FRAMEWORK_HEADER 3 4 5#include <sstream> 6#include <vector> 7#include <string> 8#include <iostream> 9#include <algorithm> 10 11using std::vector; 12using std::string; 13using std::cout; 14using std::endl; 15 16#include <allegro5/allegro.h> 17#include <allegro5/allegro_audio.h> 18#include <allegro5/allegro_acodec.h> 19#include <allegro5/allegro_font.h> 20#include <allegro5/allegro_ttf.h> 21#include <allegro5/allegro_color.h> 22#include <allegro5/allegro_memfile.h> 23#include <allegro5/allegro_primitives.h> 24 25#include <af/image_bin.h> 26#include <af/sample_bin.h> 27#include <af/font_bin.h> 28#include <af/vec2d.h> 29#include <af/useful.h> 30#include <af/logger.h> 31#include <af/profiling_timer.h> 32 33 34class Framework 35{ 36public: 37 int w, h; 38 ALLEGRO_DISPLAY *display; 39 ALLEGRO_TIMER *timer; 40 ALLEGRO_TRANSFORM camera_tansform; 41 ALLEGRO_EVENT_QUEUE *queue; 42 ALLEGRO_PATH *resource_path; 43 44 ImageBin *image_bin; 45 SampleBin *sample_bin; 46 FontBin *font_bin; 47 48 bool abort_game; 49 50 void (*init_func)(Framework *f); 51 void (*timer_func)(Framework *f, ALLEGRO_TIMER_EVENT *ev); 52 void (*key_up_func)(Framework *f, ALLEGRO_KEYBOARD_EVENT *ev); 53 void (*key_down_func)(Framework *f, ALLEGRO_KEYBOARD_EVENT *ev); 54 void (*key_char_func)(Framework *f, ALLEGRO_KEYBOARD_EVENT *ev); 55 void (*mouse_up_func)(Framework *f, ALLEGRO_MOUSE_EVENT *ev); 56 void (*mouse_down_func)(Framework *f, ALLEGRO_MOUSE_EVENT *ev); 57 void (*mouse_axes_func)(Framework *f, ALLEGRO_MOUSE_EVENT *ev); 58 void (*joy_up_func)(Framework *f, ALLEGRO_JOYSTICK_EVENT *ev); 59 void (*joy_down_func)(Framework *f, ALLEGRO_JOYSTICK_EVENT *ev); 60 void (*joy_axis_func)(Framework *f, ALLEGRO_JOYSTICK_EVENT *ev); 61 void (*display_close_func)(Framework *f, ALLEGRO_DISPLAY_EVENT *ev); 62 void (*display_resize_func)(Framework *f, ALLEGRO_DISPLAY_EVENT *ev); 63 64 Framework(std::string config_filename="data/af.cfg"); 65 ~Framework(); 66 virtual void run_loop(); 67}; 68 69 70void framework_default_display_close_func(Framework *f, ALLEGRO_DISPLAY_EVENT *ev); 71 72 73 74 75#endif

class UIFramework

I'm not planning on including this in the release, but class UIFramework : public Framework does more stuff "in the background" and among other things includes a UI. For example, it wraps the user's custom timer_func() by:

  • clearing to a background_color and/or background_image

  • drawing the UI

  • updating animations

  • flipping the display.

and also wraps most of the input functions with UI stuff.

Using the UIFramework, I've put together a few programs where I haven't needed to use a custom timer_func() at all, because everything is object controlled.

Matthew Leverton
Supreme Loser
January 1999

Raise your right hand if you looked at the pictures but didn't read any of the text. 8-)

Member #7,859
October 2006

First I looked then I read. :P Looks good. Both the screenshots and the framework. Although I'm not sure I'd use it, because I get anal about controlling the timing.
The 'testing lines' in that paper filter make it look like an old film filter. Does the paper texture move with the level? That would be awesome.

Mark Oates
Member #1,146
March 2001

weapon_S said:

Does the paper texture move with the level? That would be awesome.

Yea. It's a giant looping texture. :)

Thomas Fjellstrom
Member #476
June 2000

weapon_S said:

The 'testing lines' in that paper filter make it look like an old film filter. Does the paper texture move with the level? That would be awesome

I just assumed it was an old film filter, given the dust/grains and lines on the texture. Looked exactly like an old reel to reel film.

Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" --

Member #1,947
February 2002

* raises right hand *

It looks cool. :)

Mark Oates
Member #1,146
March 2001

Raise your right hand if you looked at the pictures but didn't read any of the text. 8-)

From now on when I make big blocks of text, I'm going to drop in "Matthew sucks" somewhere in the middle. ;D


I encourage others to join me. :P

Member #12,347
November 2010

That looks amazing! :o

Is it possible to get filter effects like that using A4?

"If only our dreams were fires to ignite, then we could let the whole world burn" -Emery

My blog:

Michael Faerber
Member #4,800
July 2004

This looks great!

... and the text was interesting to read as well. ;D

"The basic of informatics is Microsoft Office." - An informatics teacher in our school
"Do you know Linux?" "Linux? Isn't that something for visually impaired people?"

Member #3,110
January 2003

So, you going to release this thing so others can use it as well?

Febreze (and other air fresheners actually) is just below perfumes/colognes, and that's just below dead skunks in terms of smells that offend my nose. | +Me
Windows 8 is a toned, stylish, polished professional athlete. But it’s wearing clown makeup, and that creates a serious image problem. ~PCWorld Article

Trent Gamblin
Member #261
April 2000

The old paper effect looks great.

Member #4,603
May 2004

Woo! I have a fetish for frameworks, drool!

Mark Oates
Member #1,146
March 2001

So, you going to release this thing so others can use it as well?

Yep. Hopefully soon. :)

Neil Walker
Member #210
April 2000

Raise your right hand if you looked at the pictures but didn't read any of the text.

Raise your left hand if you looked at the pictures but didn't read any of the text or anyone's replies. :P

However, I have a question, is it my eyes or your screenshot - it looks like the screen is tilted slightly on an angle. I'm curious cos a 2D pivoting platformer sounds quite interesting :)

MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Member #11,955
May 2010

Good pictures. Are you going to make a little game using your framework?, I'll play the game and skip the rest ;D. I have the same question that Neil posted in his last post, the map it's a little bit rotated?.

Go to: