aboutsummaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2011-09-08 14:21:56 +0200
committerKahrl <kahrl@gmx.net>2011-09-08 14:21:56 +0200
commit71418639d3e81a0c4f03633042f9c3472572a87e (patch)
tree95f4150ce9a45cb40c2a31807c6478da641968bf /src/game.cpp
parentf2ec2265216f4621558003dcbd8974f76063576b (diff)
parentf31b0a3361c0c39b9f6f6ee440b93293690bbe02 (diff)
downloadhax-minetest-server-71418639d3e81a0c4f03633042f9c3472572a87e.tar.gz
hax-minetest-server-71418639d3e81a0c4f03633042f9c3472572a87e.zip
attempting to merge Queatz/the-wielded-tool and kahrl/viewbobbing, something doesn't work right yet
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 24f356e46..af4886137 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -828,6 +828,44 @@ void the_game(
f32 camera_pitch = 0; // "up/down"
/*
+ Tool
+ */
+
+ v3f tool_wield_position(0.06*BS, 1.619*BS, 0.1*BS);
+ v3f tool_wield_rotation(-25, 180, -25);
+ float tool_wield_animation = 0.0;
+ scene::IMeshSceneNode *tool_wield;
+ {
+ scene::SMesh *mesh = new scene::SMesh();
+ scene::IMeshBuffer *buf = new scene::SMeshBuffer();
+ video::SColor c(255,255,255,255);
+ video::S3DVertex vertices[4] =
+ {
+ video::S3DVertex(-0.5,0,0, 0,0,0, c, 0,1),
+ video::S3DVertex(0.5,0,0, 0,0,0, c, 1,1),
+ video::S3DVertex(0.5,0.5,0, 0,0,0, c, 1,0),
+ video::S3DVertex(-0.5,0.5,0, 0,0,0, c, 0,0),
+ };
+ u16 indices[] = {0,1,2,2,3,0};
+ buf->append(vertices, 4, indices, 6);
+ // Set material
+ buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
+ buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
+ buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+ // Add to mesh
+ mesh->addMeshBuffer(buf);
+ buf->drop();
+
+ tool_wield = smgr->addMeshSceneNode(mesh, camera.getPlayerNode());
+ mesh->drop();
+ }
+ tool_wield->setVisible(false);
+ tool_wield->setPosition(tool_wield_position);
+ tool_wield->setRotation(tool_wield_rotation);
+
+ client.setPlayerWield(tool_wield);
+
+ /*
Clouds
*/
@@ -1765,6 +1803,7 @@ void the_game(
}
}
+
if(input->getRightClicked())
{
std::cout<<DTIME<<"Ground right-clicked"<<std::endl;
@@ -1831,6 +1870,14 @@ void the_game(
else{
}
+
+ if(input->getLeftState())
+ // Tool animation loops 0.0 - 1.0
+ tool_wield_animation = fmod(tool_wield_animation + dtime * 3.0, 1.0);
+ else
+ // Return tool to holding position if not digging
+ tool_wield_animation /= 1.5;
+
} // selected_object == NULL
input->resetLeftClicked();
@@ -1946,6 +1993,14 @@ void the_game(
);
}
+ /*
+ Animate tool
+ */
+ {
+ tool_wield->setRotation(tool_wield_rotation - sin(tool_wield_animation * PI) * 40.0);
+ tool_wield->setPosition(tool_wield_position - sin(tool_wield_animation * PI) / 3.0);
+ }
+
/*
Update gui stuff (0ms)