add drop test
This commit is contained in:
parent
69ddcb7595
commit
4b20487c58
@ -15,4 +15,5 @@ player.flight="key:f"
|
||||
player.attack="mouse:left"
|
||||
player.build="mouse:right"
|
||||
player.pick="mouse:middle"
|
||||
player.drop="key:q"
|
||||
hud.inventory="key:tab"
|
||||
|
||||
@ -36,7 +36,7 @@ vn 1.0000 0.0000 0.0000
|
||||
vn -0.0000 -0.0000 1.0000
|
||||
vn -1.0000 -0.0000 -0.0000
|
||||
vn 0.0000 0.0000 -1.0000
|
||||
usemtl blocks/stone
|
||||
usemtl blocks/leaves
|
||||
s off
|
||||
f 1/1/1 2/2/1 3/3/1 4/4/1
|
||||
f 5/5/2 8/6/2 7/7/2 6/8/2
|
||||
|
||||
@ -54,7 +54,7 @@ ModelBatch::~ModelBatch() {
|
||||
|
||||
void ModelBatch::draw(const model::Mesh& mesh, const glm::mat4& matrix, const glm::mat3& rotation) {
|
||||
glm::vec3 gpos = matrix * glm::vec4(glm::vec3(), 1.0f);
|
||||
light_t light = chunks->getLight(gpos.x, gpos.y, gpos.z);
|
||||
light_t light = chunks->getLight(floor(gpos.x), floor(gpos.y), floor(gpos.z));
|
||||
glm::vec4 lights (
|
||||
Lightmap::extract(light, 0) / 15.0f,
|
||||
Lightmap::extract(light, 1) / 15.0f,
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include "scripting/scripting.hpp"
|
||||
|
||||
#include "../objects/Player.hpp"
|
||||
#include "../objects/Entities.hpp"
|
||||
#include "../physics/PhysicsSolver.hpp"
|
||||
#include "../physics/Hitbox.hpp"
|
||||
#include "../lighting/Lighting.hpp"
|
||||
@ -246,6 +247,9 @@ void PlayerController::update(float delta, bool input, bool pause) {
|
||||
camControl.refresh();
|
||||
if (input) {
|
||||
updateInteraction();
|
||||
if (Events::jactive("player.drop")) {
|
||||
level->entities->drop(player->camera->position, player->camera->front*10.0f+player->hitbox->velocity);
|
||||
}
|
||||
} else {
|
||||
player->selection.vox.id = BLOCK_VOID;
|
||||
player->selection.vox.state.rotation = 0;
|
||||
|
||||
@ -18,14 +18,17 @@ void Transform::refresh() {
|
||||
}
|
||||
|
||||
Entities::Entities(Level* level) : level(level) {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
auto entity = registry.create();
|
||||
glm::vec3 pos(0.5f+rand()%50, 100+i, 0.5f+rand()%50);
|
||||
glm::vec3 size(1);
|
||||
registry.emplace<EntityId>(entity, 1);
|
||||
registry.emplace<Transform>(entity, pos, size/4.0f, glm::mat3(1.0f));
|
||||
registry.emplace<Hitbox>(entity, pos, size/2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void Entities::drop(glm::vec3 pos, glm::vec3 vel) {
|
||||
auto entity = registry.create();
|
||||
glm::vec3 size(1);
|
||||
registry.emplace<EntityId>(entity, 1);
|
||||
registry.emplace<Transform>(entity, pos, size/4.0f, glm::mat3(1.0f));
|
||||
registry.emplace<Hitbox>(entity, pos, size/2.0f);
|
||||
|
||||
auto& hitbox = registry.get<Hitbox>(entity);
|
||||
hitbox.velocity = vel;
|
||||
}
|
||||
|
||||
void Entities::updatePhysics(float delta){
|
||||
@ -41,6 +44,7 @@ void Entities::updatePhysics(float delta){
|
||||
1.0f,
|
||||
true
|
||||
);
|
||||
hitbox.linear_damping = hitbox.grounded * 5;
|
||||
transform.pos = hitbox.position;
|
||||
transform.rot = glm::rotate(glm::mat4(transform.rot), delta, glm::vec3(0, 1, 0));
|
||||
if (hitbox.grounded) {
|
||||
|
||||
@ -53,6 +53,8 @@ public:
|
||||
Entities(Level* level);
|
||||
void updatePhysics(float delta);
|
||||
void render(Assets* assets, ModelBatch& batch, Frustum& frustum);
|
||||
|
||||
void drop(glm::vec3 pos, glm::vec3 vel);
|
||||
};
|
||||
|
||||
#endif // OBJECTS_ENTITIES_HPP_
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user