Added directional connection points and gamepad/keyboard navigation to overworld map. Set 1_4 to not be an infinite map.
This commit is contained in:
@@ -141,11 +141,25 @@ void State_OverworldMap::OnUserUpdate(AiL*game){
|
||||
|
||||
#pragma region Handle Connection Point Clicking and Movement
|
||||
for(ConnectionPoint&cp:connections){
|
||||
if(game->GetMouse(Mouse::LEFT).bPressed&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect)){
|
||||
for(int neighborInd:currentConnectionPoint->neighbors){
|
||||
if(neighborInd==-1)continue;
|
||||
if(game->GetMouse(Mouse::LEFT).bPressed&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect)
|
||||
||game->KEY_LEFT.Pressed()||game->KEY_RIGHT.Pressed()||game->KEY_UP.Pressed()||game->KEY_DOWN.Pressed()){
|
||||
bool mouseUsed=game->GetMouse(Mouse::LEFT).bPressed&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect);
|
||||
for(int directionInd=0;int neighborInd:currentConnectionPoint->neighbors){
|
||||
int targetDirection=-1;
|
||||
|
||||
if(game->KEY_LEFT.Pressed())targetDirection=ConnectionPoint::WEST;
|
||||
if(game->KEY_RIGHT.Pressed())targetDirection=ConnectionPoint::EAST;
|
||||
if(game->KEY_UP.Pressed())targetDirection=ConnectionPoint::NORTH;
|
||||
if(game->KEY_DOWN.Pressed())targetDirection=ConnectionPoint::SOUTH;
|
||||
|
||||
if(neighborInd==-1){
|
||||
directionInd++;
|
||||
continue;
|
||||
}
|
||||
|
||||
ConnectionPoint&neighbor=ConnectionPointFromIndex(neighborInd);
|
||||
if(Unlock::IsUnlocked(neighbor.unlockCondition)&&&cp==&neighbor){
|
||||
if(Unlock::IsUnlocked(neighbor.unlockCondition)&&&cp==&neighbor
|
||||
&&(mouseUsed||targetDirection==directionInd)){
|
||||
UpdateCurrentConnectionPoint(neighbor);
|
||||
playerTargetPos=currentConnectionPoint->rect.pos+currentConnectionPoint->rect.size/2+vf2d{0,16};
|
||||
float angleTo=util::angleTo(game->GetPlayer()->GetPos(),playerTargetPos);
|
||||
@@ -160,12 +174,15 @@ void State_OverworldMap::OnUserUpdate(AiL*game){
|
||||
}else{
|
||||
game->GetPlayer()->UpdateWalkingAnimation(LEFT);
|
||||
}
|
||||
break;
|
||||
goto doneNavigating;
|
||||
}
|
||||
directionInd++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
doneNavigating:
|
||||
int a;
|
||||
};
|
||||
void State_OverworldMap::Draw(AiL*game){
|
||||
currentTime+=game->GetElapsedTime();
|
||||
|
||||
Reference in New Issue
Block a user