From 1f7e0c7babaf647feea6ca90dec8a1e58c7d1710 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Sun, 7 Jun 2020 21:58:36 -0500 Subject: [PATCH] Add VN-style dialogue test --- Makefile | 9 +- data/image/girls_are_weird/background.png | Bin 0 -> 1827 bytes data/image/girls_are_weird/box.png | Bin 0 -> 343 bytes data/image/girls_are_weird/girl_angry.png | Bin 0 -> 1579 bytes data/image/girls_are_weird/girl_bored.png | Bin 0 -> 1582 bytes data/image/girls_are_weird/girl_happy.png | Bin 0 -> 1659 bytes data/image/girls_are_weird/girl_sad.png | Bin 0 -> 1513 bytes data/image/girls_are_weird/menu.png | Bin 0 -> 2860 bytes data/script/script.rpy | 165 ++++++++++++++++++++++ lib/menu.c | 2 +- lib/menu.h | 2 +- lib/scene.c | 78 ++++++++++ lib/scene.h | 34 +++++ tests/test-dialogue.c | 114 +++++++++++++++ tests/test-dialogue.h | 27 ++++ tests/test-menu.c | 2 +- 16 files changed, 426 insertions(+), 7 deletions(-) create mode 100644 data/image/girls_are_weird/background.png create mode 100644 data/image/girls_are_weird/box.png create mode 100644 data/image/girls_are_weird/girl_angry.png create mode 100644 data/image/girls_are_weird/girl_bored.png create mode 100644 data/image/girls_are_weird/girl_happy.png create mode 100644 data/image/girls_are_weird/girl_sad.png create mode 100644 data/image/girls_are_weird/menu.png create mode 100644 data/script/script.rpy create mode 100644 lib/scene.c create mode 100644 lib/scene.h create mode 100644 tests/test-dialogue.c create mode 100644 tests/test-dialogue.h diff --git a/Makefile b/Makefile index 23cb860..7f26d84 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,8 @@ # multiple-targets like sparrow3D! # whoops. -SRC = lib/button.c lib/font.c lib/sound.c lib/menu.c -OBJ = button.o font.o sound.o menu.o +SRC = lib/button.c lib/font.c lib/sound.c lib/menu.c lib/scene.c +OBJ = button.o font.o sound.o menu.o scene.o DEP = $(SRC:.c=.d) DYNAMIC = -lSDL_ttf -lSDL_mixer -lSDL_image -lSDL -lm @@ -56,11 +56,12 @@ targets: test-sprites: tests/test-sprites.c $(OBJ) makeBuildDir $(CC) $(CFLAGS) $(LINK_FLAGS) $< $(OBJ) $(SDL) $(INCLUDE) $(LIB) $(EFEMMERA_STATIC) $(DYNAMIC) -o $(BUILD)/tests/$@$(SUFFIX) - test-menu: tests/test-menu.c $(OBJ) makeBuildDir $(CC) $(CFLAGS) $(LINK_FLAGS) $< $(OBJ) $(SDL) $(INCLUDE) $(LIB) $(EFEMMERA_STATIC) $(DYNAMIC) -o $(BUILD)/tests/$@$(SUFFIX) +test-dialogue: tests/test-dialogue.c $(OBJ) makeBuildDir + $(CC) $(CFLAGS) $(LINK_FLAGS) $< $(OBJ) $(SDL) $(INCLUDE) $(LIB) $(EFEMMERA_STATIC) $(DYNAMIC) -o $(BUILD)/tests/$@$(SUFFIX) -tests: test-menu test-sprites +tests: test-menu test-sprites test-dialogue @echo "=== Tests built ===" #efemmera: main.c $(OBJ) makeBuildDir #$(CC) $(CFLAGS) $(LINK_FLAGS) $< $(OBJ) $(SDL) $(INCLUDE) $(LIB) $(EFEMMERA_STATIC) $(DYNAMIC) -o $(BUILD)/$@$(SUFFIX) diff --git a/data/image/girls_are_weird/background.png b/data/image/girls_are_weird/background.png new file mode 100644 index 0000000000000000000000000000000000000000..8a8e96a0058229ae639d66fb0e434fd4fe2fa1a3 GIT binary patch literal 1827 zcmZ`)dpy)>7k_@2F@s^;uhk5>gu#%QSefKDGIA}i$heHl<`y;-`Dvx=i_}hTVf(b$ z$|Ng3XzN$GvkXgxdYfGqp-lVQ$R+P@|J*;`f1dL>=X}1;bIy6b=bVc^-tG!=I&uI2 z1+IsS9{?~003?AC!s7A7CY=yy%zoZ}03H;|Z-kQwoe}Bb#{=M$5dc^o0BeK^n*-n* z769{n0PITu&`hpq^Zkl&P<^}tT-)BQ+qpO{Z;fq%t(EHTi-aADIOy(zC{w-uBouNQ zm*+~JmO(W3g1*Uh7y!}|*JXb|#>D$K@+YSlRE}?wU-_tM?VcISjdQmnEA4sLBsj0o z6`Cv+w5kt&!;o~7V>L33H3$_TQ(QauLt)PN#+T|eH6O@ZHm!)K zn!fd%sXgqERH)9ya8!z)>k5bd8l6zYR6%xC#nR^(H~EEyY;y#WEacWi+tFTFe-{xZ zLy?*^+SZ!*tIyycow57m{C8{P;zKdA_zH4A?x7Nlu7+33aj-YHeA_#|$GN;C7($P zk=Jy$#}uYWjl|ZM3?>(4k>2#tH(6j7KHODrdD5`1N&HICu`QJA?T3+&0s7 z{+UdX&5#2^k?s)xQa%a`zu}%mC=HfA=GFfSyM$62Xg;3&*4t6~5WGmaE|+oZ1P0uZ zp&ep^hNeE{&SAoME4h+QJ;2^Bo^^(_%W!!Y z!r>XzGszi?q;oLyKT;)Ei5c*#2L_(N%S{>$H)sspzfUJ)jwlnI<=*Dry$=I4>~UFt z-*RVY9xz6uABI4p9-rsInJI@L_$xH{^q+y%{x!2_x`l~z0Dk0jT{>3F3;k4Yih*`y zsOJ393YhI6Z5GEarO*|WBubJ@I{q2^%?Z*%nIaLHB1UUQ$oRp6Y(4y9ZVLTXFFDzh z|0s5T7&cJ;+PQjEGb!pUph#seEl@zBoMq1H{iBp>Ud(0t{G@X~S84TcUlnwI{ zR%}nMnQ!D%zr(PSBvo>_iA?P--E4pvcmW?IKR<~RTUM+T%RpRIH zvzTKVm4nf&Ev1e>m zIoM6?*!4q&_in%_n;PUcHtkym&YN+{uW)GS1Bn zJUWfA|@z%0%8y`@RA+~{Gnrl#6RCt=eJ~Bl>2w=^!W|^~W%~`tx ztgY?$*x9pKW-JzQ-m#(&{sWMZ6crbp`Tqfv@wF)gK>P0({F9>7(!)~(V1HCngn+?K b2#*o?3Bsc?PxK1@-dup|>g^(O=AZo^gtPBw literal 0 HcmV?d00001 diff --git a/data/image/girls_are_weird/box.png b/data/image/girls_are_weird/box.png new file mode 100644 index 0000000000000000000000000000000000000000..0961360d75b61f928b400699e830a89062e4e707 GIT binary patch literal 343 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDD3?#L31Vw-pOS+@4BLl<6e(pbstU$g(vPY0F z14ES>14Ba#1H&(%P{RubhEkx$R|yOZRx=nF#0%!^3bX-Aa0d8-?ty1sRjP-CYApF`1*o1c=IR*74~?VROBKn;>08-nxGO3D+9 lQW+dm@{>{(JaZG%Q-e|yQz{Ejrh=`NUv2;Z literal 0 HcmV?d00001 diff --git a/data/image/girls_are_weird/girl_angry.png b/data/image/girls_are_weird/girl_angry.png new file mode 100644 index 0000000000000000000000000000000000000000..92cab0ac5a5577cb2d6f7005ec090c05526d007e GIT binary patch literal 1579 zcmZ`(Sy)q75T1K)LN3HC5+#Tri8icFjS-6=V8pN$gOR0bKtV;tm6SyhLcO>GR;^mw zShiHG;sV-Y1q;=yf+#8?mAYW*1*H@;LRHGD^!V6^KAbb({OA00=KE*Pc!cvf~+ z0Kf|gR)+)N6adEH1VVx@du&FAwR(_EkM)gNa@EJ*!Vy#nhhwN%*@aF-)wz;uhAYg}Ga(NWd+PE6%N zt$4v?X;7$xbC6#}>khVlVw{lO)OF`#bfl!VYrAwT^NODTt$qBVeAP<6dP&p-YwRV= z`{;1#p`OW0XWuGKrN9xdKWxnOO3JT!Zj~ToRgTrJH9d&P=AP_43z%PfawgO9`sYHo zZ8d?UKGVddUq9t&4eawmB$hEfNZ#nVMMof^?&2$a?iYj2&WxC0-xyLD=V-ghQm3}0 zo3qx+7mNQ&UU#zo*GUq(F6*WET*;AkzbFbcS#BDFHSnP#QnNw)i{Z1Njx`h%aW*+~ zQ==o~uX1LEW4M7ou&zet+YDr{^gFzD(eUmG(K8fSnc#j4ccTF?JFKV4Lq%=Rn!O|3 z>_6V!k={T>b(Xk(ZI8g6M~k27`j-s(A$={n9Ztx!SO59iCZYU>4dX}m=4v9YI$G*p zCF<%(x-YBk(ojIHGS-nJ%T0ItZ5pnhZaS?CT2|nxqIS{k@%BGC|74x}oq!3W(^{(A zruy&sgGK7Iwe?k>w#0m}E9cp`4P8Vf@7ze;!V_)5v80eGSGgL}3njV6qU?^4g7=+f zzWLDSlj?RKdkQ#2M)kWJ{z(76o#}6Xev|p+$c4M*q50Y6K6!lRF+I{#bT)6?lEY!r za)LF}IzQ*m`MyKhfbGL}9V<;rw*4V-v5x?S8T44t)_q~nUP|+*@ZK0NC)sLhA||^$ zD_|ihG+~VxYi9EUc73z~`f+axoQIWKxhp|7S{YAm<_Jv}?{@5MNc{r!A}<9n-EjAm z#I=s7?X$|(Zf^BQf4KSH?h3@J z6Xi9xriv^j^u3yceb*z7Kp8JG^p76`9fr*FI(@xfUzkh0|tlze@ zSPi%bk!$hE^Sq3iwn*-!?eS4qxmcp&#{KQuXc(XD)|7lr~CG)2z+I71;2 zn&iEi3vhh~lOmA?_PbyW(QlCqS5MJe&iQdWAeNLq;uC>2VDT=B77F+EbL^q%4Atx&it6lgy+ h&9UJ>gbj)DYgTRfe?rUp6G?~wApv3PGXJ=3{{n>(bY=hm literal 0 HcmV?d00001 diff --git a/data/image/girls_are_weird/girl_bored.png b/data/image/girls_are_weird/girl_bored.png new file mode 100644 index 0000000000000000000000000000000000000000..5d269e94302bad341f8e359a020edc00634a85ba GIT binary patch literal 1582 zcmZ`(X;f236u$4hgggk4pa_;lk_r?QFr_FGL>?)S1QjDtMG+HO6c;oKDr{qz&IGslO6gV*wdvS|z+eu0ABGs@V(razWgOh+Rxgd?~^38@yBdc{g@^uMc5DtVo zyt6|{nv>p*`?yHEdEs!-;u2iBS6||M&sU!FZ8mIXRcDKGG|jy)H;TwQ%*o*F2wTCGICiO3zQ zDEBkU+AIACI@qVna||)&IgVk8+gow00Y=K0Ke5gAIJ zkRY*TZc|N*1j6{B!6!V+4)(MYx}d4_nA5_Ln!`PvA2a`wP~?RbQVlLsy3*#;5*JJ!-luCoOnX zH|0_hGI3G4GO6V@8)-m1D*a(r1G?iX!@Yu`AEf$M|0z9IihPJa0LVD2|LmiNO(6pj z2%5o7aVhhZJs;{m-Ob?Y&ryZ7TlF7LA1M$xN+1p9`1XsoPrfrXbw1%stfY3jujpH4 z#-k2pja}w*kNU?ebe0I|V-x8toD+Wm6drtnAuG(ff6gS&yd zUtoC6TxC;InKJQ(|B*^FL5d>G_${y{Y zRmzkpk9w2!@WI#|S3tTv7KY|E7?=sS=Qz;98qC<11GHgy1PSspZcvI&Jbv1t^Wf1N zee7F2Hv=kJ-K~lW0g&uO~rflDDjvBGpyT(>Xk910f|kni-ZP+%|LuiaSSyRw3%54JL&HC>ejzc!)$b;=>VrA!@fy`H`{mQ*NV)9ggmS1qju2<1f7 zV{RxTft?{Qgk+AL2ji{zgpf~&siI(GqJ`4nNCSM|ce&LBNkcaTXXljaaV>v%dGQAH zz3CKdPt5td^;_(3zCb|F iSH5;={|_N?XWW)essB&VZLi!-6F?di8dxn-9QYRqb#yHN literal 0 HcmV?d00001 diff --git a/data/image/girls_are_weird/girl_happy.png b/data/image/girls_are_weird/girl_happy.png new file mode 100644 index 0000000000000000000000000000000000000000..8ac29ac0ac885946975a8c87290c14b4dc32621c GIT binary patch literal 1659 zcmZ`(X;f2J5T5s50)Z3~M9?aMP{j?gk+3L1h#Vvd1sW{7Yyt%-D2XB>26@3CXj}>f zMZh+0)mlJsq0v+D74>+KilxvJQRJy;K|mvJU^L=-ZG(==! zKF1sYEF@z8wE!p%fRHFgdBj)Uwo!(bwmNtF0xOiWXD z2w*D@;8`MoS0%u#tg?g~0aWfM(x9+4(=Z*g%6YU}^m_U)<^tAA%8w*{A@YY3I!8=h z%w*!|EdWew<3gaSW;W$C&6WhOF&!|$Y*)gqdj=GM9x3r(9hTcW+NVBnatRw>pKw0D z?C`+85=M!x8Y@!%(ARdL%X%`eD}3>?M@{K&cdKtz0J`+g>m#Gp{`glIHk!G)snZqD z0DkNOP93I&hE{`#6*(eY{&{PsKYjs=JCc~;lTkba>9EW$D!dflKQ+d4BQ^BZ4;A~fA!@7SM86n2g$ zU1-{+`oZ=cHT(140P^;AoG8hOCSG95XmF4|C)SPwO~+j1ab~I|e z&ffo9fYNj}+AW3B+E@#&kWQvc@Esa0hJ%55<8-Qn({sXNj*aW3u^D_^4f}O}%=f*O zf5neF&kHrVC~wriYknUb1+!=|5*8M!hz#_M#%k=flIP5#!c}VB1=)W7FZNcXxv&lQ zczg7^#xi;?mk1!5(GqC9GjCFE(mex>Wkdz`l(le|OC{9%$PQ=p%l>eIoxCh)l4=`r z_r=>6#N$bP&2Bb1Lh!P-nD(yw{(#b!OEeK%<}A!G;|*yIm-_pP06C<*8CN(b6qV&9 zx>ZEcdUH1{ZtJ2Fp9)`@1icTM@(ITwTp3zr!f0^O54!h>Iv<7YzJ1g(>4CRyMXplYciAN~p}_}LbWTJS|hRQr^lPptl^lF9_<2po#BVg>~+FT=RR9n|zARQlUH zmT;@15I<1_X{LLB!it$6k-LQ9Mx7-+z;_ivBod(j(v@{y)7VIfK z9U0!Frfbcm&uSL76dGA~{G3~qTcA;XGvQRTmGcGf{5{6f6a7SsoT8hioOaXt_L%rv zM`H=KP2qjzlR7mu?O}eWWuwO%@6m@3;uta)%`Cg}`GGX9&|Py~*p~m^4{t~6#*^I9 z_y=cY1>>6yH%E{fPGygI>Fw|BO8Zq)+iK|yy{NidnN}{gRM-V>JD49vn`Hg(Usx2fTZwAMFS?QbF5sSzA84i!3+mPq zowpw>L+-amcMVnL{TQNJH@=?bKujp*H7T!j6^rB*_3tV=y53H+$pK>U+Gt0!P3wuU zv%PlOQwz}*zIxw>xYbgV1HxwN*LBKX6P2B^KKpC0>gwh0 q>BZwY^LW&LcDX~xe*hb^Qqohm|3Bbf=IPB803>Td{OkP^3;zXBF`UT& literal 0 HcmV?d00001 diff --git a/data/image/girls_are_weird/girl_sad.png b/data/image/girls_are_weird/girl_sad.png new file mode 100644 index 0000000000000000000000000000000000000000..57e215e4d324021b316bcd6435927c11f3a44dba GIT binary patch literal 1513 zcmZ`(X;f2J5Werd5W*4?79p~U3y2a(AYe2igg}H?S%a2CK@%ikDKwFWRnUhEHCS0{ z1X-+U6`>Rr@qieCrqWXnqKHz^10snF1TBgfBq~Z@ditk7`sdD_x$}K9ckZ2$MMZ=X zP3=tq07PC`NDKfl3IL>r5zG?yt8We_aH&DzK>%DTGg}ZEVY^x2A49R0TCsw;@=*rEp=#;w0? z*Zppm8Mhp#g*(PSu8VriGMv_f0N1Y^M+2Oeuu*=YUB%tsZ&-4MIq26#p|sPI=&U&a z_3MT_WHIpB;|Oj&$vsu=UI5@aBY9lxej4pCfNB62zzLeZ#=x;QvWtqRx|1|QUFg&! zn^8b4%7lLyF2sQR+_Mw%rg?c{=p;gr;9KQ|xB$g}p84+eIcT$kc7l$oE>wNiv015!+izF&(z2{*tZsDk#K6b8m(4GRp zb;R#h3kEwH+QtX5tCSYq@CrKW4(YQ6)mygm^wik0${K$s2rjVIn;2E>6$~=!3!5-D zg8U-;#5sfg9j+7}F*ae7R2uD2T18|$VnJ3j*s`h&{y|~`L{?j0f3hd9C_!KR z?b1Cc4U~GE39~Wl?lDOJ=K99Wki=Xi!#U)+r_%EmjRA z?_QI4&AQ|iNwG{2K#FcxYG_^j08_Hse5bMhmca{2;ldSuT!&8p>UM0L*mL&kF9-VK z2xN7SsupPOeDd~H z%jra`Rk!~FI6Z|fpRDMy8EcEMx@AGdYi$~34Xs%oAt+c4@khL_zN5@p-`MY4VugM} zdG{u!-g>yNWTSW9XA8=U?XFL)tV9%nia*CAylt^xYnPke3=0{IV-u)ZObjqk>j6`Sa*C*cLpWo#y!$A$<44|8zE$r?ehFB`pF1e4YA0(opR zjO#FeuwdD*s*kh&^jvn8yf^|A5i-hD;2w)DVF$PLbvaGesaMS)3$t;bjO@MKK~_a^9X^kzxJ<9ycQ70!MJ* EZ-bsc(*OVf literal 0 HcmV?d00001 diff --git a/data/image/girls_are_weird/menu.png b/data/image/girls_are_weird/menu.png new file mode 100644 index 0000000000000000000000000000000000000000..72b982188cfe26b859ebe2cc0aaf7198be5a282c GIT binary patch literal 2860 zcmZ`*X+RU#7QQnH2@tljFDkS^0VO7&vV_$(5H=wKPuU)ZB?4*$1S(*nV~a(Ff+Cw1 zCD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3yd|d&^lZO+_VP1ke#kbe27guMEb{NHhISM!y6l9 z`I-YO-iZcY?>?re;RRxI-Zr7v?wd8si#%t%rXE3UsUi2DMaK?`wYaaWD zB08S^vz#~Htw_C|wV~b-oe9lTJwj4rqf)tym?K>D0c`2EbSmABO5YZ2Ys=VS&!F3E zq0surface ); diff --git a/lib/menu.h b/lib/menu.h index a00389a..c0a2d38 100644 --- a/lib/menu.h +++ b/lib/menu.h @@ -53,7 +53,7 @@ void initMenu ( struct eMenu*, char title[512], void initMenuElement ( struct eMenu*, struct eMenuElement*, char[512] ); void addMenuElement ( struct eMenu*, char[512] ); -void drawMenu ( SDL_Surface*, struct eMenu* ); +void drawMenu ( struct eMenu* ); void drawMenuElement ( struct eMenuElement* ); int calcMenu ( struct eMenu*, int, Uint32 ); diff --git a/lib/scene.c b/lib/scene.c new file mode 100644 index 0000000..5be8ad3 --- /dev/null +++ b/lib/scene.c @@ -0,0 +1,78 @@ +#include +#include +#include "scene.h" + +// ============================================================================ +// INIT +// ============================================================================ +void +initScene ( struct eScene* scene, char background[512], struct eActor* actor ) +{ + scene->surface = NULL; + scene->background = NULL; + strcpy(scene->backgroundPath, background); + scene->actor = actor; +} + +void +drawScene ( struct eScene* scene ) +{ + SDL_Surface* old_target = spGetRenderTarget(); + spSelectRenderTarget( scene->surface ); + + spBlitSurface( scene->surface->w/2,scene->surface->h/2,0, scene->background ); + drawActor( scene->actor ); + + spSelectRenderTarget( old_target ); +} + + +void +resizeScene ( struct eScene* scene ) +{ + if ( scene->background != NULL ) + spDeleteSurface( scene->background ); + if ( scene->surface != NULL ) + spDeleteSurface( scene->surface ); + + scene->background = spLoadSurfaceZoom( scene->backgroundPath, + spGetSizeFactor()/ 2 ); + scene->surface = spCreateSurface(1000,1000); +} + +void +initActor ( struct eActor* actor, char name[512] ) +{ + strcpy(actor->name, name); + actor->emoteCount = 0; + actor->emoteSelection = -1; +} + +void +drawActor ( struct eActor* actor ) +{ + SDL_Surface* target = spGetRenderTarget(); + if ( actor->emote != NULL) + spBlitSurface( target->w / 2,target->h - (target->h / 2),0, actor->emote ); +} + +void +resizeActor ( struct eActor* actor ) +{ + int nowEmote = actor->emoteSelection; + + if ( actor->emote != NULL ) + spDeleteSurface( actor->emote ); + if ( nowEmote >= 0 && actor->emoteCount > 0 ) + actor->emote = spLoadSurfaceZoom( actor->emotePaths[nowEmote], + spGetSizeFactor()/ 3); + else + actor->emote = NULL; +} + +void +addEmote ( struct eActor* actor, char path[512] ) +{ + strcpy( actor->emotePaths[actor->emoteCount], path ); + actor->emoteCount += 1; +} diff --git a/lib/scene.h b/lib/scene.h new file mode 100644 index 0000000..b4183d8 --- /dev/null +++ b/lib/scene.h @@ -0,0 +1,34 @@ +#include + +struct eActor +{ + char name[512]; + + Uint16 textColor; + char emotePaths[20][512]; + int emoteCount; + int emoteSelection; + + SDL_Surface* emote; +}; + +struct eScene +{ + char backgroundPath[512]; + SDL_Surface* background; + + struct eActor* actor; + + SDL_Surface* surface; +}; + + +void initScene ( struct eScene*, char[512], struct eActor* ); +void drawScene ( struct eScene* ); +void resizeScene ( struct eScene* ); + +void initActor ( struct eActor*, char[512] ); +void drawActor ( struct eActor* ); +void resizeActor ( struct eActor* ); +void addEmote ( struct eActor*, char[512] ); + diff --git a/tests/test-dialogue.c b/tests/test-dialogue.c new file mode 100644 index 0000000..a107034 --- /dev/null +++ b/tests/test-dialogue.c @@ -0,0 +1,114 @@ +#include +#include +#include "../lib/font.h" +#include "../lib/scene.h" +#include "test-dialogue.h" + +SDL_Surface* screen = NULL; + +struct eScene* mainScene = NULL; +struct eActor* girl = NULL; + +// ============================================================================ + +int +main ( int argc, char **argv ) +{ + init(); + spLoop( draw_test, calc_test, 10, resize, NULL ); + + cleanup(); + return 0; +} + +// ============================================================================ +// TEST +// ============================================================================ +// draw this whole sprite test (aka, simple background, text, and the sprites.) +void +draw_test ( void ) +{ + spSelectRenderTarget(spGetWindowSurface()); + spClearTarget( spGetRGB(64,64,64) ); + + screen = spGetWindowSurface(); + drawScene( mainScene ); + spBlitSurface(screen->w/2,screen->h/2,0, mainScene->surface); + + spFlip(); +} + +// input for the sprite test +int +calc_test ( Uint32 steps ) +{ + if ( spGetInput()->button[SP_BUTTON_SELECT] ) + return -1; + return 0; +} + +void +resize ( Uint16 w, Uint16 h ) +{ + spSelectRenderTarget( spGetWindowSurface()); + resizeScene( mainScene ); + resizeActor( girl ); + resizeFonts(); +} + + +// ============================================================================ +// INIT +// ============================================================================ +int +init ( void ) +{ + init_sparrow3d(); + init_fonts(); + init_scenes(); + resize( spGetWindowSurface()->w, spGetWindowSurface()->h ); +} + +void +init_fonts ( void ) +{ + addFont("data/font/cozette-vector.ttf"); + addFont("data/font/love_me_chain.ttf"); +} + +void +init_scenes ( void ) +{ + girl = malloc(sizeof(struct eActor)); + initActor(girl, "Girl"); + addEmote(girl, "data/image/girls_are_weird/girl_happy.png"); + addEmote(girl, "data/image/girls_are_weird/girl_bored.png"); + addEmote(girl, "data/image/girls_are_weird/girl_sad.png"); + + addEmote(girl, "data/image/girls_are_weird/girl_angry.png"); + girl->emoteSelection = GIRL_HAPPY; + + mainScene = malloc(sizeof(struct eScene)); + initScene(mainScene, "data/image/girls_are_weird/background.png", girl); +} + +void +init_sparrow3d ( void ) +{ + spSetDefaultWindowSize( 320, 240 ); + spInitCore(); + spCreateDefaultWindow(); + spSetZSet(0); + spSetZTest(0); +} + + +// ============================================================================ +// CLEANUP +// ============================================================================ +int +cleanup ( void ) +{ + cleanupFonts(); + spQuitCore(); +} diff --git a/tests/test-dialogue.h b/tests/test-dialogue.h new file mode 100644 index 0000000..ca76e9c --- /dev/null +++ b/tests/test-dialogue.h @@ -0,0 +1,27 @@ +#include + +#define FN_COZETTE 0 +#define FN_LOVEMECHAIN 1 +#define SF_TAMBORINE 0 +#define SF_EEUH 1 + +#define GIRL_HAPPY 0 +#define GIRL_BORED 1 +#define GIRL_SAD 2 +#define GIRL_ANGRY 3 + + +int calc_test ( Uint32 ); +void draw_test ( void ); +void draw_scene ( void ); +void draw_hud ( void ); +void resize ( Uint16, Uint16 ); + +int init ( void ); + +void init_scenes ( void ); +void init_images ( void ); +void init_fonts ( void ); +void init_sparrow3d ( void ); + +int cleanup ( void ); diff --git a/tests/test-menu.c b/tests/test-menu.c index d6e5f5e..c8d2253 100644 --- a/tests/test-menu.c +++ b/tests/test-menu.c @@ -41,7 +41,7 @@ draw_test ( void ) spClearTarget( spGetRGB(64,64,64) ); spSelectRenderTarget(spGetWindowSurface()); - drawMenu ( testMenu->surface, testMenu ); + drawMenu ( testMenu ); spBlitSurface( spGetWindowSurface()->w/2, spGetWindowSurface()->h/2, 0, testMenu->surface );