wip screenshot fun
Mark Oates

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.

Screenshots

{"name":"604422","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/1\/310d4f147b68b1689bcd34d612e5c5c9.png","w":960,"h":720,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/1\/310d4f147b68b1689bcd34d612e5c5c9"}604422
{"name":"604424","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/0\/20a7f813bfc061de5dec07afb6f9cd7a.png","w":968,"h":728,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/0\/20a7f813bfc061de5dec07afb6f9cd7a"}604424

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;
  framework->run_loop();
  return 0;
}

a typical timer func looks like this:

void my_timer_func(Framework *f, ALLEGRO_TIMER_EVENT *ev)
{
   al_clear_to_color(al_color_name("black"));

   update_animated();

   /* update stuff here */

   /* draw stuff here */

   al_flip_display();
}

"af/framework.h"

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

#SelectExpand
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

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

weapon_S

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
weapon_S said:

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

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

Thomas Fjellstrom
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.

james_lohr

* raises right hand *

It looks cool. :)

Mark Oates

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

_Kronk_

That looks amazing! :o

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

Michael Faerber

This looks great!

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

MiquelFire

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

Trent Gamblin

The old paper effect looks great.

Arvidsson

Woo! I have a fetish for frameworks, drool!

Mark Oates

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

Yep. Hopefully soon. :)

Neil Walker

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 :)

AMCerasoli

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?.

Thread #607746. Printed from Allegro.cc