From 98152d733a5713a206aa9285a5b5c71ac1ed6019 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Sun, 7 Jun 2020 22:14:29 -0500 Subject: [PATCH] Remove scene/dialogue tests --- Makefile | 8 ++- lib/scene.c | 78 ----------------------------- lib/scene.h | 34 ------------- tests/test-dialogue.c | 114 ------------------------------------------ tests/test-dialogue.h | 27 ---------- 5 files changed, 3 insertions(+), 258 deletions(-) delete mode 100644 lib/scene.c delete mode 100644 lib/scene.h delete mode 100644 tests/test-dialogue.c delete mode 100644 tests/test-dialogue.h diff --git a/Makefile b/Makefile index 7f26d84..6e4160e 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 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) diff --git a/lib/scene.c b/lib/scene.c deleted file mode 100644 index 5be8ad3..0000000 --- a/lib/scene.c +++ /dev/null @@ -1,78 +0,0 @@ -#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 deleted file mode 100644 index b4183d8..0000000 --- a/lib/scene.h +++ /dev/null @@ -1,34 +0,0 @@ -#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 deleted file mode 100644 index a107034..0000000 --- a/tests/test-dialogue.c +++ /dev/null @@ -1,114 +0,0 @@ -#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 deleted file mode 100644 index ca76e9c..0000000 --- a/tests/test-dialogue.h +++ /dev/null @@ -1,27 +0,0 @@ -#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 );