diff --git a/Game.cpp b/Game.cpp index 30521e2..354eea2 100644 --- a/Game.cpp +++ b/Game.cpp @@ -15,13 +15,9 @@ Game::Game(void): MAXLVL(2) al_register_event_source(evQueue, al_get_keyboard_event_source()); al_register_event_source(evQueue, al_get_timer_event_source(timer)); - playerBMP = al_create_bitmap(50,50); - al_set_target_bitmap(playerBMP); - al_draw_filled_circle(25,25,25,al_map_rgb(255,255,255)); + playerBMP = al_load_bitmap("player.png"); - followerBMP = al_create_bitmap(50,50); - al_set_target_bitmap(followerBMP); - al_draw_filled_ellipse(25,25,25,15,al_map_rgb(187,52 ,224)); + followerBMP = al_load_bitmap("follower.png"); font = al_load_ttf_font("pirulen.ttf",40,0); msgFont = al_load_ttf_font("pirulen.ttf", 18,0); @@ -42,6 +38,7 @@ bool Game::InitializeAllegro() { al_init_font_addon(); al_init_ttf_addon(); + al_init_image_addon(); return true; } @@ -245,7 +242,7 @@ bool Game::CheckForTileCollision(int newX, int newY, bool isFollower) else if(map->getTile(newX,newY) == map->air) return true; - else if(map->getTile(newX,newY) == map->ground && !isFollower) + else if( (map->getTile(newX,newY) == map->ground || map->getTile(newX,newY) == map->grass ) && !isFollower) { map->BreakTile(newX,newY); return true; diff --git a/Game.h b/Game.h index 219a4cf..bac0508 100644 --- a/Game.h +++ b/Game.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "Sprite.h" #include "TileMap.h" #include diff --git a/TileMap.cpp b/TileMap.cpp index df48f49..6105c15 100644 --- a/TileMap.cpp +++ b/TileMap.cpp @@ -7,17 +7,14 @@ TileMap::TileMap(void) al_set_target_bitmap(ground); al_clear_to_color(al_map_rgb(173,102,9)); - treasure = al_create_bitmap(50,50); - al_set_target_bitmap(treasure); - al_clear_to_color(al_map_rgb(231,242,7)); + treasure = al_load_bitmap("treasure.png"); air = al_create_bitmap(50,50); al_set_target_bitmap(air); al_clear_to_color(al_map_rgb(82,223,255)); - rock = al_create_bitmap(50,50); - al_set_target_bitmap(rock); - al_clear_to_color(al_map_rgb(165,172,173)); + rock = al_load_bitmap("rock.png"); + grass = al_load_bitmap("grass.png"); } @@ -68,6 +65,7 @@ void TileMap::LoadMap(string mapName, Sprite* player, Sprite* follower) } else if (mapLine[i] == '0') Images[y][i] = ground; else if (mapLine[i] == 'R') Images[y][i] = rock; + else if (mapLine[i] == 'G') Images[y][i] = grass; else if (mapLine[i] == '1'){ Images[y][i] = air; objects.push_back(new Sprite(treasure,i,y)); @@ -80,7 +78,7 @@ void TileMap::LoadMap(string mapName, Sprite* player, Sprite* follower) void TileMap::BreakTile(int x, int y) { - if(Images[y][x] == ground) + if(Images[y][x] == ground || Images[y][x] == grass) Images[y][x] = air; } diff --git a/TileMap.h b/TileMap.h index 9426e23..4dd680d 100644 --- a/TileMap.h +++ b/TileMap.h @@ -27,6 +27,7 @@ class TileMap ALLEGRO_BITMAP* getTile(int x, int y); ALLEGRO_BITMAP* ground; + ALLEGRO_BITMAP* grass; ALLEGRO_BITMAP* treasure; ALLEGRO_BITMAP* air; ALLEGRO_BITMAP* rock; diff --git a/follower.png b/follower.png new file mode 100644 index 0000000..0a93453 Binary files /dev/null and b/follower.png differ diff --git a/grass.png b/grass.png new file mode 100644 index 0000000..cb4c160 Binary files /dev/null and b/grass.png differ diff --git a/map02.txt b/map02.txt index b2e7969..f11dc09 100644 --- a/map02.txt +++ b/map02.txt @@ -1,8 +1,8 @@ ....... ....... .@...F. -0000R.. -R0RRR0R +GGGGR.. +R0RRRGR 0000000 0000000 0000000 diff --git a/player.png b/player.png new file mode 100644 index 0000000..9077b14 Binary files /dev/null and b/player.png differ diff --git a/rock.png b/rock.png new file mode 100644 index 0000000..8995a29 Binary files /dev/null and b/rock.png differ diff --git a/treasure.png b/treasure.png new file mode 100644 index 0000000..7e8c163 Binary files /dev/null and b/treasure.png differ