Archived
1
0
Disbranĉigi 0

Add VN-style dialogue test

This commit is contained in:
Jaidyn Ann 2020-06-07 21:58:36 -05:00
parent dc39771307
commit 1f7e0c7bab
16 changed files with 426 additions and 7 deletions

View File

@ -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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

165
data/script/script.rpy Normal file
View File

@ -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

View File

@ -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 );

View File

@ -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 );

78
lib/scene.c Normal file
View File

@ -0,0 +1,78 @@
#include <sparrow3d.h>
#include <string.h>
#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;
}

34
lib/scene.h Normal file
View File

@ -0,0 +1,34 @@
#include <sparrow3d.h>
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] );

114
tests/test-dialogue.c Normal file
View File

@ -0,0 +1,114 @@
#include <sparrow3d.h>
#include <string.h>
#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();
}

27
tests/test-dialogue.h Normal file
View File

@ -0,0 +1,27 @@
#include <sparrow3d.h>
#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 );

View File

@ -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 );