From 3b0bff2f743a3abf100368f94efafa7c2843a9b7 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 21 Dec 2010 02:25:47 +0200 Subject: Cracking blocks while digging --- src/main.cpp | 161 ++++++++++++++++------------------------------------------- 1 file changed, 44 insertions(+), 117 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 56e725722..6b5455965 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -179,12 +179,6 @@ TODO: TOSERVER_LEAVE Doing now: ====================================================================== -TODO: Node cracking animation when digging - - TODO: A way to generate new textures by combining textures - - TODO: Mesh update to fetch cracked faces from the former - -TODO: A thread-safe wrapper for irrlicht for threads, to get rid of - g_device ====================================================================== @@ -1164,7 +1158,7 @@ int main(int argc, char *argv[]) < res_count || r0 == 0) - r0 = 2; - - { - u16 i = r0-1; - std::cout<<"-> "; - std::cout<<(i+1)<<": "<(screenW, screenH), 16, fullscreen, false, false, &receiver); - // With vsync - /*device = createDevice(driverType, - core::dimension2d(screenW, screenH), - 16, fullscreen, false, true, &receiver);*/ if (device == 0) return 1; // could not create selected driver. @@ -1380,10 +1306,10 @@ int main(int argc, char *argv[]) */ video::IVideoDriver* driver = device->getVideoDriver(); - // These make the textures not to show at all - //driver->setTextureCreationFlag(video::ETCF_ALWAYS_16_BIT); - //driver->setTextureCreationFlag(video::ETCF_OPTIMIZED_FOR_SPEED ); + /* + This changes the minimum allowed number of vertices in a VBO + */ //driver->setMinHardwareBufferVertexCount(1); scene::ISceneManager* smgr = device->getSceneManager(); @@ -2147,48 +2073,69 @@ int main(int argc, char *argv[]) } // regular block } // for coords - /*static v3s16 oldnodepos; - static bool oldnodefound = false;*/ - if(nodefound) { - //std::cout<getLeftClicked()) + if(g_input->getLeftReleased()) + { + client.clearTempMod(nodepos); + dig_time = 0.0; + } if(g_input->getLeftClicked() || (g_input->getLeftState() && nodepos != nodepos_old)) { std::cout<getLeftClicked()) + { + client.setTempMod(nodepos, NodeMod(NODEMOD_CRACK, 0)); } + if(g_input->getLeftState()) + { + dig_time += dtime; + + float dig_time_complete = 0.5; + MapNode n = client.getNode(nodepos); + if(n.d == CONTENT_STONE) + dig_time_complete = 1.5; + + u16 dig_index = (u16)(3.99*dig_time/dig_time_complete); + if(dig_time > 0.2) + { + //dstream<<"dig_index="<getRightClicked()) - /*if(g_input->getRightClicked() || - (g_input->getRightState() && nodepos != nodepos_old))*/ { std::cout<setText(L""); } - /*oldnodefound = nodefound; - oldnodepos = nodepos;*/ - } // selected_object == NULL g_input->resetLeftClicked(); @@ -2197,7 +2144,7 @@ int main(int argc, char *argv[]) if(g_input->getLeftReleased()) { std::cout<getRightReleased()) { @@ -2214,26 +2161,6 @@ int main(int argc, char *argv[]) camera->setAspectRatio((f32)screensize.X / (f32)screensize.Y); - // Background color is choosen based on whether the player is - // much beyond the initial ground level - /*video::SColor bgcolor; - v3s16 p0 = Map::floatToInt(player_position); - // Does this make short random delays? - // NOTE: no need for this, sky doesn't show underground with - // enough range - bool is_underground = client.isNodeUnderground(p0); - //bool is_underground = false; - if(is_underground == false) - bgcolor = video::SColor(255,90,140,200); - else - bgcolor = video::SColor(255,0,0,0);*/ - - //video::SColor bgcolor = video::SColor(255,90,140,200); - //video::SColor bgcolor = skycolor; - - //s32 daynight_i = client.getDayNightIndex(); - //video::SColor bgcolor = skycolor[daynight_i]; - u32 daynight_ratio = client.getDayNightRatio(); video::SColor bgcolor = video::SColor( 255, -- cgit v1.2.3