From 9512f90f754ac74780592783b1e241eeca21a249 Mon Sep 17 00:00:00 2001 From: fred-boy Date: Mon, 23 Dec 2019 18:32:49 +0700 Subject: [PATCH] Make separate textures for mob limbs #8 --- android/assets/mobs/char.png | Bin 1397 -> 0 bytes android/assets/mobs/char/0_0.png | Bin 0 -> 340 bytes android/assets/mobs/char/0_1.png | Bin 0 -> 238 bytes android/assets/mobs/char/0_2.png | Bin 0 -> 234 bytes android/assets/mobs/char/0_3.png | Bin 0 -> 220 bytes android/assets/mobs/char/1_0.png | Bin 0 -> 338 bytes android/assets/mobs/char/1_1.png | Bin 0 -> 246 bytes android/assets/mobs/char/1_2.png | Bin 0 -> 234 bytes android/assets/mobs/char/1_3.png | Bin 0 -> 220 bytes android/assets/mobs/pig.png | Bin 1665 -> 0 bytes android/assets/mobs/pig/0_0.png | Bin 0 -> 761 bytes android/assets/mobs/pig/0_1.png | Bin 0 -> 235 bytes android/assets/mobs/pig/1_0.png | Bin 0 -> 770 bytes android/assets/mobs/pig/1_1.png | Bin 0 -> 226 bytes .../cavedroid/game/GameItems.java | 36 +++++++------- .../cavedroid/game/mobs/FallingGravel.java | 4 +- .../cavedroid/game/mobs/FallingSand.java | 4 +- .../deadsoftware/cavedroid/game/mobs/Mob.java | 1 + .../deadsoftware/cavedroid/game/mobs/Pig.java | 12 ++--- .../cavedroid/game/mobs/Player.java | 14 +++--- .../deadsoftware/cavedroid/misc/Assets.java | 44 ++++-------------- 21 files changed, 46 insertions(+), 69 deletions(-) delete mode 100644 android/assets/mobs/char.png create mode 100644 android/assets/mobs/char/0_0.png create mode 100644 android/assets/mobs/char/0_1.png create mode 100644 android/assets/mobs/char/0_2.png create mode 100644 android/assets/mobs/char/0_3.png create mode 100644 android/assets/mobs/char/1_0.png create mode 100644 android/assets/mobs/char/1_1.png create mode 100644 android/assets/mobs/char/1_2.png create mode 100644 android/assets/mobs/char/1_3.png delete mode 100644 android/assets/mobs/pig.png create mode 100644 android/assets/mobs/pig/0_0.png create mode 100644 android/assets/mobs/pig/0_1.png create mode 100644 android/assets/mobs/pig/1_0.png create mode 100644 android/assets/mobs/pig/1_1.png diff --git a/android/assets/mobs/char.png b/android/assets/mobs/char.png deleted file mode 100644 index 382b6c73fcacd5c49c6b9df5fd457d2e95e2c502..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1397 zcmV-*1&aEKP)VGd000McNliru;sgs1CIXXHl-&RT1p-M# zK~!ko?O0D}990|gt%Vvflv1#_Q1OsU71~QLi-&qlFQun= z5b;oQu&06ngGetqs04ySFWQ17kk}YVl$NlNjhiOjKQr&m>tQmJnaS+Td%LsE8vJ0{ z*`4>k@BQBQ=l$NNpcCZg&EW4_w^G%ocLc~{aqrnM($#4gdm!H#?Bf8C(ST~5!sZ;D zbEt~*{?DfsC9LPIV|fk$HU|_%fvPCz%IdI~^L}BitOza0FoHl+7S(+qx&qr~sMaYo zRR!l(Xoswya>k;*8e zP+OJ`2Nq!i4oqAQzostFfdDAxd+qbr*OGpjHu#icVR zn)X7PvQ;tnaZj`&skXk zrl%Dd0zCnQn8SSR{M*Oh3ylw^O;0X^ototV)e{M`Y~dIhYL1YnU3g-1vK4@$lGaT_ zKz3?Y1jy~}=;t``k6T&kh+^aAWW#V31?S3QYbuOuxjLjqn<@QDLN;H zP>XnJr)I^5sQ+7y^^S}uCHdsb3|T#uqTrt+IX_IuWj7$oqqpZCNid!^S3y4@+1rP| zu)JJaC%7qbfZ72zvbqlcPAolRBW|2-c6LETQdT>8sK z3EG$(AH{@^U*8-1G;muI&Pmxzw70_z&ey2_;%vA#iYOaN=Xcu+kL#&M3lSw4iQ{6f zfqJ{W7)9tO$4B?|bVO|U$NOz0UFLfN^`Cpb7U#cI$1J2QU00000NkvXXu0mjf Dod=-Y diff --git a/android/assets/mobs/char/0_0.png b/android/assets/mobs/char/0_0.png new file mode 100644 index 0000000000000000000000000000000000000000..6ff1ff57a2f2ae0d836c7a6c373a758406ca89c0 GIT binary patch literal 340 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqY)RhkE)4%caKYZ?lYt_f1s;*b z3=DjSL74G){)!Z!AbW|YuPggw9&s)XWn*D`cA$`KW=KSdbAE1aYF-JD%fR4Vl$uzQ znxasiS(2gP?&%wlqL&I%xWm)MF+}3BZ=a;3zCk{&f3%vkh5rKv;h)Pa^| z^A0MX5wuy?nBczc?tfi2-lW#4Axn3!e$22!@|fpG4kac}28FdMcX|thHgO0Ztbg)* zx$#*y7Xb$`#sj*6MGLotolGh*K2tK$^94&*m(12P|DJYkziS)Y969$L*U4!|UO#S& z6rJtP7ta2GapHfuPlu1*tah@rw@j_xt=ReDqv?Z(-g-h)wk^8Wb@RyQud26ao31gTe~DWM4fP1k|( literal 0 HcmV?d00001 diff --git a/android/assets/mobs/char/0_1.png b/android/assets/mobs/char/0_1.png new file mode 100644 index 0000000000000000000000000000000000000000..5a3162528d1860732f775c6829890345b53dbf59 GIT binary patch literal 238 zcmeAS@N?(olHy`uVBq!ia0vp^EI`b|!3HE<7s&_%DYhhUcNd2LAh=-f^2tCE&H|6f zVg?4j!ywFfJby(BP>{XE)7O>#F^@PGr|#Je%8o!G+02lL66gHf+|;}hAeVu`xhOTU zBsE2$JhLQ2!QIn0AVn{g9Vi~;>Eal|aXmR@#rpr}8(1PFKp<{k3%7w{u>#Y4d*zDx z_Rd=sIE@THd{PSe@W}`yzOAEsv1Av|k)sz`68M5|b8c+yp4;7cGC{S6*^rxICoBKI TpPUijK-PM?`njxgN@xNAuO>$? literal 0 HcmV?d00001 diff --git a/android/assets/mobs/char/0_2.png b/android/assets/mobs/char/0_2.png new file mode 100644 index 0000000000000000000000000000000000000000..0eb4f935d652fcb44af0e2bc8816690f6113b000 GIT binary patch literal 234 zcmeAS@N?(olHy`uVBq!ia0vp^EI`b|!3HE<7s&_%DYhhUcNd2LAh=-f^2tCE&H|6f zVg?4j!ywFfJby(BP>{XE)7O>#F^@PmuguQ_JsvEal|aXmR@#rpr}8(3yYfI!^7mV_M)ZCok`ZpdZ* zoj<>ucVW}~?%s!wx5w|;x`3nR&o^$Rh9tI4Ty=V8Y-%$a4Q6phPHSvzWMmM#D*SeW Rm)SRvm7cDCF6*2UngHT{XE)7O>#F^@PmAIAxE?r%UL+02lL66gHf+|;}hAeVu`xhOTU zBsE2$JhLQ2!QIn0AVn{g9VqVL>Eal|aXs1Og2u1^Z=ZX!>6I0-fq)vDiNg{G@!b}O zx6juXWHR9E68p35K#HVmIWzJJ1WkR_h3elF{r5}E*r CKt2%w literal 0 HcmV?d00001 diff --git a/android/assets/mobs/char/1_0.png b/android/assets/mobs/char/1_0.png new file mode 100644 index 0000000000000000000000000000000000000000..2995fa703d84beacf09327e6acc348065605ff62 GIT binary patch literal 338 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqY)RhkE)4%caKYZ?lYt_f1s;*b z3=DjSL74G){)!Z!AbW|YuPggw9&s*C(Wjec-vMX8A; zsVNHOnI#zt?w-B@DSD~wK=Ey!E{-7*mwo%JgP0se7=E9%DRUHJ>h<6_;-41jn(~Cz zreWjrPiDtrTC~h2EGqj}%VV(M^1B63GixU^OjJ-35fs~NWXT}1?u1X4<{WqBLoY)D z)_P_0JyrT_FB2^=amCI+uhg(s5d(9f#Cw{d+FT75!44@0ZGTqPKg`?t{XE)7O>#F^@PG7suL}OO67CWHUn|N}Tg^b5rw5fLsO!=c3fa zlGGH1^30M91$R&1fE2w{cA$8ar;B3<$Mx8r)0_ts1X$I(6*#KzvFRwtM)_BHG0$T? z7+iGX{MkGA$`?*)Zm(5m2zZ_Pq-W0~w+vqUz*MtZXHmziwJc}sQrkW_KNC?{6TP_K gt*g^+)%+zHbIQ`h&z$0QeFC!H)78&qol`;+0PiMFPyhe` literal 0 HcmV?d00001 diff --git a/android/assets/mobs/char/1_2.png b/android/assets/mobs/char/1_2.png new file mode 100644 index 0000000000000000000000000000000000000000..d0701b5e5e5d7ddf9a9153511de302d96e49896a GIT binary patch literal 234 zcmeAS@N?(olHy`uVBq!ia0vp^EI`b|!3HE<7s&_%DYhhUcNd2LAh=-f^2tCE&H|6f zVg?4j!ywFfJby(BP>{XE)7O>#F^@Pmuf@^B88d-GvY8S|xv6<2KrRD=b5Uwy zNotBhd1gt5g1e`0K#E=}J5b!u)5S4_<9c$6hwtC>4J ze|~$j=)$J<=BW=)_ut>Kbpc1s&yUhd4M}X9xa9c4*wkh;8qDI1oYvUb$jET}uyDWr S0-L!YD?MHPT-G@yGywqmKuMSY literal 0 HcmV?d00001 diff --git a/android/assets/mobs/char/1_3.png b/android/assets/mobs/char/1_3.png new file mode 100644 index 0000000000000000000000000000000000000000..c0ef26c076837a956f16376d8dfec1baf9271768 GIT binary patch literal 220 zcmeAS@N?(olHy`uVBq!ia0vp^EI`b|!3HE<7s&_%DYhhUcNd2LAh=-f^2tCE&H|6f zVg?4j!ywFfJby(BP>{XE)7O>#F^@PmueM{YraMqbHZvrm#5q4VH#M&W$Yo$~E=o-- zNlj5G&n(GMaQE~LNYP7W2Z}p*x;Tb#Tu%-O?)dlr@%3mnKC?tN5KvVGd000McNliru;sg{94KY(qC0qai1`bI? zK~z}7?UzfBTvru^zw@}Ss;+)izuXRr1Q8YpCYJIikeDJSC7iBqYp613}2iu=UMv7@m+kfGtbflLOMMMcYIk1}1(NlEFC3lavKe z2UWewJ4cEAZo$gN2J@RY>F(S{`}AZD9A3SqoCN-HW1rXm{0Bl0c*}TekNV;sZtR|@ z0gn^#o;(Z~z&Rxk1J)I=7?5nZ@zP5=-dG{sJ3;y$Q-TW>s&m4k$BjU{1d9Q)JHcd+ zUs*wBE%Ow)^s8T+hZ_(FBgdD%{2Z_U^^dqB<9&(51m1vCs;UA!vwL^Rl8C)hl|npe zQOUS_iQyz*nv&^SjW#8ufDFR=h3V1>7=ZoX{6eJ{R(CIutl)d$-i;fqKeJ67GN$jy zYVeZ5WH5%*_h<;Hap-J7+hhE6#E=xP77B+k;EI~vmtTJP1P-rWBP#e!Lyi&K16f$R zcmaCBs)BX6n2AHe)^POhEqoIC5HKmCN!Z-lL9~Ew24#hxt|BKrW~Dki17%T}zrTH* zH{bXZmoGoh7j`$Xu0RWm&5ksv7F(YDUckAE_01iuH%wAbY6pl02?Jg5!fbq&8A)jPb*ObRC(DOR(rVD!@66s!LmB&0sv)TA(`n6z_cNg{2?e`q`_- ztb1(NK~uq^$9j*Z9<9deR!11?IeO8;w7W|u9ck9n ztTq(&I`hN3kTTh>QfcI|4M-fYO+nR6S$p>V4AcW_8&mpLh;7T-=9J(@ym4b6=N->~ z{#kGZVSjcujLy=s43u?=4H2u3adXOzzr6J(f4jL4K>geob?F3dUwK7MWLSbA}P{DY{-bF)Ay6|<2NE10=Nc07$gbZ>;TCL zFCH}!&6%i~!h7T}Vr`~gonoCOtNj!znYRp!Id0^Uu%Mc5Qlw0Xk)kQFLqG;YY#dD+ z!M?xmd8DwJr~1Fwr~1ov>&j1Yb@>sRH%8Pe>mQ2DG#Z{)(zQ#`{Kz;yw}D`m zqWO_=d|sV}=EJMkmQUdJl~*_qnsZd_2%NRZeP|vY0nHy@!2{4d*}bSBsH^aGL7JVI zWoUlw?YESeq4Zei2r-&vX#SW1=RgKwygU66%|yYijTsgJXA5+ZPtiOwNEaX*{5(ME zI6k-uqL`*aLc|)!_rCH~WY*&*6E?p6!txA!faa(M`ov;(aM}xE!aI*xXwyA}migTU z8anU_e1v8I6~S6ZHh@vIG!I4d|4iTkXwE`z2ec~jNtmo{E<-av|N7U^0q_o+GdnN7 zc>Y%WAT+y}$kyYmCG`PfUW#U$Git#YPmbvvG`!!y1JGQT6{hgSzQtA*NB`Mhie^cI zahA-0^~EPM@E|n%lud|{!j;%|&e~*qDVl%yyWg9qgnO!|`Xu@<8$PzXDN%rj00000 LNkvXXu0mjf&cF*X diff --git a/android/assets/mobs/pig/0_0.png b/android/assets/mobs/pig/0_0.png new file mode 100644 index 0000000000000000000000000000000000000000..75c3b89dcdaa6d252daf1d452da100af630383fa GIT binary patch literal 761 zcmVP000aK1^@s6m+}@%00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY4#NNd4#NS*Z>VGd000McNliru;|v!I5)#uQuh9Si03B&m zSad^gZEa<4bN~PV002XBWnpw>WFU8GbZ8()Nlj2>E@cM*00Lb}L_t(I%caxJid;n) z#_|7KRp(=-yOZgep3Fyu;&qsOPrxgv3*nh>;t zR1l%Wh^2&y$F><8?+C|-cYatQ+ih;O^a9 z$~e=k7lfSAX`)i`1%_#&1H2CmHgj}*iEayY@~;X1W#YV=tFV84M}OMGU1TD&@GT`p z#5~S9k|iVu+O|RG2z`TKAI{h=Pgy;_pjyF2gQ`5dJckHQjk+%om9`7`p@0MqT!VUt rbcZ00S}RQrbRTc1RzU*QIiTYoR{~(G{EY|l00000NkvXXu0mjfhhjXHn7EVZ&O!#69xOjG15T z$}jYkym=BOc=_b@PF{9)#xP000aK1^@s6m+}@%00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY4#NNd4#NS*Z>VGd000McNliru;|v!I5(!yHW<3A^03B&m zSad^gZEa<4bN~PV002XBWnpw>WFU8GbZ8()Nlj2>E@cM*00L%7L_t(I%Z-xFZWKop zMo-h9{X$M#rYKoL?B5h=?^yb{VgMC_xmfcHXzY_bD^5?KLZTOLnlrhlq#-E7D@ z^S!{)cXS*F?DKCgiK{^Vbc;_dx*L(;urgxp!hF}@B(VPL6X~p{J36HX4+{Cql?#VJ z;#tIQcii1vQTCa5wjj(iIt=s|7YsU3HX~`7h}|jM+iNJ5Doa|+90bukBPr6R6(^57 zxEmR|nUk{><6g=8JtyZYCg1bs&r5vpJbm&Qd}O-ZAcsKew!o+~ZNTpexImJKdZFnW zWXgzn7Rdwf`j5B#{`VyS-Sgf zj8@4XuSpN?p|#+~j9CQ{7z;Wpp;rPSV%6Aw_yBzi6xbWI4zEV{@FC&~;vAF!oyYEW zjD3TzAWdL%^_g0P<+qQhs!Tca(+}T)7f_G8dHKq8E?84>sfE#S|7p^S_=pV|-*>o$ zLx&lg6sXX6*6-dEx=6n~hvR_zr{K~8=N$g{nAOkETu=(WjSO|B84J738mmHRJT_&B zf|=5D%6JW3C=enPPu?*lsR zXjkXNQkillrUscObav$AN&5`))&DjV<*+CJ0s%rgW&KhlLI3~&07*qoM6N<$g2$~+ Ax&QzG literal 0 HcmV?d00001 diff --git a/android/assets/mobs/pig/1_1.png b/android/assets/mobs/pig/1_1.png new file mode 100644 index 0000000000000000000000000000000000000000..c549d26759395af6878d82cf9f4321024e7eb313 GIT binary patch literal 226 zcmeAS@N?(olHy`uVBq!ia0vp^EI`c0!3HFsSlX9@I7!~_E)4%caKYZ?lYt_f1s;*b z3=DjSL74G){)!Z!AbW|YuPggw9&v6#Mfdx2LB_~thD4M&=jZ08=9K`s3=Gaisfi`2 zDGKG8B^e6tp1uJoda3L{aW_vF#}JO|tOpx;8yq-T4nF;n@#eyjSvfyi56`TaU;TsU zxYNuIxkpxok~~Z^@|GN7oMm{gS8~I|91%6;8S4YWjd^2dN1Wtma#ho0`yXx(vdYud K&t;ucLK6V! blocks = new ArrayMap<>(); private static final ArrayMap items = new ArrayMap<>(); - static boolean isFluid(int id) { + public static boolean isFluid(int id) { return getBlock(id).isFluid(); } - static boolean isWater(int id) { + public static boolean isWater(int id) { return getBlock(id).getMeta().equals("water"); } - static boolean isLava(int id) { + public static boolean isLava(int id) { return getBlock(id).getMeta().equals("lava"); } - static boolean isSlab(int id) { + public static boolean isSlab(int id) { return getBlock(id).getMeta().equals("slab"); } - static boolean fluidCanFlowThere(int thisId, int thatId) { + public static boolean fluidCanFlowThere(int thisId, int thatId) { return thatId == 0 || (!getBlock(thatId).hasCollision() && !isFluid(thatId)) || (isWater(thisId) && isWater(thatId) && thisId < thatId) || (isLava(thisId) && isLava(thatId) && thisId < thatId); } - static Block getBlock(int id) { + public static Block getBlock(int id) { return blocks.getValueAt(id); } - static Item getItem(int id) { + public static Item getItem(int id) { return items.getValueAt(id); } - static Block getBlock(String key) { + public static Block getBlock(String key) { return blocks.getValueAt(blocksIds.get(key)); } - static Item getItem(String key) { + public static Item getItem(String key) { return items.getValueAt(itemsIds.get(key)); } - static int getBlockId(String key) { + public static int getBlockId(String key) { return blocksIds.get(key); } - static int getItemId(String key) { + public static int getItemId(String key) { return itemsIds.get(key); } - static String getBlockKey(int id) { + public static String getBlockKey(int id) { return blocks.getKeyAt(id); } - static String getItemKey(int id) { + public static String getItemKey(int id) { return items.getKeyAt(id); } - static int getBlockIdByItemId(int id) { + public static int getBlockIdByItemId(int id) { return getBlockId(items.getKeyAt(id)); } - static int getBlocksSize() { + public static int getBlocksSize() { return blocks.size; } - static int getItemsSize() { + public static int getItemsSize() { return items.size; } - static Sprite getBlockTex(int id) { + public static Sprite getBlockTex(int id) { return getBlock(id).getTex(); } - static Sprite getItemTex(int id) { + public static Sprite getItemTex(int id) { if (items.getValueAt(id).getType().equals("block")) { return getBlockTex(id); } else { diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java index 3eb10eb..70879e4 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java @@ -2,7 +2,7 @@ package ru.deadsoftware.cavedroid.game.mobs; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Vector2; -import ru.deadsoftware.cavedroid.misc.Assets; +import ru.deadsoftware.cavedroid.game.GameItems; import static ru.deadsoftware.cavedroid.GameScreen.GP; @@ -37,7 +37,7 @@ public class FallingGravel extends Mob { @Override public void draw(SpriteBatch spriteBatch, float x, float y) { - spriteBatch.draw(Assets.gravelSprite, x, y); + spriteBatch.draw(GameItems.getBlockTex(11), x, y); } } diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java index 89b20e1..a52d920 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java @@ -2,7 +2,7 @@ package ru.deadsoftware.cavedroid.game.mobs; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Vector2; -import ru.deadsoftware.cavedroid.misc.Assets; +import ru.deadsoftware.cavedroid.game.GameItems; import static ru.deadsoftware.cavedroid.GameScreen.GP; @@ -37,7 +37,7 @@ public class FallingSand extends Mob { @Override public void draw(SpriteBatch spriteBatch, float x, float y) { - spriteBatch.draw(Assets.sandSprite, x, y); + spriteBatch.draw(GameItems.getBlockTex(10), x, y); } } diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java index 5f73a6b..698ebef 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java @@ -21,6 +21,7 @@ public abstract class Mob extends Rectangle implements Serializable { private Direction dir; private boolean dead; private boolean canJump, flyMode; + /** * @param x in pixels * @param y in pixels diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Pig.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Pig.java index e37ab3e..394d9be 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/Pig.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/Pig.java @@ -46,16 +46,16 @@ public class Pig extends Mob { pigSprite[0][1].setRotation(getAnim()); pigSprite[1][1].setRotation(-getAnim()); //back legs - pigSprite[1][1].setPosition(x - 4 + (9 - dirMultiplier() * 9), y + 6); + pigSprite[1][1].setPosition(x + (9 - dirMultiplier() * 9), y + 12); pigSprite[1][1].draw(spriteBatch); - pigSprite[1][1].setPosition(x + 17 - (9 * dirMultiplier()), y + 6); + pigSprite[1][1].setPosition(x + 21 - (9 * dirMultiplier()), y + 12); pigSprite[1][1].draw(spriteBatch); + //head & body + spriteBatch.draw(Assets.pigSprite[dirMultiplier()][0], x, y); //front legs - pigSprite[0][1].setPosition(x - 4 + (9 - dirMultiplier() * 9), y + 6); + pigSprite[0][1].setPosition(x + (9 - dirMultiplier() * 9), y + 12); pigSprite[0][1].draw(spriteBatch); - pigSprite[0][1].setPosition(x + 17 - (9 * dirMultiplier()), y + 6); + pigSprite[0][1].setPosition(x + 21 - (9 * dirMultiplier()), y + 12); pigSprite[0][1].draw(spriteBatch); - //head & body - spriteBatch.draw(Assets.pigSprite[dirMultiplier()][0], x, y); } } diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Player.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Player.java index cfa1cd8..fd7101c 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/Player.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/Player.java @@ -9,8 +9,8 @@ import static ru.deadsoftware.cavedroid.GameScreen.GP; public class Player extends Mob { public final int[] inventory; - public final int gameMode; public int slot; + public final int gameMode; public boolean swim; public Player(int gameMode) { @@ -74,20 +74,20 @@ public class Player extends Mob { } //back hand - Assets.playerSprite[1][2].setPosition(x - 6, y); + Assets.playerSprite[1][2].setPosition(x + 2, y + 8); Assets.playerSprite[1][2].draw(spriteBatch); //back leg - Assets.playerSprite[1][3].setPosition(x - 6, y + 10); + Assets.playerSprite[1][3].setPosition(x + 2, y + 20); Assets.playerSprite[1][3].draw(spriteBatch); //front leg - Assets.playerSprite[0][3].setPosition(x - 6, y + 10); + Assets.playerSprite[0][3].setPosition(x + 2, y + 20); Assets.playerSprite[0][3].draw(spriteBatch); //head - spriteBatch.draw(Assets.playerSprite[dirMultiplier()][0], x - 2, y - 2); + spriteBatch.draw(Assets.playerSprite[dirMultiplier()][0], x, y); //body - spriteBatch.draw(Assets.playerSprite[dirMultiplier()][1], x - 2, y + 8); + spriteBatch.draw(Assets.playerSprite[dirMultiplier()][1], x + 2, y + 8); //front hand - Assets.playerSprite[0][2].setPosition(x - 6, y); + Assets.playerSprite[0][2].setPosition(x + 2, y + 8); Assets.playerSprite[0][2].draw(spriteBatch); } diff --git a/core/src/ru/deadsoftware/cavedroid/misc/Assets.java b/core/src/ru/deadsoftware/cavedroid/misc/Assets.java index 1e53141..335e3c0 100644 --- a/core/src/ru/deadsoftware/cavedroid/misc/Assets.java +++ b/core/src/ru/deadsoftware/cavedroid/misc/Assets.java @@ -21,8 +21,6 @@ public class Assets { public static final HashMap textureRegions = new HashMap<>(); public static final ArrayMap guiMap = new ArrayMap<>(); private static final GlyphLayout glyphLayout = new GlyphLayout(); - public static Sprite sandSprite; - public static Sprite gravelSprite; static BitmapFont minecraftFont; private static TextureRegion flippedRegion(Texture texture, int x, int y, int width, int height) { @@ -41,34 +39,14 @@ public class Assets { return sprite; } - private static void loadPlayer() { - Texture plTex = new Texture(Gdx.files.internal("mobs/char.png")); - //LOOK TO LEFT - //head - playerSprite[0][0] = flippedSprite(new TextureRegion(plTex, 0, 0, 12, 12)); - //body - playerSprite[0][1] = flippedSprite(new TextureRegion(plTex, 0, 13, 12, 12)); - //hand - playerSprite[0][2] = flippedSprite(new TextureRegion(plTex, 25, 5, 20, 20)); - //leg - playerSprite[0][3] = flippedSprite(new TextureRegion(plTex, 25, 27, 20, 20)); - //LOOK TO RIGHT - //head - playerSprite[1][0] = flippedSprite(new TextureRegion(plTex, 13, 0, 12, 12)); - //body - playerSprite[1][1] = flippedSprite(new TextureRegion(plTex, 13, 13, 12, 12)); - //hand - playerSprite[1][2] = flippedSprite(new TextureRegion(plTex, 37, 5, 20, 20)); - //leg - playerSprite[1][3] = flippedSprite(new TextureRegion(plTex, 37, 27, 20, 20)); - } - - private static void loadPig() { - Texture pigTex = new Texture(Gdx.files.internal("mobs/pig.png")); - pigSprite[0][0] = flippedSprite(new TextureRegion(pigTex, 0, 0, 25, 12)); - pigSprite[1][0] = flippedSprite(new TextureRegion(pigTex, 0, 12, 25, 12)); - pigSprite[0][1] = flippedSprite(new TextureRegion(pigTex, 4, 26, 12, 12)); - pigSprite[1][1] = flippedSprite(new TextureRegion(pigTex, 16, 26, 12, 12)); + private static void loadMob(Sprite[][] sprite, String mob) { + for (int i = 0; i < sprite.length; i++) { + for (int j = 0; j < sprite[i].length; j++) { + sprite[i][j] = flippedSprite(new Texture( + Gdx.files.internal("mobs/" + mob + "/" + i + "_" + j + ".png"))); + sprite[i][j].setOrigin(sprite[i][j].getWidth() / 2, 0); + } + } } /** @@ -95,13 +73,11 @@ public class Assets { } public static void load() { - loadPlayer(); - loadPig(); + loadMob(playerSprite, "char"); + loadMob(pigSprite, "pig"); loadJSON(); minecraftFont = new BitmapFont(Gdx.files.internal("font.fnt"), true); minecraftFont.getData().setScale(.375f); - sandSprite = flippedSprite(new Texture((Gdx.files.internal("textures/blocks/sand.png")))); - gravelSprite = flippedSprite(new Texture((Gdx.files.internal("textures/blocks/gravel.png")))); } /** -- 2.29.2