• Advertisement
Sign in to follow this  

Help with sprite and tile arrays

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

Help.. I need help drawing this sprite array... #include <allegro.h> void init(); void deinit(); BITMAP *buffer = create_bitmap(480,480); BITMAP *blank_wall = load_bitmap("sprites/blank_wall.bmp", NULL); //creates the sprites for the tiles BITMAP *down_left_wall = load_bitmap("sprites/down_left_wall.bmp", NULL); BITMAP *down_right_wall = load_bitmap("sprites/down_right_wall.bmp", NULL); BITMAP *four_way_wall = load_bitmap("sprites/four_way_wall.bmp", NULL); BITMAP *horizontal_wall = load_bitmap("sprites/horizontal_wall.bmp", NULL); BITMAP *pacman_down = load_bitmap("sprites/pacman_down.bmp", NULL); BITMAP *pacman_up = load_bitmap("sprites/pacman_up.bmp", NULL); BITMAP *pacman_left = load_bitmap("sprites/pacman_left.bmp", NULL); BITMAP *pacman_right = load_bitmap("sprites/pacman_right.bmp", NULL); BITMAP *three_way_down_wall = load_bitmap("sprites/three_way_down_wall.bmp", NULL); BITMAP *three_way_left_wall = load_bitmap("sprites/three_way_left_wall.bmp", NULL); BITMAP *three_way_right_wall = load_bitmap("sprites/three_way_right_wall.bmp", NULL); BITMAP *three_way_up_wall = load_bitmap("sprites/three_way_up_wall.bmp", NULL); BITMAP *up_left_wall = load_bitmap("sprites/up_left_wall.bmp", NULL); BITMAP *up_right_wall = load_bitmap("sprites/up_right_wall.bmp", NULL); BITMAP *vertical_wall = load_bitmap("sprites/vertical_wall.bmp", NULL); BITMAP *dot_bmp = load_bitmap ("sprites/dot.bmp", NULL); RLE_SPRITE *bw = get_rle_sprite (blank_wall); RLE_SPRITE *dlw = get_rle_sprite (down_left_wall); RLE_SPRITE *drw = get_rle_sprite (down_right_wall); RLE_SPRITE *fww = get_rle_sprite (four_way_wall); RLE_SPRITE *hw = get_rle_sprite (horizontal_wall); RLE_SPRITE *pd = get_rle_sprite (pacman_down); RLE_SPRITE *pu = get_rle_sprite (pacman_up); RLE_SPRITE *pl = get_rle_sprite (pacman_left); RLE_SPRITE *pr = get_rle_sprite (pacman_right); RLE_SPRITE *twdw = get_rle_sprite (three_way_down_wall); RLE_SPRITE *twlw = get_rle_sprite (three_way_left_wall); RLE_SPRITE *twrw = get_rle_sprite (three_way_right_wall); RLE_SPRITE *twuw = get_rle_sprite (three_way_up_wall); RLE_SPRITE *ulw = get_rle_sprite (up_left_wall); RLE_SPRITE *urw = get_rle_sprite (up_right_wall); RLE_SPRITE *vw = get_rle_sprite (vertical_wall); RLE_SPRITE *dot = get_rle_sprite (dot_bmp); RLE_SPRITE *tile_map[20][20] = {{urw,hw,hw,hw,hw,twdw,hw,hw,hw,hw,hw,hw,hw,hw,twdw,hw,hw,hw,hw,ulw}, {vw,dot,dot,dot,dot,vw,dot,dot,dot,dot,dot,dot,dot,dot,vw,dot,dot,dot,dot,vw}, {vw,dot,hw,hw,dot,vw,dot,hw,hw,hw,hw,hw,hw,dot,vw,dot,hw,hw,dot,vw}, {vw,dot,dot,dot,dot,vw,dot,dot,dot,dot,dot,dot,dot,dot,vw,dot,dot,dot,dot,vw}, {drw,hw,ulw,dot,dot,dot,dot,hw,hw,dot,hw,hw,hw,dot,drw,hw,hw,hw,dot,vw}, {dot,dot,vw,dot,urw,hw,dot,dot,dot,dot,dot,dot,dot,dot,dot,dot,dot,dot,dot,vw}, {vw,dot,vw,dot,vw,dot,dot,hw,hw,hw,hw,hw,hw,dot,hw,hw,hw,ulw,dot,vw}, {vw,dot,vw,dot,vw,dot,dot,dot,dot,dot,dot,dot,dot,dot,dot,dot,dot,vw,dot,vw}, {vw,dot,dot,dot,dot,dot,urw,hw,hw,bw,hw,ulw,dot,vw,dot,vw,dot,vw,dot,vw}, {twrw,hw,hw,dot,vw,dot,vw,bw,bw,bw,bw,vw,dot,vw,dot,vw,dot,vw,dot,vw}, {vw,dot,dot,dot,vw,dot,vw,bw,bw,bw,bw,vw,dot,vw,dot,dot,dot,dot,dot,dot}, {vw,dot,vw,dot,dot,dot,drw,hw,hw,hw,hw,dlw,dot,twrw,hw,dot,urw,hw,dot,vw}, {vw,dot,vw,dot,vw,dot,dot,dot,dot,dot,dot,dot,dot,vw,dot,dot,vw,dot,dot,vw}, {vw,dot,vw,dot,drw,hw,hw,twdw,hw,hw,hw,ulw,dot,dot,dot,dot,vw,dot,hw,twlw}, {vw,dot,dot,dot,dot,dot,dot,vw,dot,dot,dot,vw,dot,hw,dot,hw,twlw,dot,dot,vw}, {twrw,hw,dot,hw,hw,dot,dot,dot,dot,vw,dot,dot,dot,dot,dot,dot,drw,hw,dot,vw}, {vw,dot,dot,dot,dot,dot,urw,hw,dot,hw,twlw,dot,vw,dot,vw,dot,dot,dot,dot,vw}, {vw,dot,hw,hw,dot,hw,dlw,dot,dot,dot,vw,dot,vw,dot,vw,dot,hw,hw,dot,vw}, {vw,dot,dot,dot,dot,dot,dot,dot,vw,dot,dot,dot,dot,dot,vw,dot,dot,dot,dot,vw}, {drw,hw,hw,hw,hw,hw,hw,hw,twuw,hw,hw,hw,hw,hw,twuw,hw,hw,hw,hw,dlw}}; int main() { init(); while (!key[KEY_ESC]) { for (int i = 0; i < 20; i++) { for (int j = 0; j < 20; j++) { draw_rle_sprite(screen, tile_map[j], i *24, j * 24); } } } 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, 480, 480, 0, 0); if (res != 0) { allegro_message(allegro_error); exit(-1); } install_timer(); install_keyboard(); install_mouse(); /* add other initializations here */ } void deinit() { clear_keybuf(); /* add other deinitializations here */ }

Share this post


Link to post
Share on other sites
Advertisement
You should check if your files loaded correctly before you actually use them in the program. Also, you should use [ source ] tags to display code on this page. (Instructions on how to do so are in the GameDev.net FAQ in the upper right-hand corner of the page below the search bar.) Lastly, do you want to scroll smoothly or just scroll a tile at a time?

Share this post


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

  • Advertisement