From 3c51eb91645fb9ab6e6cbe49b354408a6e77d1d1 Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Mon, 16 May 2016 10:53:33 -0400 Subject: [PATCH] Stars and Stripes forevahh! --- .gitattributes | 7 ++- assets/items/FOOD_CHICKEN_FRIED.png | Bin 228 -> 232 bytes assets/items/SWORD_WOOD.png | Bin 217 -> 272 bytes assets/items/arrow_crude.png | Bin 294 -> 222 bytes assets/items/bow.png | Bin 327 -> 278 bytes assets/items/bow1.png | Bin 345 -> 316 bytes assets/items/bow2.png | Bin 381 -> 318 bytes assets/items/bow3.png | Bin 368 -> 325 bytes assets/player/playerk.png | Bin 421 -> 482 bytes assets/player/playerk1.png | Bin 482 -> 496 bytes assets/player/playerk2.png | Bin 478 -> 502 bytes assets/player/playerk3.png | Bin 490 -> 487 bytes assets/player/playerk4.png | Bin 478 -> 491 bytes assets/player/playerk5.png | Bin 472 -> 483 bytes assets/player/playerk6.png | Bin 475 -> 494 bytes assets/player/playerk7.png | Bin 485 -> 491 bytes assets/player/playerk8.png | Bin 489 -> 496 bytes brice.dat | 4 +- shaders/world.frag | 2 +- src/entities.cpp | 9 ++++ src/inventory.cpp | 4 +- src/items.cpp | 29 ++++++++++- src/world.cpp | 73 ++++++++++++++++++++++++++-- 23 files changed, 117 insertions(+), 11 deletions(-) diff --git a/.gitattributes b/.gitattributes index 7bb2418..d10ef48 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,11 @@ include/tinyxml2.h linguist-vendored src/tinyxml2.cpp linguist-vendored -src/threadpool.cpp linguist-vendored + include/threadpool.h linguist-vendored +src/threadpool.cpp linguist-vendored + include/SDL2/* linguist-vendored + include/freetype/* linguist-vendored + +include/glm/* linguist-vendored diff --git a/assets/items/FOOD_CHICKEN_FRIED.png b/assets/items/FOOD_CHICKEN_FRIED.png index d086400e25ce351f283952c79fa7c5f6bd5d81a6..5dd27e9ed63de55fb8c10e1a3fef57ffeef03341 100644 GIT binary patch delta 170 zcmaFD_=3^6Gr-TCmrII^fq{Y7)59eQNV5Sk2M36}b*#?| zJSVFFAE!~^qjh`}J#`X&JY5_^IIgGm9ppWrz{9McbHFF(u-#jeR8@(CwI&xX%oB0l zH0Q<#C3%LNuB|By=gb&%J|5)tx+ohde*Eh8aP5do`gcsl&&(5DmFJsZa6;l=pX)CN PpuG&9u6{1-oD!M-(00$e8R7#x34x~5>JR*x37`TN&n2}-D z90{Nxdx@v7EBgaxd0qyUg%f}8oEWW>ALZ%d7@~1LIpqM$|BF9*PROXS2{9_~IvIJc zNrP+I+uHs`(|(yPxb3ouSEt3tjXmXN1Jkm1mB$YN!GyO;E{g+x{g)TI*wfQ zH#bk7%N>*I*poYBNq3vnu3Ib@!k*=(@?E&PZ1o%arOZB`!%uHJ-Ep(ITSbz;QdFXW z#kKB+mKS${g34=#l;^>AX06OTul)-Tus&XTm)9oxFXK63$t!yH3ey-EfR6Wc^>bP0 Hl+XkK24_kh delta 182 zcmbQhbd%AuGr-TCmrII^fq{Y7)59eQNb>-(90wbal*s;H4x~5>JR*x37`TN&n2}-D z90{Nxdx@v7EBk#O7CsKe*9<2ECPwR|_UE zh`8Wu7M9>1{#pK}+N4~Gs|KqQLztNi4i$;`<~p3*{j^C(gUjmvf5$-YiM$$S4}*-A blBF1)aPm*qSv%7dXdQ#6tDnm{r-UW|!OAv+ diff --git a/assets/items/arrow_crude.png b/assets/items/arrow_crude.png index 3d820749a68eec9260ed1b712519692fbcc5aa53..5fba709c5c36390612d2f929b715348f3e7a7d24 100644 GIT binary patch delta 187 zcmZ3+bdNE*Gr-TCmrII^fq{Y7)59eQNHYU5CkGpl{JweGO(4aV|H(? zBwgSUSEal|alQ70q2K`n zo&yeBv)zfGr-TCmrII^fq{Y7)59eQNV5U45C@2?=w5#mB#`9o?gFHN;HUHMdLYGF z;1OBOz`!jG!i)^F=12eq*-JcqUD+S7GV!UiH9DSYo*1oD-{tAz7$R}`?1YWHOojq1 z-#?r@*?#|+`uqzFKf@h7gj-U!IJ$7hPbfZJloV|z%h}#?#Q9Xp_U)^uPD|?1So*-s zmy4mjR8^4i`@M@%%@d2;IvUnJUh(4qpL75Rqo(Sd{%Y2S%TN8bhHWV3JM*Wg>izx2 yr)^#s@&DTV*kAtF5f+8r+qWB;3r7OHm5UX!1$RD1relF{r5}E*MYg>l^ diff --git a/assets/items/bow.png b/assets/items/bow.png index 62be2dcb2751d668fe05822a4235baa8a383edd0..7affffb116475a2a37207252a75a2f11cca15067 100644 GIT binary patch delta 198 zcmV;%06G810+s?HiBL{Q4GJ0x0000DNk~Le0000C0000F2nGNE0MOwsNs%Ek2oMek zHcymWR*_pQe|kwoK~yNu&5|(+fG`jQCvsq6l{$@I5dYyv^f~@0b^egX+BzVdl^`M} z7J^gXG7GnG!dX#gg(s@>ao^Se*$~c(4qck delta 247 zcmbQnbeu`CGr-TCmrII^fq{Y7)59eQNJ{{*90wbaG}F8HbfTgW2NNSJlhz^5_KDFt z^{YKy978;gC#M`>T*4ap&v|B#|NZ}o3gQL}CA-266)STZ1gD?w6}=%T0R-plew=jZ z^q+B}RPvF0Zas6D>ZfYWm%-S!k5y+&Pr|Ps4ULVA*{>>p{o~iU z>LYn`qD|Jp6|BxG>c&pR23~#3OxQ2$cg%C#_y4ei=jucg(ZJ=Qin=G5`q^h~>CTWm uX)(L)Qj^aAg)x$I9SqY#nD1_(u@v7Y0vPKbLh*2~7YL^jk~- diff --git a/assets/items/bow1.png b/assets/items/bow1.png index a37ca719974ab4932bf9d783f42e505d58f38944..1f3562671b771f13f4fdc9e2b5763c401a80fb67 100644 GIT binary patch delta 236 zcmVO-;gB~R!a*7S1{beE8%ghy@18m+<`({t%)X| z3WJ-lW`8o>pUnH2Z<1Km)+K=M&$qFoA~yG3MO&9jE^N)?G;_J$FtZ_b;cI@pK4%gt z$W`MVjdwa74{E$q2mxRSAqW^Gv7I8qv401$k+K&YHelm4tM4iR0ck8rKcQ2B*U;HW mL|Dnk*;>B19(x6}+_o+_IBD`gPW<%%0000(sA^kW52Bgh9&g|IeUTK^AE4>c6IBSI1#r&UQ{8tokweoY6s72qxyf^YY>K3# zXF!wDW&UC-5Sz(1u~NUOyUYx*?XX-gp|Xo4 P00000NkvXXu0mjf*}-gP diff --git a/assets/items/bow2.png b/assets/items/bow2.png index 29ba192261fe3d6e6501c99cfe74f09b9815c54a..9bab2df06e401bf10979cd098ad48c34cb9b2a00 100644 GIT binary patch delta 238 zcmV zS&Lm{2HwXLgLm4{)MBxxsq~yKJpl`UaO$ o+HJvT_{uEJj|Hs&nt#*!2Dq1rhqp+o4FCWD07*qoM6N<$f^V5%+yDRo delta 301 zcmV+|0n+}y0{sFZiBL{Q4GJ0x0000DNk~Le0000O0000U2nGNE05&e(<&hyW2m%2g zC(-LC8ph?^g9s@-K^=FNMI^#*`AjuQY8Spw8?*gb-e%HD5kcc-E#403?QcWeT{c7Fxnbh(SpO#qZqspcZp z?^Z6{b5KxEWhkYLdWOk?Z**^&J;hlYBn2+8?S*p${{q8Mk!bb2sj2K_!`)=#Om!Rm z?FRSa2Uac$j@D@Q{X1HgWg~O6(f*5M^ncR_gFA5e3#wC900000NkvXXu0mjfA@_vW diff --git a/assets/items/bow3.png b/assets/items/bow3.png index 3c8ed6c3d9351bb487aab78ae5db981e82e45021..a5f550fcd12e32b1108acef93fd8207c616db265 100644 GIT binary patch delta 245 zcmVuI$iBL{Q4GJ0x0000DNk~Le0000C0000F2nGNE0MOwsNs%Ek2oMel zB&9YRUy)lZf2m1CK~yNuosuyQgFp-f=T0DsRM0}f7ZCs8OMEAFK9J&S{y>pBJxZ}D z5|G6~q{~WftR2Z~8%fxz%Zz=`mdB{6a{9KQsd8~5Z_R+FdC@P(TXWwQ^lia3FI;bT zoO5GDeCO8CT~wEu>M~OZ0bmRv2pDaK2#`LLoI#O!KL%U+yr2eY~N&U{|~^Qor>L{>}gxmRYK|00000NkvXXu0mjfK|o-e delta 288 zcmV+*0pI?`0`LMMiBL{Q4GJ0x0000DNk~Le0000O0000U2nGNE05&e(<&hyW2m%2V zFtN;g7m-^mf7D4tK~zY`?UpMJgHRAf&uiM$S0lQI>bEvvH)uA17|k9K)%B!eD#{25 z|Ab${bp#UbdGF50sVaR69yb8qpD%NCVPRc|oWGuTd)A7??TWxP@4%b`wHHQ`7bR0j z*1LnIb8~Dm=SiCV(VYtcR5jjBinQ&lO-Y(L0PlSWY9Jy}MM59Rc6DH~w3t&7i7OJu zkStGN6*?p5qevDfIDfE%USw%$rfEd~uT`}7KH8=ZhCVP75ozs3UC!5^XjA9Gkn?jU m&nM{Gi}Ip8$X;}~-Sh`v*NjOP#CWa%0000gKsNK)(*gn*z3No7c|-Xf2Y#^@7hOkiIi))uL4vn$^6Pe!QAthRI9lv zuU0GkdP_UQ%W|2&Lh;W~S$4AQ>fCI9M&Wi7M%Jb??*2re(H>^5QD@u@>Lk32o3Y$z z4>>wMz*#JqR=yH3To->S5!96u{|O2pw&SKoKy+_8qHykcR?yLQT*5Ixkn5Cf$sWE= zdI{@A2*vdBMl7d6L_}=I729z|M5NE?cWuIXA;LbRLl!KaN@&% z$$OA;7IW&=Q;FfEY`{t}H%slV%akOS5THcay2HCHV^;^`>EfKXt7{eP&?LQ%Mp4w> zjz{=Ftvieb`_rTRE1;nx(G9Wbr^Cwzw1hod&wqU*U`a-^_1xsKt;K#QkEaXVKU_l} z4%pm&JHDOg8$WB7n-L@c=DPBF01VAkz188au9Z14*A?2{m|2H9yAU1jKVBT_DS(VE z?uD}VKOxCnSIl)qk}R-1%ci|f0xYm}JOF1M^XoB@k%jRC9^#_I9H{OU00000NkvXX Hu0mjfp^2hc diff --git a/assets/player/playerk1.png b/assets/player/playerk1.png index 1c4fb490c5338d40ba8f33ec797ec4efe55096c3..6e549cfcf615d61de063a8545ccdcf6e83ad4fc9 100644 GIT binary patch delta 485 zcmVs>0004fNkl{qu7gT~Xjl9YcHtP>TH2`QJ>Mr1l{ znL3VcIsgF6?Ln7RmQ1p(r@mf9<1LvuULs z%B9X8&+++Co-C`7rK3=ale1eqJxAs}98c$HwE9Z2kCzyA&Pn^1g~KFC5ZZRB%F8%L z>d%xtyr@+0TX27@8C+M6u3S|$n^E|`33Fr99{S%FK%>>yj!}E)3qQ)v;$}*2wE8$W z+=CZI7*!WbHtQ$flpN}uQ+fpn06AVzXaSJwF6R_Zl7xwjju#+n1;kpV>~D-ss*-+8 z_!f4SN?%1GnFg<=v(m3pZ?Y&$%qqbMOY9lBsZTtdG$ZIjFk{9lKqQl8KN1d z`DBohi?SZE_+Ta9V;{w(Gl`b61a~irkAr}k7~uTsb)~*pnkt??X#eSRx7+A|FG+$j zB-`tQO_O804vK*r%f&kSs`{q=y&cUm#bTfsCO)clHh++xPoc#gb4K%|v97i|EnF#4-BhlbiYZU^reFL|lZFGQq^E&ohdBYBSov80{ta Y2l=v#I7*TE>;M1&07*qoM6N<$g0pPmjsO4v diff --git a/assets/player/playerk2.png b/assets/player/playerk2.png index 97f769bbaa7955a3f356cef4cf89e3175eb45cac..f6966ee3205110b7e6dd67f5442a244ecf287010 100644 GIT binary patch delta 491 zcmV?8&kUMLG&r9GzU_;W2ja;bgWzz13&Q-k#>DNlC`PtQ@9Ef|2K0Ri4l1 zNc{!d!?SW3zlDFqA48hTF_p_zvmS;2n=m&v?P2(30n}T4;~2Gvq4J~bEUu^IdaIAU z{T&2xjB#bTVzYkwNy(umC8bA@0FWOEnj}JH^n(altDx4LvbFS(bX7Xi zefqJ&mr)0{Bpe~R268H$d-!~FoO=&OOQ$#@BJzWX{2(tPBBCw^q`r4CSg~9$bA*OK h?%{6^mI{Qe#7`;s!}GkW{R{vA002ovPDHLkV1i;n)IR_K literal 478 zcmV<40U`d0P){QzSQ@;8tC7IWnyn34%s)tNFcE{LWb{n4rnFPov)!%{Z;* z-RG-K{eHch`4w}4Tp$<71yY+yE?%#SzP3X4ol#WYTs~=97xF9S z)r`J7J3QJ20ECNA0DtF(>cpYSM^c`z^Lr9uyDwg*Y2o+1@Cg9$F}t<$b9ssHiw!38 zWU5Rjs9y)QQ+_UR9p6DK?fqxDu9hxZ?9VBGRrmH?P-2edgFP}@V zkHr*#{r^tgC+JHgoP7fTB6(McQ@&DOjFC}`bTnv7M2I4YSd5H5>Ghy&F*hB8KiN5y Up((_KxBvhE07*qoM6N<$f*#z?mjD0& diff --git a/assets/player/playerk3.png b/assets/player/playerk3.png index 19b97c44466733cebed624abd9d4a1b5e5245991..44ca2b8f7da7f39ab3d6e00a806785cf9f44817d 100644 GIT binary patch delta 476 zcmV<20VDqE1Lp%XiBL{Q4GJ0x0000DNk~Le0000K0000W2nGNE01{$Ywg3PC24YJ` zL;wH)0002_L%V;GAs2rD2XskIMF-#o5DpP4z?H560004WNkleDQW+Agx5!(V#-At97$GkZYr)huS_JDr5PL0>ynv`pAbTy`mEFzG z>}Wy?Pjlzz&Y5%1-hp*UhZ96UW8Z3H6LL~`MA%%EUM56S|JmM$2UAajqE)fjHi@qZ7tdR^Mq}s#Q2rNgrV=#bKOjp=aUIR zzN7WX2$g_h=|AuS92f{(5@T*9RBFQ56>4X5U=PY SrH=>z0000{gpI?4{pZ~Q2_C|(&qDCJG&~g*D zSM&BlEr|DCf~FhQMdpGI?uW}If@ zK}IghJYudvtJ?Ek#g$hQX;leso{A5GfSTyw}4&-pWnFg+Jf)3ors8x8>gpQBr&b}p{x=VFaf zo=lmk1l7;s+busQxQcnusP;CNpjftg%lu5$>~syTwf1=G*UjP6A diff --git a/assets/player/playerk4.png b/assets/player/playerk4.png index c32a9b387a353a133bd3428480706bc5b611441d..767a6fc2c0b894aad91c45cbdae647ecf79831d8 100644 GIT binary patch delta 480 zcmV<60U!R}1M34biBL{Q4GJ0x0000DNk~Le0000K0000X2nGNE0NFl^6951J24YJ` zL;wH)0002_L%V;GAs2rD2XskIMF-#o5DpRrKxx360004aNklq&G(RBfrC`Q`2_&2B zW}~GA2f}2tGjHBZW|jq3ELz3)xTas}#x8(20N8JCmpV-sOCf)#Ra^nF2bZY=vP@XdJ#wk!%bZa22AyZ)m06WK5(5)i?K(}oOeVB}$Nbav)blV2i zsv)21=i@m(9;$<78EQ!@RLaTOEuNl3^%_nWOPIDV1bcsp&|!?Ee>pXn#W4cIsAPE= zMM&&5VGS=DjX!@M4s6w@4U?rKOIMW5dKmt1z+Bt(#_o>>VA{U4je27@wWDk=t|w*F z_Hl5y2PX_MX?_)S){dW)oOBqYWCRHSwVY9@20)@&&M}$ W4zK8ha!}6z0000{ zo9WfTc)TE$sGFSJW2vokQRvz(IfHxN2!R2zh zchR8Y-^?yE`_DhKGm3a9-+BrDRE|yH8DKlN9{XrGnHfn{%-w%85v3v3k$WmK8`jbW z4lWu1WGXFeNu!b_8XORXk*TzdJ=AGb0c`A_k*VwfP%b#eH`=DogzNJ<<$@zi^)OoM z+wC#0H_6Gu3Y9+!i8wgAD@#n6AYa%|;N1c4I9drd^&>IPyFdWX!u=!Ztu~H!1tQvB|q#p8Ac% zIA!rkwA>J(`Wu__cy%~;ZqoU3A^}81q)BJN`u?SQC@CD0u5@gSpYj2qtd{Yi7##or O00006P)+-MjV%FraXQuEY$DMPfCP|FueA-?uq&o?m`>&(C%Q+$9bB36C)lq2&^; zeoT-l%E~k*gR;ex@;y((D`qtX*PR~#YsZnLFX8ha#^a6uiq*+KgV|ffT4H+ z0Hheuj=_#CIbHGO7XXmRhYC5>R@_nyB*|JVdynv`pz#9wi(y9Oe literal 475 zcmV<10VMv3P)((Tvk- zKF-KRS&x`=&?)!GSFyE{D6=KlzbZZm0_kIblk>+?f6Fu#G;>gY(}&^E>wuFafep#- z=AdtKWamK+ur)1K)#sX<`ty1<^C#v2IY17O1Ei)T7q3^vwzficRTSkn=TFwH3;7fC zYDV9k9Ukoh0K&y5fZuaNb>dLfMpEvt^Lr9ux-VX)Y2p4}_yhp>nB5w+bAE~Mi)&2g z$yAw6P`{2op7L8+RW6d92c7@bnUZnMJ(fDw;=gjwSC#TS`2KbS0NB5LF1rn1wj$g$&lilA^*ZIR)2xk6!Hh^EZEsahvHl);;uuQKOpK-FwemRlWXpB zp{0Z0^6t2I-+kY^_ZZ5-(wJ17YaQ$Ycn5&}=630&>3kt2WhH<6L`I}T%7wianF?FF ziIbZi0KjktP(3P2CNVi9%ENF5(i(CdRRFMadkN}Y7g{2Vy$!58raF!%2d(rYjCHtwyz zZBkNJmyngI5$)F@q_t0qZq0NEiRe$@>)mN#-N&%D10p0M>SIXxwHRfjY{mL5-Twh# WR;J|)b~O$F0000Fi5kZ{{M$tM%1*hd~ zEXYM-Mod2F4WN@-VcYhF8Ginupzm* zK3F$7Z}T7-_-D0PMxU#1s^6>8Oj}F_l7VC(8R%OjIeWdxx0MsJYekWIGy1shTu56? zry2Ejc5t{200`%w0Dj*M<%>gE8%eRgjlYvH(|hqEO>^VB;S&JhV|s1W&gk|0UaS$G zB~vCULA4)UeC4;2GGC-T=qj$h=VcUIMRR8e_H4<~X{KrvSIl#L0IN0=Ts1+E0|4i1 z7u-94&JDi5U1|Hr>>B_O%f-?0 z0qh{ar14dV>Ad`;WYFTA;t?bOq}yI;1VEx$&M2Hk5lddwZ4c>~AX$r)DfdvfJ-qt8 z&D$m>Wor|bsmYiBXOluiq}(%Qg|@%)+kD*p*_)5M=wm5}*gDFf^hZS0$FLAZq)dTa bhQj@CoUEhb7p6_a00000NkvXXu0mjfn4{K% literal 489 zcmVgvN+s&?)wU&tmINBE^uo8lCVdO<_ZF zb7Qb+a>3R?a&T?ESZ1GVZ0gVJ*-W3993%(HL2@v(PIB>arH-`~vTH|?c60W4)w+;A zF|B6w-Pz&M4gesY{s35=8_E-hvN6(PdmFzeVW#`yS(YjH_u^Lo!1wspXq>Yf_`bM8 zc%Dp|=mhoa=;A5Am6XLI)j?NrjlFQQSdX>N6C?-Mk;NPUIA4a~{^eVpI@bfR@R{JE z4T6fq<39kaU*5hxZxpi7t`C{izvsfizRv`Etr2958Ieu+ognw3jAa!RB#rB0kpG)0 f>@01~?LEPN^{bDH*@BcV00000NkvXXu0mjftex = new Texturec(1, exml->Attribute("sprite")); // get the width and height of the object based off of its sprite - ItemMap.back()->dim = Texture::imageDim(exml->Attribute("sprite")); + dim2 tmpDim = Texture::imageDim(exml->Attribute("sprite")); + ItemMap.back()->dim.x = HLINES(tmpDim.x/2); + ItemMap.back()->dim.y = HLINES(tmpDim.y/2); ItemMap.back()->name = exml->Attribute("name"); diff --git a/src/items.cpp b/src/items.cpp index 21484b4..99c143b 100644 --- a/src/items.cpp +++ b/src/items.cpp @@ -60,20 +60,45 @@ int Sword::useItem() float dist = 0.0f; while (dist < dim.y) { hitbox.end = hitbox.start; - hitbox.end.x += dist * cos(rotation*PI/180); + if (player->left) + hitbox.end.x -= dist * cos(rotation*PI/180); + else + hitbox.end.x += dist * cos(rotation*PI/180); + hitbox.end.y += dist * sin(rotation*PI/180); if (hitbox.end.x > e->loc.x && hitbox.end.x < e->loc.x + e->width) { if (hitbox.end.y > e->loc.y && hitbox.end.y < e->loc.y + e->height) { e->takeHit(damage, 600); + static GLuint sColor = Texture::genColor(Color(255,0,0)); + + GLfloat t[] = {0.0, 0.0, + 1.0, 1.0}; + + GLfloat v[] = {hitbox.start.x, hitbox.start.y, 1.0, + hitbox.end.x, hitbox.end.y, 1.0}; + + + glBindTexture(GL_TEXTURE_2D, sColor); + glUseProgram(worldShader); + glEnableVertexAttribArray(worldShader_attribute_coord); + glEnableVertexAttribArray(worldShader_attribute_tex); + + glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, v); + glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, t); + glDrawArrays(GL_LINES, 0, 2); + + glDisableVertexAttribArray(worldShader_attribute_coord); + glDisableVertexAttribArray(worldShader_attribute_tex); + glUseProgram(0); // add some blood // for(int r = 0; r < (rand()%5);r++) // currentWorld->addParticle(rand()%game::HLINE*3 + e->loc.x - .05f,e->loc.y + e->height*.5, game::HLINE,game::HLINE, -(rand()%10)*.01,((rand()%4)*.001-.002), {(rand()%75+10)/100.0f,0,0}, 10000); } } - dist += HLINES(1); + dist += HLINES(0.5f); } } } diff --git a/src/world.cpp b/src/world.cpp index 0c5007d..70ba967 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -254,7 +254,6 @@ void World::drawBackgrounds(void) alpha = 255 - worldShade * 4; break; } - (void)alpha; glActiveTexture(GL_TEXTURE0); glUniform1i(worldShader_uniform_texture, 0); @@ -276,7 +275,6 @@ void World::drawBackgrounds(void) vec2(0.0f, 1.0f), vec2(0.0f, 0.0f)}; - bgTex(0); GLfloat back_tex_coord[] = {offset.x - backgroundOffset.x - 5, offset.y + backgroundOffset.y, 10.0f, offset.x + backgroundOffset.x + 5, offset.y + backgroundOffset.y, 10.0f, offset.x + backgroundOffset.x + 5, offset.y - backgroundOffset.y, 10.0f, @@ -290,18 +288,85 @@ void World::drawBackgrounds(void) glEnableVertexAttribArray(worldShader_attribute_coord); glEnableVertexAttribArray(worldShader_attribute_tex); + bgTex(0); + glUniform4f(worldShader_uniform_color, 1.0, 1.0, 1.0, 1.0); glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, back_tex_coord); glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, tex_coord); glDrawArrays(GL_TRIANGLES, 0 , 6); + bgTex++; + glUniform4f(worldShader_uniform_color, .8, .8, .8, 1.3 - static_cast(alpha)/255.0f); + glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, back_tex_coord); + glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, tex_coord); + glDrawArrays(GL_TRIANGLES, 0 , 6); + + + static GLuint starTex = Texture::genColor(Color(255, 255, 255)); + const static float stardim = 2; + GLfloat star_coord[star.size() * 5 * 6 + 1]; + GLfloat *si = &star_coord[0]; + + if (worldShade > 0) { + + auto xcoord = offset.x * 0.9f; + + for (auto &s : star) { + *(si++) = s.x + xcoord; + *(si++) = s.y, + *(si++) = 9.8; + + *(si++) = 0.0; + *(si++) = 0.0; + + *(si++) = s.x + xcoord + stardim; + *(si++) = s.y, + *(si++) = 9.8; + + *(si++) = 1.0; + *(si++) = 0.0; + + *(si++) = s.x + xcoord + stardim; + *(si++) = s.y + stardim, + *(si++) = 9.8; + + *(si++) = 1.0; + *(si++) = 1.0; + + *(si++) = s.x + xcoord + stardim; + *(si++) = s.y + stardim, + *(si++) = 9.8; + + *(si++) = 1.0; + *(si++) = 1.0; + + *(si++) = s.x + xcoord; + *(si++) = s.y + stardim, + *(si++) = 9.8; + + *(si++) = 0.0; + *(si++) = 1.0; + + *(si++) = s.x + xcoord; + *(si++) = s.y, + *(si++) = 9.8; + + *(si++) = 0.0; + *(si++) = 0.0; + } + glBindTexture(GL_TEXTURE_2D, starTex); + glUniform4f(worldShader_uniform_color, 1.0, 1.0, 1.0, (255.0f - (randGet() % 200 - 100)) / 255.0f); + + glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &star_coord[0]); + glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), &star_coord[3]); + glDrawArrays(GL_TRIANGLES, 0, star.size() * 6); + } glDisableVertexAttribArray(worldShader_attribute_coord); glDisableVertexAttribArray(worldShader_attribute_tex); + glUniform4f(worldShader_uniform_color, 1.0, 1.0, 1.0, 1.0); glUseProgram(0); - bgTex++; - std::vector bg_items; bgTex++; -- 2.39.5