camera using threading

This commit is contained in:
gnembon committed 2019-12-19 01:49:00 -04:00
1 parent 0e9566a58d
commit 54308bb131
1 file changed
+32 -9
@@ -140,27 +140,50 @@ __get_path_at(segment, start, index) ->
v v
); );
__invalidate_points_cache() -> global_path_precalculated = map(range(global_points:(-1):1), null); __invalidate_points_cache() -> global_path_precalculated = map(range(global_points:(-1):1), null);
global_showing_path = false;
global_playing_path = false;
stop() ->
(
if (!global_playing_path && !global_showing_path, return('You can only stop playing or showing the path'));
if (global_showing_path,
global_showing_path = false;
print('stopped showing path');
);
if (global_playing_path,
global_playing_path = false;
print('stopped playing path');
);
''
);
show() -> show() ->
( (
global_showing_path = true;
task( _() -> (
loop(100, loop(100,
if(!global_showing_path, break());
_show_path_tick('dust 0.9 0.1 0.1 1', 100); _show_path_tick('dust 0.9 0.1 0.1 1', 100);
game_tick(50) sleep(50);
); );
'Done!' print('Done!');
));
'';
); );
play(fps) -> play(fps) ->
( (
p = player(); p = player();
__assert_valid_for_motion(); __assert_valid_for_motion();
__prepare_path_if_needed(); __prepare_path_if_needed();
global_playing_path = true;
task( _(outer(fps), outer(p)) -> ( task( _(outer(fps), outer(p)) -> (
//if ((fps % 20 != 0) || fps < 20, exit('FPS needs to be multiples of 20') ); mspt = 1000 / fps;
tpt = fps / 20;
mspt = 50 / tpt;
start_time = time(); start_time = time();
point = 0; point = 0;
loop( length(global_points)-1, loop( length(global_points)-1, segment = _;
segment = _; if (!global_playing_path, break());
start = global_points:segment:1; start = global_points:segment:1;
end = global_points:(segment+1):1; end = global_points:(segment+1):1;
loop(end-start, loop(end-start,
@@ -173,9 +196,9 @@ play(fps) ->
start_time = time() start_time = time()
) )
); );
'Done!' print('Done!');
)); ));
'';
); );
_show_path_tick(particle_type, total) -> _show_path_tick(particle_type, total) ->
( (