generated from sigonasr2/CPlusPlusProjectTemplate
Flesh out some more test cases for cutscene testing
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
1651452c34
commit
07a4c5bbfa
Binary file not shown.
@ -27,7 +27,7 @@ class SeasonI:public PixelGameEngine{
|
|||||||
SeasonI(){sAppName="Season I: Winters of Loneliness";}
|
SeasonI(){sAppName="Season I: Winters of Loneliness";}
|
||||||
bool OnUserCreate()override;
|
bool OnUserCreate()override;
|
||||||
void SetupMoveList(); 됐어
|
void SetupMoveList(); 됐어
|
||||||
void SetupItemList();
|
void SetupItemList(); 됐어
|
||||||
void SetupPartyMemberStats(); 됐어
|
void SetupPartyMemberStats(); 됐어
|
||||||
void SetupAnimations(); 됐어
|
void SetupAnimations(); 됐어
|
||||||
void SetupObjectInfo(); 됐어
|
void SetupObjectInfo(); 됐어
|
||||||
@ -35,15 +35,15 @@ class SeasonI:public PixelGameEngine{
|
|||||||
void SetupBattleProperties(); 됐어
|
void SetupBattleProperties(); 됐어
|
||||||
void SetupCutscenes();
|
void SetupCutscenes();
|
||||||
void SetupMapList();
|
void SetupMapList();
|
||||||
void SetGameFlag(Flag flag,bool val);
|
void SetGameFlag(Flag flag,bool val); 됐어
|
||||||
void LoadMap(Map*map);
|
void LoadMap(Map*map);
|
||||||
void SaveMap(Map*map);
|
void SaveMap(Map*map);
|
||||||
void AddItemToPlayerInventory(ItemName item);
|
void AddItemToPlayerInventory(ItemName item);
|
||||||
Decal*CreateSprite(std::string spriteName);
|
Decal*CreateSprite(std::string spriteName);
|
||||||
Object*CreateObjectInfo(Object*obj,std::string spriteFileName,vi2d size,Flag enableFlag=Flag::NONE,Flag disableFlag=Flag::NONE); 됐어
|
Object*CreateObjectInfo(Object*obj,std::string spriteFileName,vi2d size,Flag enableFlag=Flag::NONE,Flag disableFlag=Flag::NONE); 됐어
|
||||||
vi2d grid(int x, int y);
|
vi2d grid(int x, int y);
|
||||||
bool GetGameFlag(int flag);
|
bool GetGameFlag(int flag); 됐어
|
||||||
bool GetGameFlag(Flag flag);
|
bool GetGameFlag(Flag flag); 됐어
|
||||||
//You're probably trying to add an object to the world. Use this function inside of AddObjectToWorld(CreateObject(...))
|
//You're probably trying to add an object to the world. Use this function inside of AddObjectToWorld(CreateObject(...))
|
||||||
//You only need to use this function if you want to create an object from pre-defined OBJ_INFO variables.
|
//You only need to use this function if you want to create an object from pre-defined OBJ_INFO variables.
|
||||||
Object*CreateObject(int id,vd2d pos);
|
Object*CreateObject(int id,vd2d pos);
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 264 KiB After Width: | Height: | Size: 264 KiB |
Binary file not shown.
134
test/test.cpp
134
test/test.cpp
@ -23,6 +23,11 @@
|
|||||||
#include "../SeasonI.h"
|
#include "../SeasonI.h"
|
||||||
#include "../map.h"
|
#include "../map.h"
|
||||||
|
|
||||||
|
extern int frameCount;
|
||||||
|
extern double CUTSCENE_FADE_VALUE;
|
||||||
|
extern Cutscene*CurrentCutscene;
|
||||||
|
extern ActionType CurrentAction;
|
||||||
|
extern vd2d cameraPos;
|
||||||
extern std::array<Entity*,7> PARTY_MEMBER_STATS;
|
extern std::array<Entity*,7> PARTY_MEMBER_STATS;
|
||||||
extern Entity::pstats_t partyMemberDefaultStats;
|
extern Entity::pstats_t partyMemberDefaultStats;
|
||||||
extern std::map<std::string,Decal*> SPRITES;
|
extern std::map<std::string,Decal*> SPRITES;
|
||||||
@ -54,7 +59,7 @@ void TestSpriteInitialized(std::vector<std::string> sprList) {
|
|||||||
Test("Sprite "+sprList[i]+" should be initialized",
|
Test("Sprite "+sprList[i]+" should be initialized",
|
||||||
SPRITES[sprList[i]]!=nullptr);
|
SPRITES[sprList[i]]!=nullptr);
|
||||||
Test("Sprite "+sprList[i]+" should have a non-zero width and height",
|
Test("Sprite "+sprList[i]+" should have a non-zero width and height",
|
||||||
SPRITES[sprList[i]]->sprite->width!=0&&SPRITES["terrainmap.png"]->sprite->height!=0);
|
SPRITES[sprList[i]]->sprite->width!=0&&SPRITES[sprList[i]]->sprite->height!=0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,6 +210,133 @@ bool SeasonI::OnUserCreate(){
|
|||||||
ITEMLIST[ItemName::FREEZE_PACKET]->description=="Lets out some blistering cold weather.");
|
ITEMLIST[ItemName::FREEZE_PACKET]->description=="Lets out some blistering cold weather.");
|
||||||
Test("Freeze Packet drop chance is set properly",
|
Test("Freeze Packet drop chance is set properly",
|
||||||
ITEMLIST[ItemName::FREEZE_PACKET]->dropChance==256);
|
ITEMLIST[ItemName::FREEZE_PACKET]->dropChance==256);
|
||||||
|
Test("No Maps are loaded",
|
||||||
|
MAPS.size()==0);
|
||||||
|
SetupMapList();
|
||||||
|
Test("Maps are loaded",
|
||||||
|
MAPS.size()!=0);
|
||||||
|
Test("No Cutscenes are loaded",
|
||||||
|
CUTSCENES.size()==0);
|
||||||
|
SetupCutscenes();
|
||||||
|
Test("Calling SetupCutscenes() loads up different cutscenes",
|
||||||
|
CUTSCENES.size()!=0);
|
||||||
|
Test("No active cutscene yet",
|
||||||
|
CurrentCutscene==nullptr);
|
||||||
|
StartCutscene(CUTSCENES[CutsceneName::TEST_CUTSCENE]);
|
||||||
|
Test("Starting a cutscene sets the current cutscene",
|
||||||
|
CurrentCutscene!=nullptr);
|
||||||
|
Test("Current Action should not be updated yet",
|
||||||
|
CurrentAction==ActionType::NONE);
|
||||||
|
updateGame();
|
||||||
|
Test("HandleCutscenes should get called in updateGame(), updating the current action",
|
||||||
|
CurrentAction!=ActionType::NONE);
|
||||||
|
int startFrame=frameCount;
|
||||||
|
while (CurrentAction!=ActionType::NONE) {
|
||||||
|
updateGame();
|
||||||
|
}
|
||||||
|
std::cout<<"Frame Count: "<<(frameCount-startFrame)<<std::endl;
|
||||||
|
Test("Cutscene is now finished",
|
||||||
|
CurrentAction==ActionType::NONE);
|
||||||
|
Test("Test Flag 1 is set",
|
||||||
|
GetGameFlag(Flag::TEST_FLAG1));
|
||||||
|
Test("Test Flag 2 is not set",
|
||||||
|
!GetGameFlag(Flag::TEST_FLAG2));
|
||||||
|
Test("Test Flag 1 (int cast) is still set",
|
||||||
|
GetGameFlag((int)Flag::TEST_FLAG1));
|
||||||
|
Test("Test Flag 2 (int cast) is still not set",
|
||||||
|
!GetGameFlag((int)Flag::TEST_FLAG2));
|
||||||
|
Test("Test Flag 1 (Flag cast) is still set",
|
||||||
|
GetGameFlag((Flag)1));
|
||||||
|
Test("Test Flag 2 (Flag cast) is still not set",
|
||||||
|
!GetGameFlag((Flag)2));
|
||||||
|
Test("Current Map is not set",
|
||||||
|
CURRENT_MAP==nullptr);
|
||||||
|
Test("Main Character flag is not set",
|
||||||
|
!GetGameFlag(Flag::HAS_MAIN));
|
||||||
|
SetGameFlag(Flag::HAS_MAIN,true);
|
||||||
|
Test("Main Character flag is set",
|
||||||
|
GetGameFlag(Flag::HAS_MAIN));
|
||||||
|
SetGameFlag(Flag::HAS_MAIN,false);
|
||||||
|
Test("Main Character flag is unset",
|
||||||
|
!GetGameFlag(Flag::HAS_MAIN));
|
||||||
|
SetGameFlag(Flag::HAS_MAIN,true);
|
||||||
|
Cutscene*FeatureTestCutscene=new Cutscene({
|
||||||
|
액션 Fade(),
|
||||||
|
액션 CreateObjects({
|
||||||
|
new Standard_Obj(PLAYER,"player",{64,64},ANIMATIONS["player.png"],{1,1},MAGENTA),
|
||||||
|
new Standard_Obj(PLAYER,"player",{136,136},ANIMATIONS["player.png"],{1,1},RED),
|
||||||
|
new Standard_Obj(PLAYER,"player",{96,96},ANIMATIONS["player.png"],{1,1},DARK_GREEN),
|
||||||
|
}),
|
||||||
|
액션 Fade(true),
|
||||||
|
액션 SetFlagWhenCutsceneEnds(Flag::TEST_FLAG3),
|
||||||
|
액션 SetFlag(Flag::TEST_FLAG2,true),
|
||||||
|
액션 PanCamera({128,128},BOTH,1),
|
||||||
|
액션 MoveCutsceneObjectAsync(1,{80,64},5),
|
||||||
|
액션 PanCameraAsync({64,0},BOTH),
|
||||||
|
액션 DialogBoxAsync(R"(Hello!
|
||||||
|
This is a test message that lets us trigger straight from a cutscene! Cool!)"),
|
||||||
|
액션 ModifyObject(0,ANIMATIONS["player.png"],{5,5},MAGENTA),
|
||||||
|
액션 MoveCutsceneObject(1,{320,64},1),
|
||||||
|
액션 DialogBox(R"(Hello!)"),
|
||||||
|
액션 class LoadMap(MAPS[MapName::TWOSON]),
|
||||||
|
액션 MovePlayerObjects({16,16}),});
|
||||||
|
Test("No cutscene is playing",
|
||||||
|
CurrentCutscene==nullptr);
|
||||||
|
StartCutscene(FeatureTestCutscene);
|
||||||
|
updateGame();
|
||||||
|
Test("Current action should be fading",
|
||||||
|
CurrentAction==ActionType::FADE);
|
||||||
|
double previous_fade_value=CUTSCENE_FADE_VALUE;
|
||||||
|
updateGame();
|
||||||
|
Test("Fading causes CUTSCENE_FADE_VALUE to increase",
|
||||||
|
CUTSCENE_FADE_VALUE>previous_fade_value);
|
||||||
|
Test("There should be no objects in the game",
|
||||||
|
OBJECTS.size()==0);
|
||||||
|
while (CurrentAction==ActionType::FADE) {
|
||||||
|
updateGame();
|
||||||
|
}
|
||||||
|
Test("When faded out, CUTSCENE_FADE_VALUE should be 255",
|
||||||
|
CUTSCENE_FADE_VALUE==255);
|
||||||
|
Test("Next cutscene action should be CreateObjects",
|
||||||
|
CurrentAction==ActionType::CREATE_OBJECTS);
|
||||||
|
Test("There should be 3 objects in the game",
|
||||||
|
OBJECTS.size()==3);
|
||||||
|
Test("Cutscene objects should have the temp flag set",
|
||||||
|
OBJECTS[0]->temp&&OBJECTS[1]->temp&&OBJECTS[2]->temp);
|
||||||
|
updateGame();
|
||||||
|
Test("Next cutscene action should be Fade back in",
|
||||||
|
CurrentAction==ActionType::FADE);
|
||||||
|
previous_fade_value=CUTSCENE_FADE_VALUE;
|
||||||
|
updateGame();
|
||||||
|
Test("Fading in causes CUTSCENE_FADE_VALUE to decrease",
|
||||||
|
CUTSCENE_FADE_VALUE<previous_fade_value);
|
||||||
|
while (CurrentAction==ActionType::FADE) {
|
||||||
|
updateGame();
|
||||||
|
}
|
||||||
|
Test("Next cutscene action should be setting a flag when the cutscene ends",
|
||||||
|
CurrentAction==ActionType::SET_FLAG_WHEN_CUTSCENE_ENDS);
|
||||||
|
Test("Ending cutscene flag is stored properly with proper flag and value",
|
||||||
|
CurrentCutscene->GetEndingCutsceneFlag()==Flag::TEST_FLAG3&&CurrentCutscene->GetEndingCutsceneVal());
|
||||||
|
updateGame();
|
||||||
|
Test("Next cutscene action should be setting a flag on the spot",
|
||||||
|
CurrentAction==ActionType::SET_FLAG);
|
||||||
|
Test("Test Flag 2 should now be set",
|
||||||
|
GetGameFlag(Flag::TEST_FLAG2));
|
||||||
|
Test("Test Flag 2 should still not be set",
|
||||||
|
!GetGameFlag(Flag::TEST_FLAG3));
|
||||||
|
cameraPos={0,0};
|
||||||
|
Test("Camera position should be {0,0}",
|
||||||
|
cameraPos.x==0&&cameraPos.y==0);
|
||||||
|
updateGame();
|
||||||
|
Test("Next cutscene action should be panning the camera",
|
||||||
|
CurrentAction==ActionType::PAN_CAMERA);
|
||||||
|
Test("Camera position should be moving towards {128,128}",
|
||||||
|
cameraPos.x>0&&cameraPos.y>0);
|
||||||
|
while (CurrentAction==ActionType::PAN_CAMERA) {
|
||||||
|
updateGame();
|
||||||
|
}
|
||||||
|
Test("Camera position should be {128,128}",
|
||||||
|
cameraPos.x==128&&cameraPos.y==128);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user