Skip to content

Commit

Permalink
micro fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-str committed Mar 4, 2021
1 parent bc28a8e commit 0788bfd
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 33 deletions.
5 changes: 4 additions & 1 deletion Enemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 8 additions & 3 deletions GameMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

}
Expand Down
10 changes: 5 additions & 5 deletions Item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 10 additions & 2 deletions Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -281,7 +281,7 @@ private: static Player *player_getter;
int hp = 40;
int max_hp = 40;

int damage = 4;
int damage = 70;// 3;

};

Expand Down
42 changes: 27 additions & 15 deletions maps/C.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
z+
################################
#..............................#
#..............................#
#..............................#
#..............................#
#..............................#
#..............................#
#..............................#
#..............................#
#..............................#
#..............................#
#..............................#
#..............................#
#..............................#
################################
z-
#........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

23 changes: 23 additions & 0 deletions maps/D.txt
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions maps/F.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
z+
#############.##################
################################
#I.E...#.........#.............#
#......#.........#........E. ..#
#......#....E....#........E. ..#
#......#.........#.............#
#E.E...#.........#.......... ..#
##.######.#####.####.#.........#
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion maps/M_OF_M.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#####
###ACW
##FAB#
######
#DB###
#####

0 comments on commit 0788bfd

Please sign in to comment.