From 9e14f971bc7e6d364d89a34f28e7c0c2017d16f5 Mon Sep 17 00:00:00 2001 From: Antony Date: Sat, 9 May 2015 15:46:59 -0600 Subject: [PATCH 1/4] Change windows build to use CFlag /Od so that you get the full debug experience. Without this flag set, Visual Studio lets you use breakpoints, but the watch and locals is pretty much useless. --- platform/windows/detect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 9cdf04797c2..298fa3bc789 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -204,7 +204,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['/Zi','/DDEBUG_ENABLED','/DDEBUG_MEMORY_ENABLED','/DD3D_DEBUG_INFO','/O1']) + env.Append(CCFLAGS=['/Zi','/DDEBUG_ENABLED','/DDEBUG_MEMORY_ENABLED','/DD3D_DEBUG_INFO','/Od']) env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) env.Append(LINKFLAGS=['/DEBUG']) From 8f4b6ff870d8e608ff056fee8c7043716bdd48d8 Mon Sep 17 00:00:00 2001 From: Nicolas Laurito Date: Sat, 9 May 2015 19:09:30 -0300 Subject: [PATCH 2/4] Deleted unused variable Deleted the var GRAVITY because it is unused. The gravity is used at line 237, but it's gotten from the Physics2DDirectBodyState parameter. --- demos/2d/platformer/player.gd | 1 - 1 file changed, 1 deletion(-) diff --git a/demos/2d/platformer/player.gd b/demos/2d/platformer/player.gd index b08105212ce..9ee189df21e 100644 --- a/demos/2d/platformer/player.gd +++ b/demos/2d/platformer/player.gd @@ -33,7 +33,6 @@ var shooting=false var WALK_ACCEL = 800.0 var WALK_DEACCEL= 800.0 var WALK_MAX_VELOCITY= 200.0 -var GRAVITY = 700.0 var AIR_ACCEL = 200.0 var AIR_DEACCEL= 200.0 var JUMP_VELOCITY=460 From ef8a402f71e92992e236504490a1533fa9f5d2b2 Mon Sep 17 00:00:00 2001 From: Nicolas Laurito Date: Sun, 10 May 2015 00:46:16 -0300 Subject: [PATCH 3/4] Remove focus from restart button, fixes #1850 Fixes a problem where the restart button would keep focus after being pressed, making the tetris' pieces impossible to rotate without activating the button again. --- demos/2d/tetris/grid.gd | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/2d/tetris/grid.gd b/demos/2d/tetris/grid.gd index dc89300881e..8708d168e4a 100644 --- a/demos/2d/tetris/grid.gd +++ b/demos/2d/tetris/grid.gd @@ -143,6 +143,7 @@ func restart_pressed(): cells.clear() get_node("gameover").set_text("") piece_active=true + get_node("../restart").release_focus() update() From bd1e54a8b75348fe948ef92f07a55815cc005b78 Mon Sep 17 00:00:00 2001 From: Hearto Lazor Date: Sun, 10 May 2015 10:00:26 -0400 Subject: [PATCH 4/4] - Implemented support for fixed process on timer. Useful for cooldowns without the influence from framerate similar to animation player (idle/fixed mode), where idle mode = old timer, fixed mode = fixed process implementation: Example of the behaviour with a stream of bullets with timers on different frame rates: https://gfycat.com/HeartyImpressiveIndiancow - A change for more uniform ticks on fixed/idle without this fix: http://i.imgur.com/0TMQ6CG.png with this fix: http://i.imgur.com/3zYx16c.png --- scene/main/timer.cpp | 69 ++++++++++++++++++++++++++++++++++++++------ scene/main/timer.h | 14 +++++++++ 2 files changed, 74 insertions(+), 9 deletions(-) diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index 2e3e7db0ad2..3a80382a40e 100644 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -45,14 +45,14 @@ void Timer::_notification(int p_what) { } } break; case NOTIFICATION_PROCESS: { - - if (!is_processing()) + if (timer_process_mode == TIMER_PROCESS_FIXED || !is_processing()) return; time_left -= get_process_delta_time(); if (time_left<0) { if (!one_shot) - time_left=wait_time+time_left; + //time_left=wait_time+time_left; + time_left = wait_time; else stop(); @@ -60,13 +60,27 @@ void Timer::_notification(int p_what) { } } break; + case NOTIFICATION_FIXED_PROCESS: { + if (timer_process_mode == TIMER_PROCESS_IDLE || !is_fixed_processing()) + return; + time_left -= get_fixed_process_delta_time(); + + if (time_left<0) { + if (!one_shot) + //time_left = wait_time + time_left; + time_left = wait_time; + else + stop(); + emit_signal("timeout"); + } + + } break; } } void Timer::set_wait_time(float p_time) { - ERR_EXPLAIN("time should be greater than zero."); ERR_FAIL_COND(p_time<=0); wait_time=p_time; @@ -96,14 +110,13 @@ bool Timer::has_autostart() const { } void Timer::start() { - time_left=wait_time; - set_process(true); + _set_process(true); } void Timer::stop() { time_left=-1; - set_process(false); + _set_process(false); autostart=false; } @@ -112,6 +125,41 @@ float Timer::get_time_left() const { return time_left >0 ? time_left : 0; } +void Timer::set_timer_process_mode(TimerProcessMode p_mode) { + + if (timer_process_mode == p_mode) + return; + + switch (timer_process_mode) { + case TIMER_PROCESS_FIXED: + if (is_fixed_processing()) { + set_fixed_process(false); + set_process(true); + } + break; + case TIMER_PROCESS_IDLE: + if (is_processing()) { + set_process(false); + set_fixed_process(true); + } + break; + } + timer_process_mode = p_mode; +} + +Timer::TimerProcessMode Timer::get_timer_process_mode() const{ + + return timer_process_mode; +} + + +void Timer::_set_process(bool p_process, bool p_force) +{ + switch (timer_process_mode) { + case TIMER_PROCESS_FIXED: set_fixed_process(p_process); break; + case TIMER_PROCESS_IDLE: set_process(p_process); break; + } +} void Timer::_bind_methods() { @@ -129,8 +177,12 @@ void Timer::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_time_left"),&Timer::get_time_left); + ObjectTypeDB::bind_method(_MD("set_timer_process_mode", "mode"), &Timer::set_timer_process_mode); + ObjectTypeDB::bind_method(_MD("get_timer_process_mode"), &Timer::get_timer_process_mode); + ADD_SIGNAL( MethodInfo("timeout") ); + ADD_PROPERTY(PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_timer_process_mode"), _SCS("get_timer_process_mode")); ADD_PROPERTY( PropertyInfo(Variant::REAL, "wait_time", PROPERTY_HINT_EXP_RANGE, "0.01,4096,0.01" ), _SCS("set_wait_time"), _SCS("get_wait_time") ); ADD_PROPERTY( PropertyInfo(Variant::BOOL, "one_shot" ), _SCS("set_one_shot"), _SCS("is_one_shot") ); ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autostart" ), _SCS("set_autostart"), _SCS("has_autostart") ); @@ -138,8 +190,7 @@ void Timer::_bind_methods() { } Timer::Timer() { - - + timer_process_mode = TIMER_PROCESS_IDLE; autostart=false; wait_time=1; one_shot=false; diff --git a/scene/main/timer.h b/scene/main/timer.h index 021638ccfcb..4b9cecba84e 100644 --- a/scene/main/timer.h +++ b/scene/main/timer.h @@ -46,6 +46,11 @@ protected: static void _bind_methods(); public: + enum TimerProcessMode { + TIMER_PROCESS_FIXED, + TIMER_PROCESS_IDLE, + }; + void set_wait_time(float p_time); float get_wait_time() const; @@ -60,7 +65,16 @@ public: float get_time_left() const; + void set_timer_process_mode(TimerProcessMode p_mode); + TimerProcessMode get_timer_process_mode() const; Timer(); + +private: + TimerProcessMode timer_process_mode; + void _set_process(bool p_process, bool p_force = false); + }; +VARIANT_ENUM_CAST(Timer::TimerProcessMode); + #endif // TIMER_H