All pastes #905478 Raw Edit

Unnamed

public cpp v1 · immutable
·published 2008-02-15 20:16 UTC
rendered paste body
main.cpp:#include <allegro.h>#include "map.h"map *game_map;void init();void deinit();extern void initialize_screen();extern void render();int main() {	init();	while (!key[KEY_ESC]) {          render(); 		/* put your code here */	}	deinit();	return 0;}END_OF_MAIN()void init() {	int depth, res;	allegro_init();	depth = desktop_color_depth();	if (depth == 0) depth = 32;	set_color_depth(depth);	res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);	if (res != 0) {		allegro_message(allegro_error);		exit(-1);	}	install_timer();	install_keyboard();	install_mouse();	initialize_screen();    game_map = new map(25,25);		/* add other initializations here */}void deinit() {	clear_keybuf();	/* add other deinitializations here */}render.cpp:#include <allegro.h>#include "render.h"#include "map.h"BITMAP *buffer;BITMAP *map_screen;extern map *game_map;void initialize_screen(){     buffer = create_bitmap(SCREEN_W,SCREEN_H);     map_screen = create_bitmap(game_map->map_w * TILE_W,game_map->map_h * TILE_H);     }void draw_map(){                     }     void render(){     draw_map();     show_mouse(map_screen);     blit(map_screen,buffer, 0, 0, 0, 0, SCREEN_W, SCREEN_H);     textout_ex(buffer, font, "test", 10, 10,makecol(255, 255, 255), -1);     blit(buffer,screen, 0, 0, 0, 0, SCREEN_W,SCREEN_H);                }map.cpp:#include "map.h"map::map(){           }map::map(int width, int height){    grid = new tile * [width * height];    map_w = width;    map_h = height;    }      tile map::get_tile(int x, int y){    tile *t = grid[(y * map_h) + x];    return *t;    }map.h:#include "tiles.h"class map{            private:            tile **grid;                    public:            map(int width, int height);            map();            tile get_tile(int x, int y);      int map_w;            int map_h;                           };