Wired instrument selection into game
This commit is contained in:
parent
d435980ac6
commit
02c775545d
@ -9,6 +9,7 @@
|
||||
#endif
|
||||
|
||||
int INSTRUMENT_GAMEPAD_INDEX[MAX_INSTRUMENT_TYPES] = {-1, -1, -1, -1};
|
||||
int INSTRUMENT_PHYSICAL_GAMEPAD[MAX_INSTRUMENT_TYPES] = {-1, -1, -1, -1};
|
||||
|
||||
Game game;
|
||||
|
||||
|
||||
@ -159,6 +159,7 @@ const char* const GHHB_CHART_PATH = "assets/songs/json/mary.json";
|
||||
} // namespace
|
||||
|
||||
extern int INSTRUMENT_GAMEPAD_INDEX[MAX_INSTRUMENT_TYPES];
|
||||
extern int INSTRUMENT_PHYSICAL_GAMEPAD[MAX_INSTRUMENT_TYPES];
|
||||
|
||||
class GHHBScene : public Scene
|
||||
{
|
||||
@ -295,6 +296,22 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool lane_pressed_by_instrument_owner(int lane, int instrument_slot) const
|
||||
{
|
||||
int physical_id = INSTRUMENT_PHYSICAL_GAMEPAD[instrument_slot];
|
||||
if (physical_id < 0)
|
||||
{
|
||||
for (int i = 0; i < MAX_GAMEPADS; i++)
|
||||
{
|
||||
if (IsGamepadAvailable(i) && IsGamepadButtonPressed(i, GAMEPAD_BUTTONS[lane]))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return IsGamepadAvailable(physical_id) &&
|
||||
IsGamepadButtonPressed(physical_id, GAMEPAD_BUTTONS[lane]);
|
||||
}
|
||||
|
||||
bool is_menu_pressed() const
|
||||
{
|
||||
if (IsKeyPressed(KEY_ENTER))
|
||||
@ -461,10 +478,13 @@ public:
|
||||
}
|
||||
}
|
||||
if (best != nullptr)
|
||||
{
|
||||
if (lane_pressed_by_instrument_owner(lane, best->instrument_slot))
|
||||
{
|
||||
consume_note(best);
|
||||
}
|
||||
else
|
||||
}
|
||||
else if (is_lane_pressed(lane))
|
||||
{
|
||||
combo = 0;
|
||||
score = std::max(0, score - 25);
|
||||
|
||||
@ -98,7 +98,10 @@ public:
|
||||
if (IsKeyPressed(KEY_ENTER))
|
||||
{
|
||||
for (int i = 0; i < MAX_INSTRUMENT_TYPES; i++)
|
||||
{
|
||||
INSTRUMENT_GAMEPAD_INDEX[i] = instrument_owner[i];
|
||||
INSTRUMENT_PHYSICAL_GAMEPAD[i] = participant_order[instrument_owner[i]];
|
||||
}
|
||||
game->go_to_scene("ghhb");
|
||||
return;
|
||||
}
|
||||
@ -107,7 +110,10 @@ public:
|
||||
if (IsGamepadAvailable(gp) && IsGamepadButtonPressed(gp, GAMEPAD_BUTTON_MIDDLE_RIGHT))
|
||||
{
|
||||
for (int i = 0; i < MAX_INSTRUMENT_TYPES; i++)
|
||||
{
|
||||
INSTRUMENT_GAMEPAD_INDEX[i] = instrument_owner[i];
|
||||
INSTRUMENT_PHYSICAL_GAMEPAD[i] = participant_order[instrument_owner[i]];
|
||||
}
|
||||
game->go_to_scene("ghhb");
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user