@@ -215,6 +215,9 @@ def __init__(self, scale: float):
215215
216216 self .should_redraw = False
217217 self .a = False
218+
219+ self .global_offset_x = 100
220+ self .global_offset_y = 0
218221 # FIXME: make this 'a' a proper thing (it's used for showing blocks)
219222 # TODO: add side-by-side code comparison
220223
@@ -249,12 +252,12 @@ def on_resize(self, width: float, height: float):
249252 for i in self .parser .code_tree .roots :
250253 self .compute_node_size (i , self .scaler )
251254
252- offset_x = 100
255+ tmp_offset_x = 0
253256
254257 for i in self .parser .code_tree .roots :
255- self .compute_node_position (i , self .scaler , offset_x , (self .height - self .graphics_info [i ].size_y ) // 2 )
256- offset_x += self .scaler .OBJECTS_BUFFER
257- offset_x += self .graphics_info [i ].size_x
258+ self .compute_node_position (i , self .scaler , self . global_offset_x + tmp_offset_x , self . global_offset_y + (self .height - self .graphics_info [i ].size_y ) // 2 )
259+ tmp_offset_x += self .scaler .OBJECTS_BUFFER
260+ tmp_offset_x += self .graphics_info [i ].size_x
258261
259262 for i in self .parser .code_tree .function_calls :
260263 self .compute_function_call_graphics_info (i )
@@ -496,3 +499,32 @@ def recursive_node_draw(self, node):
496499
497500 def update (self , delta_time ):
498501 pass
502+
503+ def on_key_press (self , symbol , modifier ):
504+ should_recalculate = False
505+ if symbol == arcade .key .UP :
506+ self .global_offset_y -= 50
507+ should_recalculate = True
508+ elif symbol == arcade .key .DOWN :
509+ self .global_offset_y += 50
510+ should_recalculate = True
511+ elif symbol == arcade .key .RIGHT :
512+ self .global_offset_x -= 50
513+ should_recalculate = True
514+ elif symbol == arcade .key .LEFT :
515+ self .global_offset_x += 50
516+ should_recalculate = True
517+ elif symbol == arcade .key .KEY_0 :
518+ self .scaler .rescale (self .scaler .current_scale * 1.05 )
519+ should_recalculate = True
520+ elif symbol == arcade .key .KEY_9 :
521+ self .scaler .rescale (self .scaler .current_scale * 0.95 )
522+ should_recalculate = True
523+
524+ # FIXME: probably this should be made more elegant
525+ if should_recalculate :
526+ self .on_resize (self .width , self .height )
527+
528+
529+
530+
0 commit comments