Minor refactor
This commit is contained in:
parent
7ab69ebc1e
commit
41f9c51a27
21
src/core_defs.h
Normal file
21
src/core_defs.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef SRC_CORE_DEFS_H_
|
||||
#define SRC_CORE_DEFS_H_
|
||||
|
||||
/* blocks and bindings used in engine code */
|
||||
|
||||
#define BLOCK_AIR 0
|
||||
|
||||
#define BIND_MOVE_FORWARD "movement.forward"
|
||||
#define BIND_MOVE_BACK "movement.back"
|
||||
#define BIND_MOVE_LEFT "movement.left"
|
||||
#define BIND_MOVE_RIGHT "movement.right"
|
||||
#define BIND_MOVE_JUMP "movement.jump"
|
||||
#define BIND_MOVE_SPRINT "movement.sprint"
|
||||
#define BIND_MOVE_CROUCH "movement.crouch"
|
||||
#define BIND_MOVE_CHEAT "movement.cheat"
|
||||
#define BIND_CAM_ZOOM "camera.zoom"
|
||||
#define BIND_PLAYER_NOCLIP "player.noclip"
|
||||
#define BIND_PLAYER_FLIGHT "player.flight"
|
||||
#define BIND_HUD_INVENTORY "hud.inventory"
|
||||
|
||||
#endif // SRC_CORE_DEFS_H_
|
||||
@ -2,8 +2,8 @@
|
||||
#define DECLARATIONS_H
|
||||
|
||||
#include <iostream>
|
||||
#include "core_defs.h"
|
||||
|
||||
#define BLOCK_AIR 0
|
||||
#define BLOCK_DIRT 1
|
||||
#define BLOCK_GRASS_BLOCK 2
|
||||
#define BLOCK_LAMP 3
|
||||
@ -21,19 +21,6 @@
|
||||
#define BLOCK_METAL 15
|
||||
#define BLOCK_RUST 16
|
||||
|
||||
#define BIND_MOVE_FORWARD "movement.forward"
|
||||
#define BIND_MOVE_BACK "movement.back"
|
||||
#define BIND_MOVE_LEFT "movement.left"
|
||||
#define BIND_MOVE_RIGHT "movement.right"
|
||||
#define BIND_MOVE_JUMP "movement.jump"
|
||||
#define BIND_MOVE_SPRINT "movement.sprint"
|
||||
#define BIND_MOVE_CROUCH "movement.crouch"
|
||||
#define BIND_MOVE_CHEAT "movement.cheat"
|
||||
#define BIND_CAM_ZOOM "camera.zoom"
|
||||
#define BIND_PLAYER_NOCLIP "player.noclip"
|
||||
#define BIND_PLAYER_FLIGHT "player.flight"
|
||||
#define BIND_HUD_INVENTORY "hud.inventory"
|
||||
|
||||
extern void setup_bindings();
|
||||
extern void setup_definitions();
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
#include "gui/GUI.h"
|
||||
#include "screens.h"
|
||||
#include "../engine.h"
|
||||
#include "../core_defs.h"
|
||||
|
||||
using std::wstring;
|
||||
using std::shared_ptr;
|
||||
@ -309,7 +310,7 @@ void HudRenderer::draw(const GfxContext& ctx){
|
||||
pauseMenu->visible(true);
|
||||
}
|
||||
}
|
||||
if (Events::jactive("hud.inventory")) {
|
||||
if (Events::jactive(BIND_HUD_INVENTORY)) {
|
||||
if (!pause) {
|
||||
inventoryOpen = !inventoryOpen;
|
||||
}
|
||||
|
||||
@ -12,6 +12,8 @@
|
||||
#include "../window/Events.h"
|
||||
#include "../window/input.h"
|
||||
|
||||
#include "../core_defs.h"
|
||||
|
||||
#define CROUCH_SPEED_MUL 0.25f
|
||||
#define CROUCH_SHIFT_Y -0.2f
|
||||
#define RUN_SPEED_MUL 1.5f
|
||||
@ -38,18 +40,18 @@ void PlayerController::refreshCamera() {
|
||||
}
|
||||
|
||||
void PlayerController::updateKeyboard() {
|
||||
input.moveForward = Events::active("movement.forward");
|
||||
input.moveBack = Events::active("movement.back");
|
||||
input.moveLeft = Events::active("movement.left");
|
||||
input.moveRight = Events::active("movement.right");
|
||||
input.sprint = Events::active("movement.sprint");
|
||||
input.shift = Events::active("movement.crouch");
|
||||
input.cheat = Events::active("movement.cheat");
|
||||
input.jump = Events::active("movement.jump");
|
||||
input.zoom = Events::active("camera.zoom");
|
||||
input.moveForward = Events::active(BIND_MOVE_FORWARD);
|
||||
input.moveBack = Events::active(BIND_MOVE_BACK);
|
||||
input.moveLeft = Events::active(BIND_MOVE_LEFT);
|
||||
input.moveRight = Events::active(BIND_MOVE_RIGHT);
|
||||
input.sprint = Events::active(BIND_MOVE_SPRINT);
|
||||
input.shift = Events::active(BIND_MOVE_CROUCH);
|
||||
input.cheat = Events::active(BIND_MOVE_CHEAT);
|
||||
input.jump = Events::active(BIND_MOVE_JUMP);
|
||||
input.zoom = Events::active(BIND_CAM_ZOOM);
|
||||
|
||||
input.noclip = Events::jactive("player.noclip");
|
||||
input.flight = Events::jactive("player.flight");
|
||||
input.noclip = Events::jactive(BIND_PLAYER_NOCLIP);
|
||||
input.flight = Events::jactive(BIND_PLAYER_FLIGHT);
|
||||
|
||||
// block choice
|
||||
for (int i = 1; i < 10; i++){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user