Test holding down key functionality implemented

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 62b26a740d
commit 3073b1b85a
  1. BIN
      C++ProjectTemplate
  2. 3
      main.cpp
  3. 1
      states.h
  4. 34
      test/test.cpp

Binary file not shown.

@ -5609,6 +5609,9 @@ char SeasonI::GetTileDegreeSafely(std::vector<std::vector<TILE*>>&data){
void SeasonI::PressTestKey(Key k) {
TESTKEYS[k].bPressed=TESTKEYS[k].bHeld=true;
TESTKEYS[k].bReleased=false;
KEY_LASTPRESSED=k;
lastPress=frameCount;
lastRepeatedFrame=frameCount;
}
void SeasonI::ReleaseTestKey(Key k) {

@ -25,6 +25,7 @@ namespace GameState{
MAP_POSITION_SELECT,
FILE_LOAD_SELECT,
DISPLAY_CUTSCENE_TEXT,
TEST_GAME,
};
}

@ -195,6 +195,9 @@ void TestSpriteInitialized(std::vector<std::string> sprList) {
}
bool SeasonI::OnUserCreate(){
GAME_STATE=GameState::TEST_GAME;
Test("We start in the TEST_GAME state",
GAME_STATE==GameState::TEST_GAME);
for (int i=0;i<PARTY_MEMBER_STATS.size();i++) {
Test("Party Member stats should not be initialized",
PARTY_MEMBER_STATS[i]==nullptr);
@ -563,6 +566,37 @@ bool SeasonI::OnUserCreate(){
Test(k.keyName+" key is no longer released",
!GetKeyReleased(*this,k));
}
Test("We are still in the TEST_GAME state",
GAME_STATE==GameState::TEST_GAME);
TestKey testRepeatKeys[] = {key::UP,key::DOWN,key::LEFT,key::RIGHT};
for (TestKey k : testRepeatKeys) {
frameCount=0;
PressTestKey(k.k);
for (int i=0;i<23;i++) {
updateGame();
Test(k.keyName+" key is not considered pressed",
!GetKeyPressed(*this,k));
keyUpdates();
}
int attemptCount=1;
updateGame();
Test(k.keyName+" key is considered pressed again (Attempt "+std::to_string(attemptCount++)+")",
GetKeyPressed(*this,k));
keyUpdates();
for (int j=0;j<2;j++) {
for (int i=0;i<3;i++) {
updateGame();
Test(k.keyName+" key is not considered pressed",
!GetKeyPressed(*this,k));
keyUpdates();
}
updateGame();
Test(k.keyName+" key is considered pressed again (Attempt "+std::to_string(attemptCount++)+")",
GetKeyPressed(*this,k));
keyUpdates();
}
ResetTestKeys();
}
return true;
}

Loading…
Cancel
Save