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