From 770c09060fab507ac241d0a1699844ee14a34098 Mon Sep 17 00:00:00 2001 From: name Date: Wed, 3 Mar 2021 06:23:34 +0300 Subject: [PATCH] + enemy --- Enemy.cpp | 2 +- Enemy.h | 5 ++++- LiveObjSprite.h | 6 +++--- Player.h | 2 +- SpriteManager.h | 15 +++++++++++++-- maps/F.txt | 4 ++-- resources/enemies/1/attack.png | Bin 0 -> 2651 bytes resources/enemies/1/move.png | Bin 0 -> 2274 bytes resources/enemies/1/take_hit.png | Bin 0 -> 1663 bytes 9 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 resources/enemies/1/attack.png create mode 100644 resources/enemies/1/move.png create mode 100644 resources/enemies/1/take_hit.png diff --git a/Enemy.cpp b/Enemy.cpp index a236d5d..01a36f8 100644 --- a/Enemy.cpp +++ b/Enemy.cpp @@ -1,6 +1,6 @@ #include "Enemy.h" -Enemy::Enemy(Point center_pos, int _type) : type(_type), mov(center_pos) +Enemy::Enemy(Point center_pos, int _type) : type(_type), mov(center_pos + Point{.x = 0, .y = 5}) { max_hp = get_hp(_type); hp = max_hp; diff --git a/Enemy.h b/Enemy.h index 8dac13c..1e28488 100644 --- a/Enemy.h +++ b/Enemy.h @@ -10,16 +10,19 @@ struct Enemy static constexpr int get_hp(int type) { if (type == 0)return 20; - return 35; + if (type == 1)return 40; + return 30; } static constexpr Size get_sz(int type) { if (type == 0)return Size {.w = 41, .h = 34}; + if (type == 1)return Size {.w = 28, .h = 38}; return Size {2,2}; } static constexpr int get_speed(int type) { if (type == 0)return 160; + if (type == 1)return 80; return 80; } diff --git a/LiveObjSprite.h b/LiveObjSprite.h index 70cb96d..52eb81c 100644 --- a/LiveObjSprite.h +++ b/LiveObjSprite.h @@ -21,14 +21,14 @@ enum class E_LiveObjType struct LiveObjSprite { - LiveObjSprite(E_LiveObjType must_enemy, int type, int move_frames, int attack_frames, int take_hit_frames) : spr_states() + LiveObjSprite(E_LiveObjType must_enemy, int type, int move_frames, int attack_frames, int take_hit_frames, int ms_speed) : spr_states() { if (must_enemy != E_LiveObjType::Enemy)error("must enemy. for character use another constructor"); lo_type = must_enemy; cur_dir = std::rand() % 2 ? E_Dir::LEFT : E_Dir::RIGHT; std::string path_0 = "../resources/enemies/" + std::to_string(type) + "/"; - spr_states.insert({E_LiveObjState::Idle, std::map{}}).first->second.insert({E_Dir::RIGHT, Sprite(path_0 + "move.png", move_frames)}); - spr_states.insert({E_LiveObjState::Attack, std::map{}}).first->second.insert({E_Dir::RIGHT, Sprite(path_0 + "attack.png", attack_frames)}); + spr_states.insert({E_LiveObjState::Idle, std::map{}}).first->second.insert({E_Dir::RIGHT, Sprite(path_0 + "move.png", move_frames, ms_speed)}); + spr_states.insert({E_LiveObjState::Attack, std::map{}}).first->second.insert({E_Dir::RIGHT, Sprite(path_0 + "attack.png", attack_frames, ms_speed)}); spr_states.insert({E_LiveObjState::TakeHit, std::map{}}).first->second.insert({E_Dir::RIGHT, Sprite(path_0 + "take_hit.png", take_hit_frames)}); //SetCurSprite(); } diff --git a/Player.h b/Player.h index 901ad66..e5024c9 100644 --- a/Player.h +++ b/Player.h @@ -16,7 +16,7 @@ private: static Player *player_getter; { Kill, EmptyStay, - }; + }; static Player &Get() { return *player_getter; } diff --git a/SpriteManager.h b/SpriteManager.h index ede2ada..406179c 100644 --- a/SpriteManager.h +++ b/SpriteManager.h @@ -37,22 +37,33 @@ struct SpriteManager static constexpr int e_get_move_frames(int type) { if (type == 0)return 8; + if (type == 1)return 8; return 1; } static constexpr int e_get_attack_frames(int type) { if (type == 0)return 8; + if (type == 1)return 8; return 1; } static constexpr int e_get_take_hit_frames(int type) { if (type == 0)return 4; + if (type == 1)return 4; + return 1; + } + static constexpr int e_get_spr_speed(int type) + { + if (type == 0)return 125; + if (type == 1)return 190; return 1; } SpriteManager() : enemy_spr(), hp_imgs(), doors() { - for (int _type = 0; _type < 1; _type++) - enemy_spr.emplace_back(E_LiveObjType::Enemy, _type, e_get_move_frames(_type), e_get_attack_frames(_type), e_get_take_hit_frames(_type)); + for (int _type = 0; _type < 2; _type++) + enemy_spr.emplace_back(E_LiveObjType::Enemy, _type, + e_get_move_frames(_type), e_get_attack_frames(_type), + e_get_take_hit_frames(_type), e_get_spr_speed(_type)); int sz = HP_SZ; Image hp_img {sz,sz,4}; diff --git a/maps/F.txt b/maps/F.txt index ebd0bea..a89c109 100644 --- a/maps/F.txt +++ b/maps/F.txt @@ -19,8 +19,8 @@ O. ..E.....#.........#... .....O ###########O#################### z- -E: 0, 0, 0, 0, 0, 0, 0, 0 -/1, 0, 1, 1, 1, 0, 0, 0 +/E: 0, 0, 0, 0, 0, 0, 0, 0 +E: 1, 0, 1, 1, 1, 0, 0, 0 I: 2, 1, 2, 3, 0, 0, 0, 1, 1 /I: - rarity of Items in the same order as they stay on map diff --git a/resources/enemies/1/attack.png b/resources/enemies/1/attack.png new file mode 100644 index 0000000000000000000000000000000000000000..926dd0ae73a0edcc2114c006397e8281189498a2 GIT binary patch literal 2651 zcmV-h3Z(UkP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf3GhioK~#8N?VY{P z6-5-ruU3|lXlbFb(87pDDkCQR0~T5l8$m1NO=z@`f`Ud1N%*J~Dnp|d{sEGRu_93n zg^jVXu+W6o4tXy7ydDm-J7;F+>%jdbo85cwzU*&j=R7;RcW-#?&RsS;cI@cJvFBc# zmeRQL$8Xcpj$Z5nbTF*N)U$XzID(Nqb3;?J3(>yp0(1b@7E_BN^56(Y_be5h#7ls3 zzaO^1-vww#N)}VCj_JV>JZf!8Mh>Ld{1joW`uOJk9;zcp(vx81Ey4|Ra9?Xt;K8uHSCr>3RsmiBVt^hx@btFrLi@*)6F%c| zh}wNPhdHOmr@09Tm5?gAW0IVI7Y9>Mn$o`dV94#tj)i5u4t2PtPPi5ij=+m2pey|( zDXw7Dd!HcG{y-iZF7tH_WZwvFmlKi8nz;-xk3egLp6>i>i8(GcPzc!pO1lF1YA0@! z@6Wv^^6zUDl?O-Q#Z!XO8cB7n(H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ZVvLy3sB>>FC7T*m4YNA`441Qu})Fj2+7! zp3*6_{ZM_^@*FMLvjUXQaO#E)?Lg1qoCDtU1JakkdxXm)**P?!_gWF^19Q+5>sr^TakK42y*V=w_H6B8`*Y=Xc+(N-=Y1nhbt`T)y5ZX7ftKdK)Yhu0@rWhoqJq!|1Ou&JxBFR{r7A85V;NX@mN3S zdYsoF=|Ot0Y=6ryenGYL9BRtCHOSq5Z|@yDYLnW>>(|6)^B+3+TRrUQ%O3y$002ov JPDHLkV1nbV3rzq3 literal 0 HcmV?d00001 diff --git a/resources/enemies/1/move.png b/resources/enemies/1/move.png new file mode 100644 index 0000000000000000000000000000000000000000..20b5bc4fba461cfd28af2703b52d221ab8c0e412 GIT binary patch literal 2274 zcmV<82p#u{P);00001b5ch_0Itp) z=>Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D2zN6KcuI8PQ+0(A8 zu*bBucVUNU>sGAJ&Ybi#=Zwr|&$6(|PLRVLt1i<#Gcx-XyPD?&Id*zxjJza!Ok20& zYF}HEH1CYe?({Ur336o5+ZQn^%5h%jx;CeAb{Kn-%w0i_ogUHhC&{A4H=1)sW_P=q=L9)sU0j>rJ?6SLr*U??D-eU9@w z*R?tNjXhkS0h*SW6EY0Mrm z%I5rN%y~ioyFnwvfB)NG-_W=f7q_IWOp+kvVhs3`h5sJcbIhEQH|#$5j5bHd zF6r3q67-xP|382G#|Jcj=M3}yc<-Yz=jm+ZdPC1>%y~iojLdz;^RnO1#a%haOruUV z{4!YX7bEAGxyn|Is!z~!!e>3N=60{= zm}%6>h6`sfbCoyW&CTuLt|WV3$0c`#>=?n!75D-g%|Cs9;xqeNk2~JRC3i~tM=;Z< zlO(18`S-u-r(o_X_RV1CD$PxpxkB?cn7cyrnx|iQ(R$3&eXWBqb4t4IzVCICSoo*k z{rpYPhkg9m-oi(3G|L&?kdgQVD1XdE1rH{=}mXyHO!Ja z>2Sk^`8^8-eKRtbcq4ZqOgMN4I%l-Jxx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t&i(me4^`i2}Ah_oH;pM0Q0)tCP>&k`ne*gdg07*qoM6N<$g2r01H~;_u literal 0 HcmV?d00001 diff --git a/resources/enemies/1/take_hit.png b/resources/enemies/1/take_hit.png new file mode 100644 index 0000000000000000000000000000000000000000..830ce151a72154eba5bd0a62528d8981df1fcbbf GIT binary patch literal 1663 zcmV-_27vjAP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1{6s|K~#8N?Uyl* zBt;ZN_X0?3VBlgPAz>kL6Hb6Q26w>X2zZ=YvFM4;$5kySslvb$GkjHl}Q z^)r4{W^7OIhnJU^cmC)6@a5Mp9k_0VSbV3)y$)pu$y*m{%@B+4oRbbB!FBg0d02tE zU1IT_W6}YfL5+Km=B`5RF0uH|n6&w`P;&=q&Kci*{QM1iM*S|a_|6zV5HdQP5!Ajy z(s$_X4C;4@#TkA-az(z_MuPzpU`e?jdlB>jSZx=_DMES`~!&p^E$ zq`=HTy%GK%=^)PV^#%1;pk~3DoX@&Hr~VAFI6`K2KZkTBu}Iu( z7dI(VA7^z*Vb}#{5xooF%@6A3i*IiZk5Ka}^h4yOe94>Ys!?-=SR`fk2%0~`*K$^u z6og%HRzmMl*E)>ffBWSX9hBGf-mmqbwG*G^$cw@wuU@0p3b9B$08TPKLuqhUmlT9u zaMls^9v&V)D2MCr4fmRU64Y2B789c&`Mp19U#itT=gg48umjFHBLyhIb&o_I{{Hii zcrCbQg;*Rh3W?W8_pBGxUm*qJ3e@jVf%?=#RkOeO?Bi>I(sh@=SnT5A(54o3p8_PP zvx^jvF4UT#-dP8uL(&0}>QD8A^mkBt?oXe^u9>koi-M#dcM6r)xaQs{C|`a5*DD?# z)wpJrde6}T?SeB`D4p`A!0WU7<(gSyahCtg{2QM7T$}7QuDLgl3{;^Y@qo_IK6T*C zS(0WKYK@4+S&{+5HTT8?G=gicQsHpYK8)zB(N74@ogwMYLQN+YXYfJ#D&@7{x_jcG zDG%vdaNQ0(P@RxCX?@jo)$dZxn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