From 2413c7d3d4125d9bf3d7b502b136cd47a6dc6e6b Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Sat, 9 May 2020 19:34:43 +0200 Subject: [PATCH] Added flowers (+ basic simulation). Added resource loader (load list of textures). --- cmd/tins2020/res/images/flower_purpleA_NE.png | Bin 0 -> 1158 bytes cmd/tins2020/res/images/flower_purpleA_NW.png | Bin 0 -> 1132 bytes cmd/tins2020/res/images/flower_purpleA_SE.png | Bin 0 -> 1222 bytes cmd/tins2020/res/images/flower_purpleA_SW.png | Bin 0 -> 1112 bytes cmd/tins2020/res/images/flower_purpleC_NE.png | Bin 0 -> 1146 bytes cmd/tins2020/res/images/flower_purpleC_NW.png | Bin 0 -> 1150 bytes cmd/tins2020/res/images/flower_purpleC_SE.png | Bin 0 -> 1191 bytes cmd/tins2020/res/images/flower_purpleC_SW.png | Bin 0 -> 1135 bytes cmd/tins2020/res/images/flower_redA_NE.png | Bin 0 -> 1182 bytes cmd/tins2020/res/images/flower_redA_NW.png | Bin 0 -> 1192 bytes cmd/tins2020/res/images/flower_redA_SE.png | Bin 0 -> 1220 bytes cmd/tins2020/res/images/flower_redA_SW.png | Bin 0 -> 1171 bytes cmd/tins2020/res/images/flower_redC_NE.png | Bin 0 -> 1202 bytes cmd/tins2020/res/images/flower_redC_NW.png | Bin 0 -> 1173 bytes cmd/tins2020/res/images/flower_redC_SE.png | Bin 0 -> 1205 bytes cmd/tins2020/res/images/flower_redC_SW.png | Bin 0 -> 1189 bytes cmd/tins2020/res/images/flower_yellowC_NE.png | Bin 0 -> 1081 bytes cmd/tins2020/res/images/flower_yellowC_NW.png | Bin 0 -> 1056 bytes cmd/tins2020/res/images/flower_yellowC_SE.png | Bin 0 -> 1102 bytes cmd/tins2020/res/images/flower_yellowC_SW.png | Bin 0 -> 1030 bytes cmd/tins2020/res/textures.txt | 74 ++++++++++++ cmd/tins2020/tins2020.go | 50 +------- flower.go | 46 ++++++++ game.go | 109 +++++++++--------- math.go | 30 +++++ noisemap.go | 52 +++++++++ projection.go | 2 +- resourceloader.go | 51 ++++++++ terrainrenderer.go | 20 ++-- 29 files changed, 326 insertions(+), 108 deletions(-) create mode 100644 cmd/tins2020/res/images/flower_purpleA_NE.png create mode 100644 cmd/tins2020/res/images/flower_purpleA_NW.png create mode 100644 cmd/tins2020/res/images/flower_purpleA_SE.png create mode 100644 cmd/tins2020/res/images/flower_purpleA_SW.png create mode 100644 cmd/tins2020/res/images/flower_purpleC_NE.png create mode 100644 cmd/tins2020/res/images/flower_purpleC_NW.png create mode 100644 cmd/tins2020/res/images/flower_purpleC_SE.png create mode 100644 cmd/tins2020/res/images/flower_purpleC_SW.png create mode 100644 cmd/tins2020/res/images/flower_redA_NE.png create mode 100644 cmd/tins2020/res/images/flower_redA_NW.png create mode 100644 cmd/tins2020/res/images/flower_redA_SE.png create mode 100644 cmd/tins2020/res/images/flower_redA_SW.png create mode 100644 cmd/tins2020/res/images/flower_redC_NE.png create mode 100644 cmd/tins2020/res/images/flower_redC_NW.png create mode 100644 cmd/tins2020/res/images/flower_redC_SE.png create mode 100644 cmd/tins2020/res/images/flower_redC_SW.png create mode 100644 cmd/tins2020/res/images/flower_yellowC_NE.png create mode 100644 cmd/tins2020/res/images/flower_yellowC_NW.png create mode 100644 cmd/tins2020/res/images/flower_yellowC_SE.png create mode 100644 cmd/tins2020/res/images/flower_yellowC_SW.png create mode 100644 cmd/tins2020/res/textures.txt create mode 100644 flower.go create mode 100644 noisemap.go create mode 100644 resourceloader.go diff --git a/cmd/tins2020/res/images/flower_purpleA_NE.png b/cmd/tins2020/res/images/flower_purpleA_NE.png new file mode 100644 index 0000000000000000000000000000000000000000..08c992b8e42186d67ba13e9b4329e0302a5e448c GIT binary patch literal 1158 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&w@L)Zt|+Cm0wQcLw-`xVjhkOs;)3rQuCQ z#(vek^D`or%5+y`L@Zy@`#(Km$?Vqe>5)t4b^PnDcrc^s)5=NzC)K@D-8HwX{I2Sb zxl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m&eJ%yQel3F;*uWCQ)_hZ?^9VnP4B^e z&6BH@R!-1+bWr!s9*yHGmDf%N1}`ui~)y>_%LBvGLCqFdAM z-PSDA|9meizxB8&yP({=K>daH;p79W_Ntry599S)2()>SfdlsGAMdzc4&lhYH>qf6 zO=h2XN9Mmn6F1+rwY@9u=PRPTh;`}d=jUVg7JYp3GC9e`WOLBVw{NY=m0r)$a`QO4 zZ{L-v>6Lb|-4oQ7PVtJI7pk5uc&R1H>u==SAAy=lv*vcK+ply?GgH`)KCIFUR)Ew${c+@4w$?H&J;}ul0A4J`?Hqy1ln|m)SlahLBVu_*p*8hKT?|-0rl?~HW z)=yPhIRR)j&@pOz7PJ;!nc4CUXp!=UY07J-s2^McbU)DLYCGov9jv@=sv6Lo9dlK; z%u?ICKzZF1pi|WkELL7KNoiT1;*uVztLlwGL4e=*Rf>W7vBeF5~>-1gry zTfWX|`=!2k;_S9xGn&6NmtAcuxzSv3aY^6*S*<@B^3F|b{Ae(JQg_wW*5Ye3nm*6( z{Ig=>{{<6XOl^2SyY1)BHDB9Gt}p8OKcV*FseS(!cK`qM{{Ms9-wP5p@8AA#di%YF zJ%8W7`3($#l$a&ER{i_;@Bh(l|8wKkr9~`mDL=4g*5A*yYuka5YFQHG7tD|x@V@&g z7nj`B+j2JLQS*)F|CH;VZF!Z?7IL5@i%0m{XF~HitX96WIpD+(yi0~QvLbKIU!S~TYnzk z{q6Md_VVrD^YsFh7xjKUZ*TuZ|C99QtsI%od+&v>4Ea>ENz8EV{ZC6@AN*P~M@X>u zuW|PK*qM5+K9g^Wse4|l%jgg>A&BdGhY5Y_2tf=MJy&sw+}v>COlVs(-zO3 zj<&b2>lv*3=A0MH6ukW5ul40m>n=H|9+I*uI`AOSh~`o9fA#&v+2+RWC9P^8yF6X} KT-G@yGywochumNQ literal 0 HcmV?d00001 diff --git a/cmd/tins2020/res/images/flower_purpleC_NW.png b/cmd/tins2020/res/images/flower_purpleC_NW.png new file mode 100644 index 0000000000000000000000000000000000000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Gh&wpPls^ z=}hc-&ExN1cs*m_HT&Z)&s!`5S?1~L=d#Wzp$P!5Zm)&_ literal 0 HcmV?d00001 diff --git a/cmd/tins2020/res/images/flower_redA_NW.png b/cmd/tins2020/res/images/flower_redA_NW.png new file mode 100644 index 0000000000000000000000000000000000000000..36992c900d9e4300a03c4b6e44ce1259e64ca2cf GIT binary patch literal 1192 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&w@L)Zt|+Cm0wQ&jt8|xVjhkOfoQ;XkfC& z!uEozm%{w^`ESok z&~%fv{be`r4OaH*2bR3`4*^PP?45ts*-LfjT-68ViNG6TrfKD|!k=n9pM(`CBKRJYC6Jh4h`$6Sp=OI5edQrR*~ zb=Q2E?h2L7Gu3v@mz`9rw6sTIc8kLDeuef5sm46@!^`AnH7l)}q_TRlWOWwM+4sHt zfldW_N~Wh=Zc5!uou3;ipzQ@ z0M&Pw1Dzz>SE+Mjht92Cy0>=S^YY(o?{e4EZ@#HzzrOJmH=h;eHmfad`}B>EIJ({O z^!pGH_TE4AsZY>uJLd;p0X=#~54{2&c?aI~@ICC{deYfrhpiJZ1mq^ycA8lzF6p`8 z6QFZ*Cop6bI!gRHE0vb_DX*TSvSFIi(q7sAYMH)DxoHhbEBe)T&Qo06t+sc8>h?K6 z-^os>mgz17Mvd&mYK3`i8b_AvT;C21Ox-(s@Kl#NENV~yP#V7hVfba4!+xb^mG@+=ufiPnpKxwp5? z?Oe6$uI;xY+j4K;%H7oS#{VYQV4<^MM7u3eiudAWw* z$c3Xyj@oNNW)Ocs%XW}M;|Xg*Ne5ackAi+Woj;KTlw}=>!pW`NiHTPo}YY| zZwjgk=$_D~`cq})l1!_B?is(-f7V#~Zax@v#N^$3_9>fnr1e~VE?a-{v^;C1y6BX; z?9?qLaUCnf&h8G~X&l_XW7?g1gZS11VrAE+uM)VvD(mYv8OcMl3K#!QtM2DZJi9Ag zW83|!ifgX+@9tV(RoantaIyN_qgC?-5^ZbZH2(eDrak?(N%gA}j#Vw67ybVG{n)*~ zJKyHVotIT~H_*PGdn4laug&+i=YQ|Zo&B{V{pYRey{-Mdw$*%ZM3t8uZB4%#KYw3N z?gXV3sap^2=C?2761>(Gb^Z4F=n{^cvzNar(LBQbueCoJ=}?obJF^*Nm#3?r%Q~lo FCIAPzvd;hj literal 0 HcmV?d00001 diff --git a/cmd/tins2020/res/images/flower_redA_SE.png b/cmd/tins2020/res/images/flower_redA_SE.png new file mode 100644 index 0000000000000000000000000000000000000000..2cdf374898e387f146d1e756bc7585293d52f802 GIT binary patch literal 1220 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&w@L)Zt|+Cm0wQuLt;qxVjhkOfoQ;Xkc=| z#p|k@&wbB;H5Rs$4NUesIB4viufBhg!kpHL2FCZi{3jV0Yn@xKeQ}e<`svCmCakuw z(Ym-RoDPea^*8H=L7?jd!GJ4XY1VDxzfT$=f;k^p8of}{DI;h1H!bgY*k#+ zqqw+R(`(fBEKonR6zEOWZL|CJjr;VCb#Lv`y0}Ss?PRU<8&&|dU)v6J3DEtz zw|B|UZqdHHMSe!(O%LCL_O9v&mjWFC^!{xRzenDIS{FBJ9A2h#Yu5v>0L?RNHBYQk znBB71&UucB1u&q_ID5*^Y+7Yu)2nX`bomx*2cR#suWwi0Fcs+WSH8jT{X?Jo20!%) z(m1~ImWQ9_$<W7wHjw#{* z#_8P4W zn7a3UW8+G)5S5Q;?~=%q2bYi0u2{KG)v3N%csxw zW>VQ7TB$v-k9$|D7FKY$OS^e^7ycnaXBUI|M5Jyw=vvU%Qbh@c90B zcP_V2?a#Y6Hvjs0L=*s!q`tPTD&=Hfe2TU?PZC-*Qu161u8@P2Y*!DHPp=J^= zepgJgz4`6W?7L1!wtoJ3JXVWk+v3&b-CT{i_16uZTMuk|b}2^9IPsN-X40%V%U)jE z`Fr(oPr)-kj&A;MmpN;9RCM{L10t?Xkr%^)w=XccT%&W=Hgm-~L6tc#b=9+`r_b8G zJHA{jI{cO3`8CS!>vP}y`0)7m_EqewpKxT{+}n2T-n#F(bN8=0!jbv*{ds%t)@j@4 zn`H=IT4WtRf3H?pt>(GwO3PZO$L)FZ($dpd_3W#%@kEo?Nl&%fdB3lu!$;M${SbkWu8w6mw$?)hh(J)U?6=v?3a%qQrr zU+8n+pu>)CTIV;aZJ!M^XQF|L!mJjR_0u#@tk%A=Mf3Dpjl;`iy2`XJZdTboAIJbA z?Ms_=ZtPfBkgc?$UvY7_%BJb6TW4t;S+0Fylg8oYip%?f43*8Z71}FQ)=$?uyI!`p zLVe#NneKA614~pkPM4cpt9fjtOm`X3u6v&TD=lp9divk@@|Wo-`4|ue^a#)jy@&gO zwgCOor*AyLz+{z$jqd$@K*#7k*sptMw@ha#&{)042er;`(7n4y>%zwCZa#NC{jRwA zJoE~E2!^mupowMf2)fQK_t+22OoZX>ue5JF!Z?CbINjnNS9OSh=0|X|!H>E_UmCcwr^JL;P84D}7PrF`m z?EihXWEvyT_Q3=`_|LX0ZR05Pofoz;WY%#m!OKfNUOzW~cfre?x{@Ulg1y>)aeJzM zo|>tAoWE1>;s)X6QBhr&+r8P{y9I;1R&KSJ_I#;eREvp;=@O;&>+|K7x_USVWodk} zu~%^QNzUTF5T^CiuVI6`Lw45cT1Me199d;vu5Vcjm|9GqKRkPU^%?sOPq*i-2~pf| zw0u|Cm6HP3H@%))KK+D1`1i@|-}CjaDy}*9-2b-qv)2OUjBK-S$?INHTyy^Fy=8sX z=MEIST6QL8hu!IIW?|L$zuR0^p4Z8}Dt}wb?p^Fw`}frl}htx6R+be~;8U k=a|{|B<*P(TOZ_qbLaJ0w}p!S76IAi>FVdQ&MBb@07Ad8$^ZZW literal 0 HcmV?d00001 diff --git a/cmd/tins2020/res/images/flower_redC_NE.png b/cmd/tins2020/res/images/flower_redC_NE.png new file mode 100644 index 0000000000000000000000000000000000000000..bd6c52a7dbd43d1115f4bcdc8fe268f5e2959398 GIT binary patch literal 1202 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&w@L)Zt|+Cm0wQ?*{m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q>4d_Ck%VpY&fnGS}>><-tDmSS{`|_4Y-hpzHYJpCY?X8sQDSzu1a^A)3 zjbDhu{0^NPJ6`*SD9mluxwT7SVdo2<;6o0suY7~$r#C7t?a{fm9TY^HW+=>S*S@s* zjEm=UpP>7dwU506&jd$Ew--P04*L7`>)Uw?f#G~UIzfI$<4OzL?>ly{wzPeJ=9Z})&a;ipUtha6)yVYx{Dp;H?zT3*YTAiQ~jf+=HBjppL^WREg(uG;HSvXl%FX!7d7_o z-5b!ItKn}W@;*Rh@9n9LQ@cfOdoR7t2uv^*o-U3d6}R4AeHs!$JyY^*jpaeF!z@P3_>F2~1*WK*aE8V(9W{y$W z4lzdGIpyDuHP3VREJ}J`VagO$@Gol8p8AWoi{BlXS6Fmp^A7Eoe+@po`+4~FPvzjJ z954P|Hs7r^&(`m9WERVow{PFipTDpEZT(C=LFGle58k89f@HjPWX@3g?R6^EC$9Sf5^ zG;8<&jN-?xKt`b6oHsi*d3LPe-|+s%%x^K@rBoN)s$DhXZ0UMorB#{BXK&tlZR^b5 z@>#Rodafx?QxrCu%qM!gxOTO9d5PY9We*eO_N)Dw+G*?W?Jg}o8f57tWwleWdgteF oUaF5~#l?j!1(gIe1t0eR;?DVI-KW!jbS}suPgg&ebxsLQ0A^FT)Bpeg literal 0 HcmV?d00001 diff --git a/cmd/tins2020/res/images/flower_redC_SE.png b/cmd/tins2020/res/images/flower_redC_SE.png new file mode 100644 index 0000000000000000000000000000000000000000..b5ef78659d81fc6f523685417725812e7410f087 GIT binary patch literal 1205 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&w@L)Zt|+Cm0wQ9|!n^xVjhks2^COx@o%R znRS|{)@baWuW@3P#`@_R`{!#MTdB07A1JPMeuL_^Ir6hwv@UMc0xCPcQhD7Jh2{M+ z-4#l!CaE7-yx+kU$W=eIOu9K=6R7>ja-f--C)a45+aTLhG0DIfD5AP~rc76v(#naG z4NO#b%z5u0de_r`y_LfOdzX{W9#4FNfVTJR8^7=ky65S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YCVduWZr2y6v@Z$TfH0>+U`mUA?#3IBH+r zs<^Q8tc$1mzJ=25#afp(UvTx>Z0!IHkVjsDGMy!tT)j034xew_Ton|w*v;!?O2*$$pI_}i_+izW z2aA^6+r8)WuD#oB9RGg#^6|(q?tiQ8fw68;666=mU=;a2#KKHXStZH{(JemzWly#^>v2fJsr=s zh;!K+AN5(5y-h;#tp1+5`7gD^#JvPVUhXoNzrQagW|d3C>-(iTfr=X{&878L2;5lt zIlX^{K*ZODx86QZ;jlTd?#(q{BNjP@?Zwe=Gh`P81vbE~KV+2!f#=d#Wz Gp$P!t-^UFA literal 0 HcmV?d00001 diff --git a/cmd/tins2020/res/images/flower_yellowC_NE.png b/cmd/tins2020/res/images/flower_yellowC_NE.png new file mode 100644 index 0000000000000000000000000000000000000000..f7342ebe60657d430fc482d2d3542183bb461176 GIT binary patch literal 1081 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&w@L)Zt|+Cm0wQR|WWlxVjhkJeq4S)tINa zq(`QwLZ-9y)nZ5axoxU@=PR^VD6i;WTw?HYk>mgUKAI=jsBWHld9sbts(!`AT_?IN zG>)!NKd?k~%Pggp6IC|N_`l2h{}zw`yS>%+Ecmv+D<>=~*8dL#JG_)u^ee5L zptQX2#x$Gj(`=R$>8b6Ur@D34&$Vtq^HnxZ|GL`c$`tGWJH3E5UYlz3f4k@8T05XK zRJY7j**p{I9o6k~l-EvHUO)BADwm(@T$PsfscfF1vSHfil`cxFCMd6)s&Qob_cg9> zmN+Rc>{MLbt+cFHzIUNiYzztx{j?&_=hmDfyCnA`Sgr3=uHKi0aw zU*>GFp#J&VxbqXOE>5>sUD%XfZapx; zZ*h^{uXlI<|NHrWtLLq`o)3=BJ!CM;92j|qB|(0{4Bg%3Hp#hD<+yH(%W$`?|QsNn$hZ8-a75i%2WSM@iNUx*{Qrx((6p!>#W-Un>OxySMl|3Y+K7Rt)Eq| zuKu_jobG3H+V<9S_kyzH@^}32?VD`>>(9f-Ue-(@Qu`}S@87num~bQCtz%p1_n2Lm zrgW?GR|qa!>wC8I^z~ogtOVD*JsQo`okR1`{ulnALFK%j`1^bPr$Lr^y85}Sb4q9e E00?HVD*ylh literal 0 HcmV?d00001 diff --git a/cmd/tins2020/res/images/flower_yellowC_NW.png b/cmd/tins2020/res/images/flower_yellowC_NW.png new file mode 100644 index 0000000000000000000000000000000000000000..4150213d3ccf3917daadd3bd351c225ada1d4dc8 GIT binary patch literal 1056 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&w@L)Zt|+Cm0wQ=LPtLxVjhkXsn;EaeUSH z^=_ZnxoKV8q`G6?{pk*yYfKd8x8Iv>_j`-SkF~C!*Sr7U=Ba*QiRzYF3JbgM&$0Wx z$^F(0n_Dw%l~zr-Io(EnYQ4tsm1_GJt8Sa4vT26Wvfecn22bWYC@t@opWdjvX0k$i zh1}G7h3QRa`z zyO-RQy8qif|8MmGn)YwAhtl#sr4{{;=Q%u?=kRNrr{?LkFBUndA6WbgsAjXrqj~nv z7C0!(Yx}>;8)&{vXUYGaUjKJ^y zoNKQzr{(`v&sWQw{%`S+n^dE)pabaIC(8r>Z}ojN&*9%DckRnt{%!I2e5h9Y>Q?!g zO|m@|Pv<*mUD&8~cAesqo_`zN|K3^m_x!}a8{D6+jM&>^`v2KM>6Svpg`J;oZeBad zLv~_Kz?`E0FHgU|b7Dia;lH<6_coiB)Ouao+Pk7ue`T5e#}~JI8eLYE>mQx$FVjft8sARq77t*A>6Zlg1v7A6+}r3@&LzS%|7UJvq`#5I)b}2Ky- zlD?w4P8z&gvnQ=t@$S}3tvToZSL!|dKJT-e642Vg2M#cvI%{9))>`n~{^C{f+{`Sk zQ+8Tz4MlmT_wqC4^K$oIp19ntq0ii|W8d7rHW&YG*nO6jWrfMFS7)z(eII|%*8lsQ zY03`H7h7ll@7Y@svc|39)wAzr|JS_LIo})JDY)qM?M@e)f68-D&JkDk;Emqh`Q!Yy z{^?6OE=_&1eZTbnuvhsWf-5H8c=Ud0rfgHF?XSerXP390SbA{xT=%}0g45PCc|3i5 z{e5t7xc;$uA#;ROOxpSH+EuUrnVMx}84#@JK7q@7R`u`scDon2>^PP5JS&vuLHsZL Yx4pmS3)ZV1W+1yfUHx3vIVCg!05~#~m;e9( literal 0 HcmV?d00001 diff --git a/cmd/tins2020/res/images/flower_yellowC_SE.png b/cmd/tins2020/res/images/flower_yellowC_SE.png new file mode 100644 index 0000000000000000000000000000000000000000..02f9ff4abb2736b5aea2451cf1b0c2b391de1c96 GIT binary patch literal 1102 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&w@L)Zt|+Cm0wQw*~lwxVjhkXzZUa-Bu*i zRVLe0p?+wI!t9p&(;YOAt&r)iP+B$V^E$VmTRqkHEmGS#Pi^l4_5F*LR`hEeT&l5q z{^#{>|2KJTtv6EJHBWW>oa@tV)OOBQ**rse#e_%m9h6p2dN9ZS|2EIX1$wup+pZ|p z*H}MYegC4RMY=1>^wst({J-6Eb-BUU4Q{_TxvOrP4zxn!_{w{;?5<9>RzI-#|Ns9$ zGlAOIR2TqN0*zW-VeojKgW8@2s#|Aiom&sIRC(=WrIi!@Z}nJPVeoI0yVlwDKU6}ZPll%X#FP<%M zcsk!f_t>(BbL}6^wSRH_;F?MUps)X3oqJ?ikjKu6>y|}lt*g@7KI`N81yANVJf3I& z>-*=|`x|e}_dl{M@b~`Qe$XzF~f z3K6-+shjs6KmLBNNTZzG?TaE&Q*Uohe&47O(8P6H?&8z=?=Swe30V2m?PoPtl^8HJ zhD>+op-g;@vipxF^?P6CxbRN8 z`TOzsJulz<`SQ(kr_4i58Lut&bASGMonBR^r|I6%cSJ2s+H9@b{p%|Q7YO$+vtLu6 ze}D}u6{1-oD!M z%@e3tZRb3NIW3weRw>MH*F3gTZP)xo1-e(KTC47uqj7wt+P;NaC)TL%T{vlRqQ=2x zON#WCmgp@l(o@+u9f+0|>&f<2DzsO~c2!)TX7e8ic6$Ba;ia}`!IxDo|Mz(R-{tjx zi^u=19%{Si>)hTAG;m3=p7y29*QVM?w-o`ke_rMCeU0m{b#6b_y8c+>dTEmN@AYo~ zcX@wZ?ecnw(}`}2|GT|4j;_$Xvs>fvvNL^_AC^1+-{$#$yVvGgqxZ|4HBYV4y|-8Q z&K|9c8$TUxzB1YR*Lt@vcXw$VTk&tRhx);#4;DCRo!_8)ckiu5p?}_7Roy;YepU<6 zkAF|KE-uvje<(3+eeM4TTQ;_NYMosN^!5M0zaC!L`TyC`S0|vNVgZSogeb&^HcQ$OVsu(tlLm3-C8tlX_DrdwTV(r>cHsHEeY}q zW_TZv%$1wV#dR^o=;Hjy<04Zd-%ovSRL*tV$f!JbbWT^vIyZoR$8X)Rp9aNr?lYLQ5wqPwc-W?pIOXvOMO3$~o>@#*O435r%-piLCf6sGYXM(a#`mV<-%jbv1?X9ROUlP*y;fj6ij}Kcv&!6f3{R+p$r{CxA zf18)LX5XAF0cDr9H@ChCdlN8G!g1H6^Zz9}cy;2ZC)-c$jF~FOnAP`f-TV5;Srrxg zmc5xFqqu8I&1MVBs%>GN0aLfw>|OxMdNc(e{{P}OKCbR2G_^JuWRa( 1 { - return 1 - } - return x -} - -// Value generates the noise value for an x/y pair. The range of the output is approximately [-1.325825214,1.325825214] (for 4 harmonics). -func (m *noiseMap) Value(x, y int32) float64 { - value := m.noise.Noise2D(float64(x)*.01, float64(y)*.01, m.alpha, m.beta, m.harmonics)*.565 + .5 - return clipNormalized(value) -} - -type randomNoiseMap struct { - *noise.Perlin -} - -// Value generates the noise value for an x/y pair. The range of the output is approximately [-1.325825214,1.325825214] (for 4 harmonics). -func (m randomNoiseMap) Value(x, y int32) float64 { - value := m.Noise2D(float64(x)*.53, float64(y)*.53, 1.01, 2, 2)*.5 + .5 - return clipNormalized(value) + temp, humid := float32(m.Temp.Value(pos.X, pos.Y)), float32(m.Humid.Value(pos.X, pos.Y)) + flower.Traits.UpdateModifier(temp, humid) + return flower } func NewGame() *Game { @@ -76,18 +43,52 @@ func NewGame() *Game { Variant: NewRandomNoiseMap(rand.Int63()), PlaceX: NewRandomNoiseMap(rand.Int63()), PlaceY: NewRandomNoiseMap(rand.Int63()), + Flowers: map[Point]Flower{}, } + terrain.AddFlower(Pt(0, 0), NewPoppyTraits()) return &Game{ + Money: 100, Terrain: terrain, - Flowers: []Flower{}, - Bees: []Bee{}, + + start: time.Now(), } } -type Flower struct { - Location PointF +func (g *Game) Update() { + update := time.Since(g.start) + for g.lastUpdate < update { + g.tick() + g.lastUpdate += time.Millisecond * 10 + } } -type Bee struct { - Location PointF +func (g *Game) tick() { + randomNeighbor := func(pos Point) Point { + switch rand.Intn(4) { + case 0: + return Pt(pos.X-1, pos.Y) + case 1: + return Pt(pos.X, pos.Y-1) + case 2: + return Pt(pos.X+1, pos.Y) + case 3: + return Pt(pos.X, pos.Y+1) + } + return pos + } + flowers := map[Point]Flower{} + for pos, flower := range g.Terrain.Flowers { + if rand.Float32() < flower.Traits.Spread { + dst := randomNeighbor(pos) + if _, ok := g.Terrain.Flowers[dst]; !ok { + if _, ok := flowers[dst]; !ok { + flowers[dst] = g.Terrain.NewFlower(dst, flower.Traits) + } + } + } + if rand.Float32() < flower.Traits.Life*flower.Traits.LifeModifier { + flowers[pos] = flower + } + } + g.Terrain.Flowers = flowers } diff --git a/math.go b/math.go index 949dafd..4f221eb 100644 --- a/math.go +++ b/math.go @@ -2,6 +2,36 @@ package tins2020 import "math" +func Abs32(x float32) float32 { + if x < 0 { + return -x + } + return x +} + +func AbsSub32(a, b float32) float32 { + if a > b { + return a - b + } + return b - a +} + func Ceil32(x float32) float32 { return float32(math.Ceil(float64(x))) } func Floor32(x float32) float32 { return float32(math.Floor(float64(x))) } + +func Max32(a, b float32) float32 { + if a > b { + return a + } + return b +} + +func Min32(a, b float32) float32 { + if a < b { + return a + } + return b +} + +func Sqrt32(x float32) float32 { return float32(math.Sqrt(float64(x))) } diff --git a/noisemap.go b/noisemap.go new file mode 100644 index 0000000..ed5060c --- /dev/null +++ b/noisemap.go @@ -0,0 +1,52 @@ +package tins2020 + +import "opslag.de/schobers/geom/noise" + +type NoiseMap interface { + Value(x, y int32) float64 +} + +func NewNoiseMap(seed int64) NoiseMap { + return &noiseMap{ + noise: noise.NewPerlin(seed), + alpha: 2, + beta: 4, + harmonics: 2, + } +} + +func NewRandomNoiseMap(seed int64) NoiseMap { + return &randomNoiseMap{noise.NewPerlin(seed)} +} + +type noiseMap struct { + noise *noise.Perlin + alpha, beta float64 + harmonics int +} + +func clipNormalized(x float64) float64 { + if x < 0 { + return 0 + } + if x > 1 { + return 1 + } + return x +} + +// Value generates the noise value for an x/y pair. The range of the output is approximately [-1.325825214,1.325825214] (for 4 harmonics). +func (m *noiseMap) Value(x, y int32) float64 { + value := m.noise.Noise2D(float64(x)*.01, float64(y)*.01, m.alpha, m.beta, m.harmonics)*.565 + .5 + return clipNormalized(value) +} + +type randomNoiseMap struct { + *noise.Perlin +} + +// Value generates the noise value for an x/y pair. The range of the output is approximately [-1.325825214,1.325825214] (for 4 harmonics). +func (m randomNoiseMap) Value(x, y int32) float64 { + value := m.Noise2D(float64(x)*.53, float64(y)*.53, 1.01, 2, 2)*.5 + .5 + return clipNormalized(value) +} diff --git a/projection.go b/projection.go index f7dc56a..a7cbc81 100644 --- a/projection.go +++ b/projection.go @@ -64,7 +64,7 @@ func (p *projection) update(renderer *sdl.Renderer) { log.Fatal(err) } p.windowCenter = Pt(windowW/2, windowH/2) - p.windowRect = sdl.Rect{X: 200, Y: 200, W: windowW - 400, H: windowH - 400} + p.windowRect = sdl.Rect{X: 0, Y: 0, W: windowW - 0, H: windowH - 0} } func (p *projection) visibleTiles(action func(int32, int32, Point)) { diff --git a/resourceloader.go b/resourceloader.go new file mode 100644 index 0000000..58048d4 --- /dev/null +++ b/resourceloader.go @@ -0,0 +1,51 @@ +package tins2020 + +import ( + "bufio" + "fmt" + "strings" +) + +type ResourceLoader struct { + Resources map[string]string +} + +func NewResourceLoader() *ResourceLoader { + return &ResourceLoader{} +} + +func (l *ResourceLoader) parseResourcesFile(res *Resources, name string) error { + f, err := res.Fs().Open(name) + if err != nil { + return err + } + defer f.Close() + + l.Resources = map[string]string{} + scanner := bufio.NewScanner(f) + for scanner.Scan() { + definition := scanner.Text() + sep := strings.Index(definition, ":") + if sep == -1 { + continue + } + name := strings.TrimSpace(definition[:sep]) + content := strings.TrimSpace(definition[sep+1:]) + l.Resources[name] = content + } + return nil +} + +func (l *ResourceLoader) LoadFromFile(res *Resources, name string, action func(string, string) error) error { + err := l.parseResourcesFile(res, name) + if err != nil { + return err + } + for name, content := range l.Resources { + err = action(name, content) + if err != nil { + return fmt.Errorf("cannot load resource '%s'; error: %v", name, err) + } + } + return nil +} diff --git a/terrainrenderer.go b/terrainrenderer.go index b2b273f..69d9ca2 100644 --- a/terrainrenderer.go +++ b/terrainrenderer.go @@ -127,6 +127,17 @@ func (r *terrainRenderer) Render(ctx *Context) { return variantToTexture("bush-large-%d", stretch(variant, .8, 1)*multiplier) } + toItemTexture := func(x, y int32) *Texture { + variant := r.terrain.Variant.Value(x, y) + _, ok := r.terrain.Flowers[Pt(x, y)] + if ok { + return variantToTexture("flower-poppy-%d", variant) + } + temp := r.terrain.Temp.Value(x, y) + humid := r.terrain.Humid.Value(x, y) + return toPropTexture(temp, humid, variant) + } + // horizontal: [191, 321) = 130 // vertical: [267,332) = 65 @@ -143,14 +154,7 @@ func (r *terrainRenderer) Render(ctx *Context) { }) r.project.visibleTiles(func(x, y int32, pos Point) { - variant := r.terrain.Variant.Value(x, y) - if variant < -1 || variant > 1 { - return - } - - temp := r.terrain.Temp.Value(x, y) - humid := r.terrain.Humid.Value(x, y) - text := toPropTexture(temp, humid, variant) + text := toItemTexture(x, y) if text == nil { return }