From 0788bfddaeebc371faef4d53a6a15cbb23b44308 Mon Sep 17 00:00:00 2001 From: name Date: Fri, 5 Mar 2021 00:47:21 +0300 Subject: [PATCH] micro fix --- Enemy.cpp | 5 ++++- GameMap.cpp | 11 ++++++++--- Item.cpp | 10 +++++----- Player.cpp | 12 ++++++++++-- Player.h | 6 +++--- maps/C.txt | 42 +++++++++++++++++++++++++++--------------- maps/D.txt | 23 +++++++++++++++++++++++ maps/F.txt | 6 +++--- maps/M_OF_M.txt | 2 +- 9 files changed, 84 insertions(+), 33 deletions(-) create mode 100644 maps/D.txt diff --git a/Enemy.cpp b/Enemy.cpp index 81d583e..7505938 100644 --- a/Enemy.cpp +++ b/Enemy.cpp @@ -50,7 +50,10 @@ void Enemy::Draw(Image &canvas) //TODO:check player pos auto &pl = Player::Get(); //if (fn_can_attack(pl, p, attack_dir)) pl.GetDamage(get_damage(type)); - if (fn_can_attack(pl, p).first) pl.GetDamage(get_damage(type)); + + int dmg_add = (int)(GameTime::Now().GetTime() / (80)); + if (dmg_add > 5) dmg_add = 5; + if (fn_can_attack(pl, p).first) pl.GetDamage(dmg_add + get_damage(type)); attack_cd = true; time_start = GameTime::Now().GetTime(); diff --git a/GameMap.cpp b/GameMap.cpp index 2fe8fdf..25afd08 100644 --- a/GameMap.cpp +++ b/GameMap.cpp @@ -88,11 +88,11 @@ bool GameMap::CheckChangeMap() Z(gri.R); } if (center_pos.y / TILE_SZ >= now_room->gri.map_height) { - now_y += 1; + now_y -= 1; Z(gri.U); } if (center_pos.y < 0) { - now_y -= 1; + now_y += 1; Z(gri.D); } @@ -169,7 +169,12 @@ GameMap::GameRoom::GameRoom(GameMap::GameRoomInfo &_gri, GameMap &_parent) : gri for (int i = 0; i < gri.enemies.size(); i++)map_objects.AddEnemy(gri.enemies[i].first, gri.enemies[i].second); for (int i = 0; i < gri.door_pos.size(); i++) { Point door_p = gri.door_pos[i]; - map_objects.AddDoor(door_p, (door_p.x == 0) ? E_Dir::LEFT : (door_p.y == 0) ? E_Dir::DOWN : (door_p.y == gri.map_height - 1) ? E_Dir::UP : E_Dir::RIGHT); + bool _L = (door_p.x == 0); + bool _D = (door_p.y == 0); + bool _U = (door_p.y == gri.map_height - 1); + bool _R = (door_p.x == gri.map_width - 1); + if (_L || _D || _R || _U)map_objects.AddDoor(door_p, _L ? E_Dir::LEFT : _D ? E_Dir::DOWN : _U ? E_Dir::UP : E_Dir::RIGHT); + else map_objects.AddDoor(door_p, gri.tile_type[door_p.y][door_p.x - 1] == E_TileType::Wall ? E_Dir::UP : E_Dir::LEFT); } } diff --git a/Item.cpp b/Item.cpp index 28400d3..73d6294 100644 --- a/Item.cpp +++ b/Item.cpp @@ -33,17 +33,17 @@ Item::Item(int i_lvl, Point _pos) : item_lvl(i_lvl), pos(_pos) { int t = std::rand() % 5; if (t < 2)item_type = E_ItemTypes::Potion; - if (t == 2)item_type = E_ItemTypes::Boots; - if (t == 3)item_type = E_ItemTypes::Book; - if (t == 4)item_type = E_ItemTypes::Ring; + if (t == 2)item_type = E_ItemTypes::Book; + if (t == 3)item_type = E_ItemTypes::Ring; + if (t == 4)item_type = E_ItemTypes::Boots; break; } case 3: { int t = std::rand() % 5; if (t < 3)item_type = E_ItemTypes::Potion; - if (t == 3)item_type = E_ItemTypes::Boots; - if (t == 4)item_type = E_ItemTypes::Book; + if (t == 3)item_type = E_ItemTypes::Book; + if (t == 4)item_type = E_ItemTypes::Boots; break; } case case_boots: diff --git a/Player.cpp b/Player.cpp index 2162929..5b12a23 100644 --- a/Player.cpp +++ b/Player.cpp @@ -12,11 +12,19 @@ void Player::Attack() auto cp = position.CenterPos(); switch (dir) { case E_Dir::UP: - GameMap::GetCur()->TryAttack({cp.x, cp.y + 25}, damage); + { + bool b = GameMap::GetCur()->TryAttack({cp.x, cp.y + 25}, damage); + if (!b)b = GameMap::GetCur()->TryAttack({cp.x - 10, cp.y + 25}, damage); + if (!b)b = GameMap::GetCur()->TryAttack({cp.x + 10, cp.y + 25}, damage); break; + } case E_Dir::DOWN: - GameMap::GetCur()->TryAttack({cp.x, cp.y - 25}, damage); + { + bool b = GameMap::GetCur()->TryAttack({cp.x, cp.y - 25}, damage); + if(!b)b = GameMap::GetCur()->TryAttack({cp.x - 10, cp.y - 25}, damage); + if(!b)b = GameMap::GetCur()->TryAttack({cp.x + 10, cp.y - 25}, damage); break; + } case E_Dir::LEFT: GameMap::GetCur()->TryAttack({cp.x - 25, cp.y}, damage); break; diff --git a/Player.h b/Player.h index 1c83fb2..20f10af 100644 --- a/Player.h +++ b/Player.h @@ -226,7 +226,7 @@ private: static Player *player_getter; dmg_text_img.Draw(canvas, Point {now_x_pos, now_y_pos - 8 + dmg_text_img.Height() / 2}, true); now_x_pos += dmg_text_img.Width() + 7; - for (int i = Player::Get().damage; i > 0; i-=3) { + for (int i = Player::Get().damage, dmg_dr = 0; (i > 0) && (dmg_dr < 7); i-=3, dmg_dr++) { damage_img[(i > 3) ? 2 : i - 1].Draw(canvas, Point {now_x_pos, now_y_pos}, true); now_x_pos += 42; } @@ -265,7 +265,7 @@ private: static Player *player_getter; Point old_coords {.x = 0, .y = 0}; Pixel color {.r = 255, .g = 255, .b = 0, .a = 255}; - int move_speed = 100; + int move_speed = 90; int move_speed_ctrl = 40; LiveObjSprite &spr; @@ -281,7 +281,7 @@ private: static Player *player_getter; int hp = 40; int max_hp = 40; - int damage = 4; + int damage = 70;// 3; }; diff --git a/maps/C.txt b/maps/C.txt index 2e73a6a..996fa3c 100644 --- a/maps/C.txt +++ b/maps/C.txt @@ -1,17 +1,29 @@ z+ ################################ -#..............................# -#..............................# -#..............................# -#..............................# -#..............................# -#..............................# -#..............................# -#..............................# -#..............................# -#..............................# -#..............................# -#..............................# -#..............................# -################################ -z- \ No newline at end of file +#........EIE............. .. ..# +#...... . E .#.... ..... ......# +#..... .# . .#.. .. ...... ....# +#.... ..#. .###. . ........ ..# +#.....####....## .....#..#..#..# +#......#......#....E...........# +#........E E E.. .....#.I......# +#.........EIE .. ...... .....# +#......... E . ....E....... . ## +#########.. . .. .....#...... E. +#.......#... ......E..... . .. # +... ....#....... ............ E# +#... ...#....... .....# ...... # +#.... .................. . . ..# +#.E E...#....... ..E...........# +#..... .#....... .....#..#..#..# +#.I.E ..#......................# +################.############### +z- + +I: 3, pot, 2, book +E: 0, 0, 1 +E: 1, 0, 0, 0, 1, 1, 1 +E: 0, 1, 0, 1 +E: 0, 0, 1 +E: 1 + \ No newline at end of file diff --git a/maps/D.txt b/maps/D.txt new file mode 100644 index 0000000..f3bf361 --- /dev/null +++ b/maps/D.txt @@ -0,0 +1,23 @@ +z+ +################################ +#....E.. .E.....#....... .. # +#.I.. ..II. .....#......E .. # +#......E E......#..... .. ..# +#.E..............#..... .. ..# +#...... ......#......E .. # +#O###### ######O# ...... .. # +#....... .... III .... .. ... +#............. .... .. ..# +#####... .....#.........E .. # +#K..#.. ..####. .... .. # +#.E.#... ...E#.. I . .... ..# +#E..##.. ....#.. . . # +#..E............ .E.........E# +########.####################### +z- + +E: 1, 0, 1, 0, 0, 0, 1, 1 +E: 0, 1, 0, 0, 1, 1 +I: pot, book, book +I: ring, pot, 2 +I: 3 \ No newline at end of file diff --git a/maps/F.txt b/maps/F.txt index 1019121..8450228 100644 --- a/maps/F.txt +++ b/maps/F.txt @@ -1,7 +1,7 @@ z+ -#############.################## +################################ #I.E...#.........#.............# -#......#.........#........E. ..# +#......#....E....#........E. ..# #......#.........#.............# #E.E...#.........#.......... ..# ##.######.#####.####.#.........# @@ -22,7 +22,7 @@ z- / it's comment /E: 0, 0, 0, 0, 0, 0, 0, 0 -E: 1, 0, 1, 1, 1, 1, 0, 0, 0, 0 +E: 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 ///I: 2, 1, 2, 3, 0, 0, 0, 1, 1 I: boots, 0, 0 diff --git a/maps/M_OF_M.txt b/maps/M_OF_M.txt index 29d83e8..d180e5d 100644 --- a/maps/M_OF_M.txt +++ b/maps/M_OF_M.txt @@ -1,6 +1,6 @@ ##### ###ACW ##FAB# -###### +#DB### #####