diff options
author | PilzAdam <PilzAdam@gmx.de> | 2013-01-03 19:51:52 +0100 |
---|---|---|
committer | PilzAdam <PilzAdam@gmx.de> | 2013-01-04 18:51:38 +0100 |
commit | 82fd83fd12e23ad7c61b4c7ae525be745b5236a5 (patch) | |
tree | 10ae8a3c7a1bec088944caab1ca0ea4960df78b8 /src/game.cpp | |
parent | b50da63852f2a2360d07cc2f1e29fc6844b15ccc (diff) | |
download | minetest-82fd83fd12e23ad7c61b4c7ae525be745b5236a5.tar.gz minetest-82fd83fd12e23ad7c61b4c7ae525be745b5236a5.tar.bz2 minetest-82fd83fd12e23ad7c61b4c7ae525be745b5236a5.zip |
Switch to fly mode if spacebar is doubleclicked
Can be turned off in the key change GUI or in minetest.conf via doubletab_space
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/game.cpp b/src/game.cpp index fdb083ff1..ab480c3db 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1310,6 +1310,9 @@ void the_game( float damage_flash = 0; s16 farmesh_range = 20*MAP_BLOCKSIZE; + float jump_timer = 0; + bool reset_jump_timer = false; + const float object_hit_delay = 0.2; float object_hit_delay_timer = 0.0; float time_from_last_punch = 10; @@ -1592,6 +1595,10 @@ void the_game( // Input handler step() (used by the random input generator) input->step(dtime); + // Increase timer for doubleclick of "jump" + if(g_settings->getBool("doubletab_jump") && jump_timer <= 0.2) + jump_timer += dtime; + /* Launch menus and trigger stuff according to keys */ @@ -1681,6 +1688,27 @@ void the_game( statustext += L" (note: no 'fly' privilege)"; } } + else if(input->wasKeyDown(getKeySetting("keymap_jump"))) + { + if(g_settings->getBool("doubletab_jump") && jump_timer < 0.2) + { + if(g_settings->getBool("free_move")) + { + g_settings->set("free_move","false"); + statustext = L"free_move disabled"; + statustext_time = 0; + } + else + { + g_settings->set("free_move","true"); + statustext = L"free_move enabled"; + statustext_time = 0; + if(!client.checkPrivilege("fly")) + statustext += L" (note: no 'fly' privilege)"; + } + } + reset_jump_timer = true; + } else if(input->wasKeyDown(getKeySetting("keymap_fastmove"))) { if(g_settings->getBool("fast_move")) @@ -1843,6 +1871,13 @@ void the_game( statustext_time = 0; } + // Reset jump_timer + if(!input->isKeyDown(getKeySetting("keymap_jump")) && reset_jump_timer) + { + reset_jump_timer = false; + jump_timer = 0.0; + } + // Handle QuicktuneShortcutter if(input->wasKeyDown(getKeySetting("keymap_quicktune_next"))) quicktune.next(); |