forked from mirrors/kolyah35-minecraft-pe-0.6.1
the whole game
This commit is contained in:
parent
816e9060b4
commit
f0617a5d22
2069 changed files with 581500 additions and 0 deletions
43
src/client/player/input/MouseTurnInput.h
Executable file
43
src/client/player/input/MouseTurnInput.h
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef NET_MINECRAFT_CLIENT_PLAYER_INPUT_MouseTurnInput_H__
|
||||
#define NET_MINECRAFT_CLIENT_PLAYER_INPUT_MouseTurnInput_H__
|
||||
|
||||
#include "ITurnInput.h"
|
||||
#include "../../../platform/input/Mouse.h"
|
||||
|
||||
/** A Mouse Turn input */
|
||||
class MouseTurnInput : public ITurnInput {
|
||||
public:
|
||||
static const int MODE_OFFSET = 1;
|
||||
static const int MODE_DELTA = 2;
|
||||
|
||||
MouseTurnInput(int mode_, int centerX, int centerY)
|
||||
: mode(mode_),
|
||||
_centerX((float)centerX),
|
||||
_centerY((float)centerY)
|
||||
{}
|
||||
|
||||
void onConfigChanged(const Config& config) {
|
||||
_centerX = ((float) config.width ) * 0.5f;
|
||||
_centerY = ((float) config.height) * 0.5f;
|
||||
}
|
||||
|
||||
TurnDelta getTurnDelta() {
|
||||
float dx = 0, dy = 0;
|
||||
if ( MODE_DELTA == mode ) {
|
||||
dx = (float)Mouse::getDX();
|
||||
dy = (float)Mouse::getDY();
|
||||
} else if (MODE_OFFSET == mode) {
|
||||
float dt = getDeltaTime();
|
||||
dx = linearTransform( (float)Mouse::getX() - _centerX, 40, 0.4f ) * dt;
|
||||
dy = linearTransform( (float)Mouse::getY() - _centerY, 30, 0.6f ) * dt;
|
||||
}
|
||||
return TurnDelta(dx, dy);
|
||||
}
|
||||
|
||||
int mode;
|
||||
private:
|
||||
float _centerX;
|
||||
float _centerY;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_PLAYER_INPUT_MouseTurnInput_H__*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue