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 0000000..8a8e96a Binary files /dev/null and b/data/image/girls_are_weird/background.png differ diff --git a/data/image/girls_are_weird/box.png b/data/image/girls_are_weird/box.png new file mode 100644 index 0000000..0961360 Binary files /dev/null and b/data/image/girls_are_weird/box.png differ 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 0000000..92cab0a Binary files /dev/null and b/data/image/girls_are_weird/girl_angry.png differ 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 0000000..5d269e9 Binary files /dev/null and b/data/image/girls_are_weird/girl_bored.png differ 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 0000000..8ac29ac Binary files /dev/null and b/data/image/girls_are_weird/girl_happy.png differ 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 0000000..57e215e Binary files /dev/null and b/data/image/girls_are_weird/girl_sad.png differ diff --git a/data/image/girls_are_weird/menu.png b/data/image/girls_are_weird/menu.png new file mode 100644 index 0000000..72b9821 Binary files /dev/null and b/data/image/girls_are_weird/menu.png differ diff --git a/data/script/script.rpy b/data/script/script.rpy new file mode 100644 index 0000000..40bf53f --- /dev/null +++ b/data/script/script.rpy @@ -0,0 +1,165 @@ +# You can place the script of your game in this file. + +init: + # Declare images below this line, using the image statement. + # eg. image eileen happy = "eileen_happy.png" + + image g = "images/girl_happy.png" + image g angry = "images/girl_angry.png" + image g sad = "images/girl_sad.png" + image g bored = "images/girl_bored.png" + + image street = "images/background.png" + + # Declare characters used by this game. + + $ g = Character('Sakura-chan') + $ m = Character(what_color="#bae9fb") + + $_game_menu_screen = "_quit_prompt" + +# The game starts here. +label start: + $ config.rollback_enabled = False + scene street with pixellate + show g + m "There is this girl at my school." + m "She's so goddamn cute." + m "I heard from my mate that she's having boyfriend problems." + m "What she really needs now, is a nice guy like me." + "Hey, Sakura-chan!" + show g bored + g "Hey" + m "She needs a nice guy." + m "She is like a goddess." + m "I think about her... every night." + show g + g "Do we know each other?" + "I'm in your class!" + show g bored + g "Oh, right." + g "Oh you must sit with... those... otaku guys. Uh." + m "Bitch." + "Yeah. Them." + g "Sorry, school is so boring." + g "I hate this stupid school!" + show g + g "Urgh, and I hate this uniform. It makes me look so fat." + menu: + "Yeah, lay off the doughnuts then.": + "Yeah, you look a bit chunky in that." + show g angry + g "What the hell? Like you can talk." + g "Idiot." + g "It's 'cos of jerks like you that regular girls like me get eating disorders." + g "Twat." + "No, you look fine.": + "No, you look fine!" + show g sad + g "Urgh but I'm sooo fat!" + g "I gotta go on a diet, but I just like sweets too much!" + g "I hate myself. Why does this happen to me?!?" + + + show g + g "Actually, I had a fight with my boyfriend because he said I was fat." + show g sad + g "He's such a... cunt." + show g angry + g "I hate him!" + show g bored + g "He's pretty thick too... Like, he comes out with the most moronic things." + g "Makes me ashamed to be around him." + show g + g "He's pretty thick really." + "Heh..." + menu: + "Yeah, sounds like a real idiot.": + "Yeah, he sounds like a real idiot!" + show g angry + g "D-don't be mean to him!" + g "What the hell, you don't even know him." + g "Will you butt out?" + g "We have enough problems without losers like you adding to them!!!" + "Fine, whatever." + + "Aww, you're being unfair.": + "Aww, don't you think you're being a little unfair to him?" + show g sad + g "Ah I knew you wouldn't understand." + g "Stupid boys always stick together!" + show g bored + g "Guess you're just an idiot like him." + + show g bored + g "Hey, do you have any cigarettes?" + menu: + "Yes!": + "Y-yes." + g "..." + show g angry + g "What the hell, this is made of fucking chocolate!?" + g "Grow up a little... man, I can't believe you're the same age as me." + + "No.": + "No, I don't think you should smoke." + show g angry + g "What are you, my mother?" + g "Jeez..." + + show g bored + g "Damn, I hate being a teenager." + g "Stupid family, stupid school..." + show g + g "Wouldn't it be nice to do something fun?" + menu: + "Let's run away!": + "We could run away together." + show g bored + g "No thanks." + g "Besides, who has the money?" + g "Do you ever think anything through?" + g "...Stupid soft-headed boys." + + "Be more responsible.": + "You should be more responsible." + show g angry + g "What?" + g "What the hell? I have a job as well as school." + g "So stop lecturing me!" + g "I bet mummy and daddy buy you everything!" + + + show g + g "OK, I've gotta go soon... Got things to do." + g "So what did you want?" + m "Oh man, here we go." + "Uhh..." + m "Just say it, say it say it...!!!" + "Would... you like to hang out?" + show g bored + g "..." + g "I have a boyfriend." + "But you were having trouble with him." + g "Yeah." + g "You're just... not my type." + "..." + g "I think I'm going to make up with my boyfriend now." + m "Cow..." + show g + g "So, see you. It was, uh, nice chatting to you..." + g "Uh... Akihiko was it?" + m "That's not my name." + "Yeah, Akihiko." + g "So, maybe I'll see you in class!" + m "Riiight." + g "Bye!" + hide g + m "Stupid goddamn bitchy girls..." + m "They can never appreciate a nice guy like me." + m "Always clinging to popular neanderthal types." + m "Oh man, if I had a girl like her..." + m "..." + m "...!" + m "..." + scene black with pixellate diff --git a/lib/menu.c b/lib/menu.c index 2b3d258..c2394fe 100644 --- a/lib/menu.c +++ b/lib/menu.c @@ -91,7 +91,7 @@ resizeMenu ( struct eMenu* menu ) // ============================================================================ // draw an eMenu on it's surface. void -drawMenu ( SDL_Surface* surface, struct eMenu* menu ) +drawMenu ( struct eMenu* menu ) { SDL_Surface* old_surface = spGetRenderTarget( ); spSelectRenderTarget( menu->surface ); 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 );