|
|
|
@ -49,6 +49,7 @@ class DamageNumber{ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
int frameCount=0; |
|
|
|
|
int partyTrailStepCount=0; |
|
|
|
|
float elapsedTime=0; |
|
|
|
|
const float TARGET_RATE = 1/60.0; |
|
|
|
|
int MAP_WIDTH=-1; |
|
|
|
@ -428,13 +429,13 @@ void SeasonI::SetupAnimations() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SeasonI::SetupObjectInfo() { |
|
|
|
|
CreateObjectInfo(new NPC_Obj(PLAYER,"player",{0,0},nullptr,{2,2},WHITE,32),"player.png",{32,32}); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(NESS,"Ness",{0,0},nullptr,{1,1},YELLOW,32),"player.png",{32,32}); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(PAULA,"Paula",{0,0},nullptr,{1,1},MAGENTA,32),"player.png",{32,32}); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(JEFF,"Jeff",{0,0},nullptr,{1,1},DARK_GREEN,32),"player.png",{32,32}); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(ANNA,"Anna",{0,0},nullptr,{1,1},DARK_MAGENTA,32),"player.png",{32,32}); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(KING,"King",{0,0},nullptr,{1,1},GREY,32),"player.png",{32,32}); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(POO,"Poo",{0,0},nullptr,{1,1},DARK_GREY,32),"player.png",{32,32}); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(PLAYER,"player",{0,0},nullptr,{2,2},WHITE,16),"player.png",{32,32}); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(NESS,"Ness",{0,0},nullptr,{1,1},YELLOW,14),"player.png",{32,32}); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(PAULA,"Paula",{0,0},nullptr,{1,1},MAGENTA,13),"player.png",{32,32}); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(JEFF,"Jeff",{0,0},nullptr,{1,1},DARK_GREEN,15),"player.png",{32,32}); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(ANNA,"Anna",{0,0},nullptr,{1,1},DARK_MAGENTA,12),"player.png",{32,32}); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(KING,"King",{0,0},nullptr,{1,1},GREY,10),"player.png",{32,32}); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(POO,"Poo",{0,0},nullptr,{1,1},DARK_GREY,17),"player.png",{32,32}); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(NPC1,"npc1",{0,0},nullptr,{1,1},RED,60),"player.png",{32,32},Flag::NONE,Flag::NONE); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(NPC2,"npc2",{0,0},nullptr,{1,1},GREEN,2),"player.png",{32,32},Flag::NONE,Flag::NONE); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(NPC3,"npc3",{0,0},nullptr,{2,2},BLUE,20),"player.png",{32,32},Flag::NONE,Flag::NONE); |
|
|
|
@ -444,7 +445,7 @@ void SeasonI::SetupObjectInfo() { |
|
|
|
|
CreateObjectInfo(new NPC_Obj(NPC7,"npc7",{0,0},nullptr,{2,2},BLUE,20),"player.png",{32,32},Flag::NONE,Flag::NONE); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(NPC8,"npc8",{0,0},nullptr,{2,2},BLUE,20),"player.png",{32,32},Flag::NONE,Flag::NONE); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(NPC9,"npc9",{0,0},nullptr,{2,2},BLUE,20),"player.png",{32,32},Flag::NONE,Flag::NONE); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(NPC10,"npc10",{0,0},nullptr,{2,2},BLUE,20),"player.png",{32,32},Flag::NONE,Flag::NONE); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(NPC10,"npc10",{0,0},nullptr,{2,2},CYAN,20,false,{moveTime:180,moveFreq:60,moveSpd:1}),"player.png",{32,32},Flag::NONE,Flag::NONE); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(NPC11,"npc11",{0,0},nullptr,{2,2},BLUE,20),"player.png",{32,32},Flag::NONE,Flag::NONE); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(NPC12,"npc12",{0,0},nullptr,{2,2},BLUE,20),"player.png",{32,32},Flag::NONE,Flag::NONE); |
|
|
|
|
CreateObjectInfo(new NPC_Obj(NPC13,"npc13",{0,0},nullptr,{2,2},BLUE,20),"player.png",{32,32},Flag::NONE,Flag::NONE); |
|
|
|
@ -1071,7 +1072,7 @@ bool SeasonI::GetGameFlag(Flag flag) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Object*SeasonI::CreateObject(int id,vd2d pos) { |
|
|
|
|
return OBJ_INFO[id]->CreateType(id,OBJ_INFO[id]->name,pos,OBJ_INFO[id]->spr,OBJ_INFO[id]->GetScale(),OBJ_INFO[id]->color,OBJ_INFO[id]->animationSpd); |
|
|
|
|
return OBJ_INFO[id]->CreateType(id,OBJ_INFO[id]->name,pos,OBJ_INFO[id]->spr,OBJ_INFO[id]->GetScale(),OBJ_INFO[id]->color,OBJ_INFO[id]->animationSpd,OBJ_INFO[id]->temp,OBJ_INFO[id]->extraData); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Object*SeasonI::AddObjectToWorld(Object*obj) { |
|
|
|
@ -1189,10 +1190,13 @@ bool SeasonI::OnUserUpdate(float fElapsedTime) |
|
|
|
|
void SeasonI::updateGame(){ |
|
|
|
|
frameCount++; |
|
|
|
|
for (auto obj:OBJECTS) { |
|
|
|
|
if (obj->animationSpd!=0&&obj->frameCount++>obj->animationSpd) { |
|
|
|
|
if (obj->animated&&obj->animationSpd!=0&&obj->frameCount++>obj->animationSpd) { |
|
|
|
|
obj->frameCount=0; |
|
|
|
|
obj->frameIndex++; |
|
|
|
|
} |
|
|
|
|
if (NPCCanMove()) { |
|
|
|
|
obj->Update(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!messageBoxVisible&&INTERACTION_MESSAGES.size()>0) { |
|
|
|
@ -1270,7 +1274,7 @@ void SeasonI::updateGame(){ |
|
|
|
|
if (PlayerCanMove()) { |
|
|
|
|
bool moved=false; |
|
|
|
|
vd2d movementComponents = {0,0}; |
|
|
|
|
Direction facingDir=Direction::SOUTH; |
|
|
|
|
Direction facingDir=(Direction)PARTY_MEMBER_OBJ[0]->animationSubIndex; |
|
|
|
|
if (UpHeld()) { |
|
|
|
|
movementComponents.y-=1; |
|
|
|
|
facingDir=Direction::NORTH; |
|
|
|
@ -1313,7 +1317,7 @@ void SeasonI::updateGame(){ |
|
|
|
|
} |
|
|
|
|
PARTY_MEMBER_OBJ[0]->animationSubIndex=(int)facingDir; |
|
|
|
|
if (movementComponents.mag()>0) { |
|
|
|
|
PARTY_MEMBER_OBJ[0]->frameIndex+=frameCount%PARTY_MEMBER_OBJ[0]->originalAnimationSpd==0; |
|
|
|
|
PARTY_MEMBER_OBJ[0]->frameIndex+=frameCount%PARTY_MEMBER_OBJ[0]->animationSpd==0; |
|
|
|
|
if (PARTY_MEMBER_OBJ[0]->SmoothMove(movementComponents)) { |
|
|
|
|
UpdatePlayerTrail(movementComponents,facingDir); |
|
|
|
|
for (int i=0;i<CURRENT_MAP->triggers.size();i++) { |
|
|
|
@ -1920,6 +1924,11 @@ void SeasonI::keyUpdates() { |
|
|
|
|
case GameState::GAME_WORLD:{ |
|
|
|
|
if (GetKey(F5).bPressed) { |
|
|
|
|
GAME_STATE=GameState::EDITOR; |
|
|
|
|
for (int i=0;i<OBJECTS.size();i++) { |
|
|
|
|
if (!OBJECTS[i]->enc) { |
|
|
|
|
OBJECTS[i]->SetPos(OBJECTS[i]->GetStartPos()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else |
|
|
|
|
if (PlayerCanMove()&&ACTIONKEYPRESSED) { |
|
|
|
|
GAME_STATE=GameState::OVERWORLD_MENU; |
|
|
|
@ -3931,16 +3940,21 @@ bool SeasonI::PlayerCanMove(){ |
|
|
|
|
return GAME_STATE==GameState::GAME_WORLD&&BATTLE_ENCOUNTER==nullptr&&!IsTextEntryEnabled()&&!messageBoxVisible&&PARTY_MEMBER_OBJ[0]!=nullptr&&CurrentCutscene==nullptr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool SeasonI::NPCCanMove(){ |
|
|
|
|
return GAME_STATE==GameState::GAME_WORLD&&BATTLE_ENCOUNTER==nullptr&&!IsTextEntryEnabled()&&!messageBoxVisible; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SeasonI::UpdatePlayerTrail(vd2d newMovement,Direction newFacingDir) { |
|
|
|
|
for (int i=PARTY_TRAIL_LENGTH-1;i>0;i--) { |
|
|
|
|
partyTrail[i]=partyTrail[i-1]; |
|
|
|
|
} |
|
|
|
|
partyTrailStepCount++; |
|
|
|
|
partyTrail[0]={{PARTY_MEMBER_OBJ[0]->GetPos().x-newMovement.x+PARTY_MEMBER_OBJ[0]->spr->sprSize.x*0.5*(PARTY_MEMBER_OBJ[0]->GetScale().x-1), |
|
|
|
|
PARTY_MEMBER_OBJ[0]->GetPos().y-newMovement.y+(PARTY_MEMBER_OBJ[0]->spr->sprSize.y-4)*(PARTY_MEMBER_OBJ[0]->GetScale().y-1)},newFacingDir}; |
|
|
|
|
for (int i=1;i<PARTY_MEMBER_COUNT;i++) { |
|
|
|
|
PARTY_MEMBER_OBJ[i]->SetPos(partyTrail[PARTY_TRAIL_LENGTH*((double)i/4)].first); |
|
|
|
|
PARTY_MEMBER_OBJ[i]->animationSubIndex=(int)partyTrail[PARTY_TRAIL_LENGTH*((double)i/4)].second; |
|
|
|
|
PARTY_MEMBER_OBJ[i]->frameIndex+=(int)(PARTY_TRAIL_LENGTH*((double)i/4))%PARTY_MEMBER_OBJ[i]->originalAnimationSpd==0; |
|
|
|
|
PARTY_MEMBER_OBJ[i]->frameIndex+=partyTrailStepCount%PARTY_MEMBER_OBJ[i]->animationSpd==0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|