Added bindings for mouse clicks, fixed lights
This commit is contained in:
@@ -22,7 +22,7 @@ void main(){
|
|||||||
vec2 pos2d = (u_model * vec4(v_position, 1.0)).xz-u_cameraPos.xz;
|
vec2 pos2d = (u_model * vec4(v_position, 1.0)).xz-u_cameraPos.xz;
|
||||||
vec4 modelpos = u_model * vec4(v_position+vec3(0,pow(length(pos2d)*0.0, 3.0),0), 1.0);
|
vec4 modelpos = u_model * vec4(v_position+vec3(0,pow(length(pos2d)*0.0, 3.0),0), 1.0);
|
||||||
vec4 viewmodelpos = u_view * modelpos;
|
vec4 viewmodelpos = u_view * modelpos;
|
||||||
vec3 light = v_light.rgb * 1.6;
|
vec3 light = v_light.rgb;
|
||||||
float torchlight = max(0.0, 1.0-distance(u_cameraPos, modelpos.xyz)/u_torchlightDistance);
|
float torchlight = max(0.0, 1.0-distance(u_cameraPos, modelpos.xyz)/u_torchlightDistance);
|
||||||
light += torchlight * u_torchlightColor;
|
light += torchlight * u_torchlightColor;
|
||||||
a_color = vec4(pow(light, vec3(u_gamma)),1.0f);
|
a_color = vec4(pow(light, vec3(u_gamma)),1.0f);
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
#define BIND_CAM_ZOOM "camera.zoom"
|
#define BIND_CAM_ZOOM "camera.zoom"
|
||||||
#define BIND_PLAYER_NOCLIP "player.noclip"
|
#define BIND_PLAYER_NOCLIP "player.noclip"
|
||||||
#define BIND_PLAYER_FLIGHT "player.flight"
|
#define BIND_PLAYER_FLIGHT "player.flight"
|
||||||
|
#define BIND_PLAYER_ATTACK "player.attack"
|
||||||
|
#define BIND_PLAYER_BUILD "player.build"
|
||||||
|
#define BIND_PLAYER_PICK "player.pick"
|
||||||
#define BIND_HUD_INVENTORY "hud.inventory"
|
#define BIND_HUD_INVENTORY "hud.inventory"
|
||||||
|
|
||||||
#endif // SRC_CORE_DEFS_H_
|
#endif // SRC_CORE_DEFS_H_
|
||||||
@@ -103,5 +103,8 @@ void setup_bindings() {
|
|||||||
Events::bind(BIND_CAM_ZOOM, inputtype::keyboard, keycode::C);
|
Events::bind(BIND_CAM_ZOOM, inputtype::keyboard, keycode::C);
|
||||||
Events::bind(BIND_PLAYER_NOCLIP, inputtype::keyboard, keycode::N);
|
Events::bind(BIND_PLAYER_NOCLIP, inputtype::keyboard, keycode::N);
|
||||||
Events::bind(BIND_PLAYER_FLIGHT, inputtype::keyboard, keycode::F);
|
Events::bind(BIND_PLAYER_FLIGHT, inputtype::keyboard, keycode::F);
|
||||||
|
Events::bind(BIND_PLAYER_ATTACK, inputtype::mouse, mousecode::BUTTON_1);
|
||||||
|
Events::bind(BIND_PLAYER_BUILD, inputtype::mouse, mousecode::BUTTON_2);
|
||||||
|
Events::bind(BIND_PLAYER_PICK, inputtype::mouse, mousecode::BUTTON_3);
|
||||||
Events::bind(BIND_HUD_INVENTORY, inputtype::keyboard, keycode::TAB);
|
Events::bind(BIND_HUD_INVENTORY, inputtype::keyboard, keycode::TAB);
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ Panel* create_controls_panel(Engine* engine, PagesControl* menu) {
|
|||||||
for (auto& entry : Events::bindings){
|
for (auto& entry : Events::bindings){
|
||||||
string bindname = entry.first;
|
string bindname = entry.first;
|
||||||
|
|
||||||
Panel* subpanel = new Panel(vec2(400, 45), vec4(5.0f), 1.0f);
|
Panel* subpanel = new Panel(vec2(400, 40), vec4(5.0f), 1.0f);
|
||||||
subpanel->color(vec4(0.0f));
|
subpanel->color(vec4(0.0f));
|
||||||
subpanel->orientation(Orientation::horizontal);
|
subpanel->orientation(Orientation::horizontal);
|
||||||
|
|
||||||
|
|||||||
@@ -221,10 +221,10 @@ void PlayerController::updateInteraction(){
|
|||||||
vec3 norm;
|
vec3 norm;
|
||||||
|
|
||||||
bool xkey = Events::pressed(keycode::X);
|
bool xkey = Events::pressed(keycode::X);
|
||||||
bool lclick = Events::jclicked(mousecode::BUTTON_1) ||
|
bool lclick = Events::jactive(BIND_PLAYER_ATTACK) ||
|
||||||
(xkey && Events::clicked(mousecode::BUTTON_1));
|
(xkey && Events::active(BIND_PLAYER_ATTACK));
|
||||||
bool rclick = Events::jclicked(mousecode::BUTTON_2) ||
|
bool rclick = Events::jactive(BIND_PLAYER_BUILD) ||
|
||||||
(xkey && Events::clicked(mousecode::BUTTON_2));
|
(xkey && Events::active(BIND_PLAYER_BUILD));
|
||||||
float maxDistance = 10.0f;
|
float maxDistance = 10.0f;
|
||||||
if (xkey) {
|
if (xkey) {
|
||||||
maxDistance *= 20.0f;
|
maxDistance *= 20.0f;
|
||||||
@@ -270,7 +270,7 @@ void PlayerController::updateInteraction(){
|
|||||||
lighting->onBlockSet(x,y,z, player->choosenBlock);
|
lighting->onBlockSet(x,y,z, player->choosenBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Events::jclicked(mousecode::BUTTON_3)){
|
if (Events::jactive(BIND_PLAYER_PICK)){
|
||||||
player->choosenBlock = chunks->get(x,y,z)->id;
|
player->choosenBlock = chunks->get(x,y,z)->id;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user