mirror of
https://github.com/XProger/OpenLara.git
synced 2025-04-22 03:51:58 +02:00
add/remove second player; fix dozy reset
This commit is contained in:
parent
6969f5f904
commit
15f0a0d220
@ -166,8 +166,8 @@ namespace Game {
|
||||
}
|
||||
*/
|
||||
if (!level->level.isTitle()) {
|
||||
if (Input::state[0][cStart]) level->addPlayer(0);
|
||||
if (Input::state[1][cStart]) level->addPlayer(1);
|
||||
if (Input::lastState[0] == cStart) level->addPlayer(0);
|
||||
if (Input::lastState[1] == cStart) level->addPlayer(1);
|
||||
}
|
||||
|
||||
if (!level->level.isCutsceneLevel())
|
||||
|
11
src/input.h
11
src/input.h
@ -5,11 +5,13 @@
|
||||
#include "utils.h"
|
||||
|
||||
#define INPUT_JOY_COUNT 4
|
||||
#define MAX_PLAYERS COUNT(Core::settings.controls)
|
||||
|
||||
namespace Input {
|
||||
InputKey lastKey;
|
||||
bool down[ikMAX];
|
||||
bool state[2][cMAX];
|
||||
bool state[MAX_PLAYERS][cMAX];
|
||||
ControlKey lastState[MAX_PLAYERS];
|
||||
|
||||
struct Mouse {
|
||||
vec2 pos;
|
||||
@ -195,10 +197,15 @@ namespace Input {
|
||||
|
||||
void update() {
|
||||
for (int j = 0; j < COUNT(Core::settings.controls); j++) {
|
||||
lastState[j] = cMAX;
|
||||
|
||||
Core::Settings::Controls &ctrl = Core::settings.controls[j];
|
||||
for (int i = 0; i < cMAX; i++) {
|
||||
KeySet &c = ctrl.keys[i];
|
||||
state[j][i] = (c.key != ikNone && down[c.key]) || (c.joy != jkNone && joy[ctrl.joyIndex].down[c.joy]);
|
||||
bool active = (c.key != ikNone && down[c.key]) || (c.joy != jkNone && joy[ctrl.joyIndex].down[c.joy]);
|
||||
if (active && !state[j][i])
|
||||
lastState[j] = ControlKey(i);
|
||||
state[j][i] = active;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -960,16 +960,14 @@ struct Inventory {
|
||||
}
|
||||
|
||||
void update() {
|
||||
if (titleTimer > 1.0f && (
|
||||
Input::state[0][cInventory] || Input::state[0][cAction] ||
|
||||
Input::state[1][cInventory] || Input::state[1][cAction] ||
|
||||
Input::down[ikCtrl]))
|
||||
if (Input::lastState[0] == cInventory || Input::lastState[0] == cAction ||
|
||||
Input::lastState[1] == cInventory || Input::lastState[1] == cAction)
|
||||
{
|
||||
if (video) {
|
||||
if (video->time > 0.75f)
|
||||
skipVideo();
|
||||
} else if (titleTimer > 1.0f && titleTimer < 2.5f)
|
||||
skipVideo();
|
||||
} else if (titleTimer > 1.0f && titleTimer < 2.5f) {
|
||||
titleTimer = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (video) {
|
||||
@ -1018,9 +1016,9 @@ struct Inventory {
|
||||
Input::Joystick &joy = Input::joy[Core::settings.controls[playerIndex].joyIndex];
|
||||
|
||||
ControlKey key = cMAX;
|
||||
if (Input::down[ikCtrl] || Input::down[ikEnter] || Input::state[playerIndex][cAction] || joy.down[jkA])
|
||||
if (Input::down[ikCtrl] || Input::down[ikEnter] || Input::lastState[playerIndex] == cAction || joy.down[jkA])
|
||||
key = cAction;
|
||||
else if (Input::down[ikAlt] || joy.down[jkB] || Input::state[playerIndex][cInventory])
|
||||
else if (Input::down[ikAlt] || joy.down[jkB] || Input::lastState[playerIndex] == cInventory)
|
||||
key = cInventory;
|
||||
else if (Input::down[ikLeft] || joy.down[jkLeft] || joy.L.x < -0.5f)
|
||||
key = cLeft;
|
||||
|
@ -614,7 +614,8 @@ struct Lara : Character {
|
||||
visibleMask = 0xFFFFFFFF;
|
||||
health = LARA_MAX_HEALTH;
|
||||
oxygen = LARA_MAX_OXYGEN;
|
||||
|
||||
dozy = false;
|
||||
|
||||
keyHole = NULL;
|
||||
keyItem = NULL;
|
||||
|
||||
@ -2583,8 +2584,8 @@ struct Lara : Character {
|
||||
int pid = camera->cameraIndex;
|
||||
|
||||
if (!dozy && ((Input::state[pid][cAction] && Input::state[pid][cJump] && Input::state[pid][cLook] && Input::state[pid][cDash]) || Input::down[ikO])) {
|
||||
dozy = true;
|
||||
reset(getRoomIndex(), pos - vec3(0, 512, 0), angle.y, STAND_UNDERWATER);
|
||||
dozy = true;
|
||||
return input;
|
||||
}
|
||||
|
||||
|
10
src/level.h
10
src/level.h
@ -770,6 +770,11 @@ struct Level : IGame {
|
||||
players[index] = (Lara*)addEntity(TR::Entity::LARA, 0, vec3(0.0f), 0.0f);
|
||||
players[index]->camera->cameraIndex = index;
|
||||
Sound::listenersCount = 2;
|
||||
} else if (index == 1) {
|
||||
removeEntity(players[index]);
|
||||
players[index] = NULL;
|
||||
Sound::listenersCount = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
Lara *lead = players[index ^ 1];
|
||||
@ -783,7 +788,6 @@ struct Level : IGame {
|
||||
c = next;
|
||||
}
|
||||
|
||||
players[index]->dozy = false;
|
||||
players[index]->reset(lead->getRoomIndex(), lead->pos, lead->angle.y, lead->stand);
|
||||
}
|
||||
|
||||
@ -1535,8 +1539,8 @@ struct Level : IGame {
|
||||
}
|
||||
}
|
||||
|
||||
if ((Input::state[0][cInventory] || Input::state[1][cInventory]) && !level.isTitle() && inventory->titleTimer < 1.0f && !inventory->active && inventory->lastKey == cMAX) {
|
||||
int playerIndex = Input::state[0][cInventory] ? 0 : 1;
|
||||
if ((Input::lastState[0] == cInventory || Input::lastState[1] == cInventory) && !level.isTitle() && inventory->titleTimer < 1.0f && !inventory->active) {
|
||||
int playerIndex = (Input::lastState[0] == cInventory) ? 0 : 1;
|
||||
|
||||
if (level.isCutsceneLevel()) {
|
||||
loadNextLevel();
|
||||
|
Loading…
x
Reference in New Issue
Block a user