|
|
|
@ -49,7 +49,7 @@ int testCount=0; |
|
|
|
|
int MAX_ITERATIONS=1000; |
|
|
|
|
int iterations=0; |
|
|
|
|
|
|
|
|
|
enum KeyIdentifier{ |
|
|
|
|
enum class KeyIdentifier{ |
|
|
|
|
UP, |
|
|
|
|
RIGHT, |
|
|
|
|
DOWN, |
|
|
|
@ -195,6 +195,13 @@ void TestSpriteInitialized(std::vector<std::string> sprList) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool SeasonI::OnUserCreate(){ |
|
|
|
|
srand(time(NULL)); |
|
|
|
|
GAME=this; |
|
|
|
|
for (int i=1;i<7;i++) { |
|
|
|
|
CreateLayer(); |
|
|
|
|
EnableLayer(i,true); |
|
|
|
|
} |
|
|
|
|
SetPixelMode(Pixel::ALPHA); |
|
|
|
|
GAME_STATE=GameState::TEST_GAME; |
|
|
|
|
Test("We start in the TEST_GAME state", |
|
|
|
|
GAME_STATE==GameState::TEST_GAME); |
|
|
|
@ -361,12 +368,12 @@ bool SeasonI::OnUserCreate(){ |
|
|
|
|
CurrentCutscene!=nullptr); |
|
|
|
|
Test("Current Action should not be updated yet", |
|
|
|
|
CurrentAction==ActionType::NONE); |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test("HandleCutscenes should get called in updateGame(), updating the current action", |
|
|
|
|
CurrentAction!=ActionType::NONE); |
|
|
|
|
int startFrame=frameCount; |
|
|
|
|
TestWhile("Cutscene should complete entirely",CurrentAction!=ActionType::NONE) { |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
} |
|
|
|
|
std::cout<<"Frame Count: "<<(frameCount-startFrame)<<std::endl; |
|
|
|
|
Test("Cutscene is now finished", |
|
|
|
@ -417,17 +424,19 @@ bool SeasonI::OnUserCreate(){ |
|
|
|
|
Test("No cutscene is playing", |
|
|
|
|
CurrentCutscene==nullptr); |
|
|
|
|
StartCutscene(FeatureTestCutscene); |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test("Current action should be fading", |
|
|
|
|
CurrentAction==ActionType::FADE); |
|
|
|
|
double previous_fade_value=CUTSCENE_FADE_VALUE; |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
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); |
|
|
|
|
Test("Player should not be able to move during a cutscene", |
|
|
|
|
!PlayerCanMove()); |
|
|
|
|
TestWhile("Fade out should finish",CurrentAction==ActionType::FADE) { |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
} |
|
|
|
|
Test("When faded out, CUTSCENE_FADE_VALUE should be 255", |
|
|
|
|
CUTSCENE_FADE_VALUE==255); |
|
|
|
@ -437,21 +446,21 @@ bool SeasonI::OnUserCreate(){ |
|
|
|
|
OBJECTS.size()==3); |
|
|
|
|
Test("Cutscene objects should have the temp flag set", |
|
|
|
|
OBJECTS[0]->temp&&OBJECTS[1]->temp&&OBJECTS[2]->temp); |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test("Next cutscene action should be Fade back in", |
|
|
|
|
CurrentAction==ActionType::FADE); |
|
|
|
|
previous_fade_value=CUTSCENE_FADE_VALUE; |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test("Fading in causes CUTSCENE_FADE_VALUE to decrease", |
|
|
|
|
CUTSCENE_FADE_VALUE<previous_fade_value); |
|
|
|
|
TestWhile("Fade in should finish",CurrentAction==ActionType::FADE) { |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
} |
|
|
|
|
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(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test("Next cutscene action should be setting a flag on the spot", |
|
|
|
|
CurrentAction==ActionType::SET_FLAG); |
|
|
|
|
Test("Test Flag 2 should now be set", |
|
|
|
@ -461,7 +470,7 @@ bool SeasonI::OnUserCreate(){ |
|
|
|
|
cameraPos={0,0}; |
|
|
|
|
Test("Camera position should be {0,0}", |
|
|
|
|
cameraPos.x==0&&cameraPos.y==0); |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test("Next cutscene action should be panning the camera", |
|
|
|
|
CurrentAction==ActionType::PAN_CAMERA); |
|
|
|
|
Test("Camera position should be moving towards {128,128}", |
|
|
|
@ -469,20 +478,20 @@ bool SeasonI::OnUserCreate(){ |
|
|
|
|
Test("Temporary cutscene object 1 is at position {136,136}", |
|
|
|
|
CurrentCutscene->GetCutsceneObjects()[1]->GetPos().x==136&&CurrentCutscene->GetCutsceneObjects()[1]->GetPos().y==136); |
|
|
|
|
TestWhile("Panning Camera should finish",CurrentAction==ActionType::PAN_CAMERA) { |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
} |
|
|
|
|
Test("Camera position should be {128,128}", |
|
|
|
|
cameraPos.x==128&&cameraPos.y==128); |
|
|
|
|
Test("Next cutscene action is the async cutscene object movement", |
|
|
|
|
CurrentAction==ActionType::MOVE_CUTSCENE_OBJ_ASYNC); |
|
|
|
|
vd2d prevCutsceneObjPosition=CurrentCutscene->GetCutsceneObjects()[1]->GetPos(); |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test("Cutscene object is moving towards {80,64}", |
|
|
|
|
CurrentCutscene->GetCutsceneObjects()[1]->GetPos().x<prevCutsceneObjPosition.x&&CurrentCutscene->GetCutsceneObjects()[1]->GetPos().y<prevCutsceneObjPosition.y); |
|
|
|
|
vd2d prevCameraPos=cameraPos; |
|
|
|
|
Test("Due to async actions, next cutscene action should be Pan Camera Async", |
|
|
|
|
CurrentAction==ActionType::PAN_CAMERA_ASYNC); |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test("Camera is moving towards {64,0}", |
|
|
|
|
prevCameraPos.x>cameraPos.x&&prevCameraPos.y>cameraPos.y); |
|
|
|
|
Test("Due to async actions, next cutscene action should be Dialog Box Async", |
|
|
|
@ -493,20 +502,20 @@ bool SeasonI::OnUserCreate(){ |
|
|
|
|
GetAnyKeyPress(H); |
|
|
|
|
Test("Pressing any key should close the message box", |
|
|
|
|
!messageBoxVisible); |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test("Next cutscene action should be Modify Object 0", |
|
|
|
|
CurrentAction==ActionType::MODIFY_OBJECT); |
|
|
|
|
Test("Cutscene Object 0 is now size {5,5}", |
|
|
|
|
CurrentCutscene->GetCutsceneObjects()[0]->GetScale().x==5&&CurrentCutscene->GetCutsceneObjects()[0]->GetScale().y==5); |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test("Next cutscene action should be Move Cutscene Object 1", |
|
|
|
|
CurrentAction==ActionType::MOVE_CUTSCENE_OBJ); |
|
|
|
|
prevCutsceneObjPosition=CurrentCutscene->GetCutsceneObjects()[1]->GetPos(); |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test("Cutscene Object 1 is moving towards position {320,64}", |
|
|
|
|
CurrentCutscene->GetCutsceneObjects()[1]->GetPos().x>prevCutsceneObjPosition.x&&CurrentCutscene->GetCutsceneObjects()[1]->GetPos().y==prevCutsceneObjPosition.y); |
|
|
|
|
TestWhile("Move Cutscene Object should finish",CurrentAction==ActionType::MOVE_CUTSCENE_OBJ) { |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
} |
|
|
|
|
Test("Cutscene Object 1 should be at position {320,64}", |
|
|
|
|
CurrentCutscene->GetCutsceneObjects()[1]->GetPos().x==320&&CurrentCutscene->GetCutsceneObjects()[1]->GetPos().y==64); |
|
|
|
@ -521,21 +530,21 @@ bool SeasonI::OnUserCreate(){ |
|
|
|
|
Test("Pressing a key should close the message box", |
|
|
|
|
!messageBoxVisible); |
|
|
|
|
int prevDestructionCount=OBJECT_DESTRUCTION_COUNT; |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test("Next cutscene action should be loading a map", |
|
|
|
|
CurrentAction==ActionType::LOAD_MAP); |
|
|
|
|
Test("Current Map should now be TWOSON", |
|
|
|
|
CURRENT_MAP==MAPS[MapName::TWOSON]); |
|
|
|
|
Test("All temporary objects should now be destroyed", |
|
|
|
|
OBJECT_DESTRUCTION_COUNT-3==prevDestructionCount); |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test("Next action should be moving player objects", |
|
|
|
|
CurrentAction==ActionType::MOVE_PLAYER_OBJS); |
|
|
|
|
Test("All player objects should now be at position {16,16}", |
|
|
|
|
PARTY_MEMBER_OBJ[0]->GetPos().x==16&&PARTY_MEMBER_OBJ[0]->GetPos().y==16); |
|
|
|
|
Test("Next cutscene action should be cleanup", |
|
|
|
|
CurrentCutscene->CurrentAction()==ActionType::CLEANUP); |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test("All cutscene and action variables should be cleaned up", |
|
|
|
|
CurrentCutscene==nullptr&& |
|
|
|
|
CurrentAction==ActionType::NONE); |
|
|
|
@ -544,16 +553,16 @@ bool SeasonI::OnUserCreate(){ |
|
|
|
|
PressTestKey(k.k); |
|
|
|
|
Test(k.keyName+" key is pressed", |
|
|
|
|
GetKeyPressed(*this,k)); |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test(k.keyName+" key is no longer pressed", |
|
|
|
|
!GetKeyPressed(*this,k)); |
|
|
|
|
Test(k.keyName+" key is held down", |
|
|
|
|
GetKeyHeld(*this,k)); |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test(k.keyName+" key is still held down", |
|
|
|
|
GetKeyHeld(*this,k)); |
|
|
|
|
for (int i=0;i<50;i++) { |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
} |
|
|
|
|
Test(k.keyName+" key is still held down after multiple updates", |
|
|
|
|
GetKeyHeld(*this,k)); |
|
|
|
@ -562,7 +571,7 @@ bool SeasonI::OnUserCreate(){ |
|
|
|
|
!GetKeyHeld(*this,k)); |
|
|
|
|
Test(k.keyName+" key is released", |
|
|
|
|
GetKeyReleased(*this,k)); |
|
|
|
|
updateGame(); |
|
|
|
|
OnUserUpdate(1/60.f); |
|
|
|
|
Test(k.keyName+" key is no longer released", |
|
|
|
|
!GetKeyReleased(*this,k)); |
|
|
|
|
} |
|
|
|
@ -596,12 +605,31 @@ bool SeasonI::OnUserCreate(){ |
|
|
|
|
keyUpdates(); |
|
|
|
|
} |
|
|
|
|
ResetTestKeys(); |
|
|
|
|
SetDrawTarget(nullptr); |
|
|
|
|
GetDrawTarget()->GetData()[0].a=4; |
|
|
|
|
} |
|
|
|
|
GAME_STATE=GameState::GAME_WORLD; |
|
|
|
|
Test("Player can move when there is no cutscene and the game is in a normal state", |
|
|
|
|
PlayerCanMove());
|
|
|
|
|
GAME_STATE=GameState::TEST_GAME; |
|
|
|
|
Test("Player cannot move during testing", |
|
|
|
|
!PlayerCanMove()); |
|
|
|
|
SetGameFlag(Flag::INTRO_COMPLETED,true); |
|
|
|
|
GAME_STATE=GameState::GAME_WORLD; |
|
|
|
|
vd2d prevPlayerPos = PARTY_MEMBER_OBJ[0]->GetPos(); |
|
|
|
|
CenterCameraOnPlayer(); |
|
|
|
|
PressTestKeyAndRun(RIGHT); |
|
|
|
|
Test("Player has moved to the right", |
|
|
|
|
PARTY_MEMBER_OBJ[0]->GetPos().x>prevPlayerPos.x&&PARTY_MEMBER_OBJ[0]->GetPos().y==prevPlayerPos.y); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool SeasonI::OnUserUpdate(float fElapsedTime) |
|
|
|
|
{ |
|
|
|
|
updateGame(); |
|
|
|
|
keyUpdates(); |
|
|
|
|
SetupGameDrawing(); |
|
|
|
|
drawGame(); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|