1-- GunFu Deadlands 2-- Copyright 2009-2011 Christiaan Janssen, September 2009-October 2011 3-- 4-- This file is part of GunFu Deadlands. 5-- 6-- GunFu Deadlands is free software: you can redistribute it and/or modify 7-- it under the terms of the GNU General Public License as published by 8-- the Free Software Foundation, either version 3 of the License, or 9-- (at your option) any later version. 10-- 11-- GunFu Deadlands is distributed in the hope that it will be useful, 12-- but WITHOUT ANY WARRANTY; without even the implied warranty of 13-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14-- GNU General Public License for more details. 15-- 16-- You should have received a copy of the GNU General Public License 17-- along with GunFu Deadlands. If not, see <http://www.gnu.org/licenses/>. 18 19BulletTime = {} 20 21function BulletTime.init() 22 23 BulletTime.showprogress = true 24 25 BulletTime.slowdown_player = 1/3 -- player goes 3 times slower 26 BulletTime.slowdown_enemies = 1/5 -- enemies go 5 times slower 27 BulletTime.slowdown_bullets = 1/6 -- bullets go 6 times slower 28 29 BulletTime.active = false 30 BulletTime.timer = 0 31 BulletTime.duration = Graphics.get_jumptime()/BulletTime.slowdown_player 32 33 BulletTime.charge_duration = 2.5 34 BulletTime.charge_timer = 0 35 BulletTime.charged = true 36 37end 38 39function BulletTime.reset() 40 -- bullet time! 41 BulletTime.showprogress = true 42 BulletTime.active = false 43 BulletTime.timer = 0 44 BulletTime.charge_timer = 0 45 BulletTime.charged = true 46end 47 48function BulletTime.start() 49 if not BulletTime.active and BulletTime.charged then 50 BulletTime.active = true 51 BulletTime.timer = BulletTime.duration 52 BulletTime.charged = false 53 BulletTime.charge_timer = 0 54 Sounds.play_bullettime() 55 end 56end 57 58function BulletTime.force( timer ) 59 -- for dramatic effects.. 60 -- but we want the marker to freeze! 61 -- ok, so what we do is just hide it, since this will always happen at the end of a level 62 -- we assume that with the new level start the marker will be shown again 63 BulletTime.showprogress = false 64 BulletTime.active = true 65 BulletTime.timer = timer 66 BulletTime.charged = false 67 BulletTime.charge_timer = 0 68end 69 70function BulletTime.update( dt ) 71 if BulletTime.active then 72 73 -- timer 74 BulletTime.timer = BulletTime.timer - dt 75 if BulletTime.timer <= 0 then 76 BulletTime.active = false 77 BulletTime.timer = BulletTime.charge_duration 78 end 79 80 else 81 82 if BulletTime.charge_timer < BulletTime.charge_duration then 83 BulletTime.charge_timer = BulletTime.charge_timer + dt 84 if BulletTime.charge_timer >= BulletTime.charge_duration then 85 BulletTime.charged = true 86 end 87 end 88 89 end 90 91end 92 93 94 95