Remove scene/dialogue tests
This commit is contained in:
parent
1f7e0c7bab
commit
98152d733a
8
Makefile
8
Makefile
|
@ -3,8 +3,8 @@
|
|||
# multiple-targets like sparrow3D!
|
||||
# whoops.
|
||||
|
||||
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
|
||||
SRC = lib/button.c lib/font.c lib/sound.c lib/menu.c
|
||||
OBJ = button.o font.o sound.o menu.o
|
||||
DEP = $(SRC:.c=.d)
|
||||
|
||||
DYNAMIC = -lSDL_ttf -lSDL_mixer -lSDL_image -lSDL -lm
|
||||
|
@ -58,10 +58,8 @@ 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 test-dialogue
|
||||
tests: test-menu test-sprites
|
||||
@echo "=== Tests built ==="
|
||||
#efemmera: main.c $(OBJ) makeBuildDir
|
||||
#$(CC) $(CFLAGS) $(LINK_FLAGS) $< $(OBJ) $(SDL) $(INCLUDE) $(LIB) $(EFEMMERA_STATIC) $(DYNAMIC) -o $(BUILD)/$@$(SUFFIX)
|
||||
|
|
78
lib/scene.c
78
lib/scene.c
|
@ -1,78 +0,0 @@
|
|||
#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
34
lib/scene.h
|
@ -1,34 +0,0 @@
|
|||
#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] );
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
#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();
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
#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 );
|
Reference in New Issue