@@ -240,18 +240,8 @@ def draw_carriers(self):
240240 def draw_info (self ):
241241 if self .info is not None :
242242 font = pygame .font .SysFont (None , 20 )
243- time = font .render (
244- 'T={:.2f}' .format (self .info ['time' ]),
245- True ,
246- 'black' ,
247- 'white'
248- )
249- n_parts = font .render (
250- f"#Parts={ self .info ['n_parts' ]} " ,
251- True ,
252- 'black' ,
253- 'white'
254- )
243+ time = font .render ( 'T={:.2f}' .format (self .info ['time' ]), True , 'black' , 'white' )
244+ n_parts = font .render ( f"#Parts={ self .info ['n_parts' ]} " , True , 'black' , 'white' )
255245 self .screen .blit (time , time .get_rect (center = (30 , 30 )))
256246 self .screen .blit (n_parts , n_parts .get_rect (center = (30 , 50 )))
257247
@@ -264,12 +254,7 @@ def draw_actions(self):
264254 actions = "" .join (f"{ action [0 ]} ={ action [1 ]} " for action in actor_actions [1 ].items ())
265255 else :
266256 actions = "" .join (f"{ action [0 ]} ={ action [1 ]} , " for action in actor_actions [1 ].items ())
267- text = font .render (
268- f'{ actor } : { actions } ' ,
269- True ,
270- 'black' ,
271- 'white'
272- )
257+ text = font .render ( f'{ actor } : { actions } ' , True , 'black' , 'white' )
273258 self .screen .blit (text , text .get_rect (center = (self .center .x , 30 + n * 22 )))
274259
275260 def draw_user_input (self ):
@@ -292,75 +277,70 @@ def draw_shutdown(self):
292277 text = font .render ("Shutting down..." , True , 'black' )
293278 self .screen .blit (text , text .get_rect (center = self .center ))
294279
295- def draw_cursor (self ):
296- pygame .draw .circle (self .screen , 'blue' , self .center , 10 , 1 )
280+ def draw_crosshair (self ):
281+ pygame .draw .line ( self .screen , 'red' , self .center + (10 ,0 ), self .center - (10 ,0 ))
282+ pygame .draw .line ( self .screen , 'red' , self .center + (0 ,10 ), self .center - (0 ,10 ))
297283
298284 def draw_minimap (self ):
299285 if self .line_bounds is None :
300286 self .find_line_bounds ()
301287
288+ #setup minimap
302289 downscale = 5
303290 buffer = pygame .Vector2 (20 , 20 )
304291 line_diagonal = self .line_bounds ['lower_right' ] - self .line_bounds ['upper_left' ]
305- minimap_surface_size = pygame .Vector2 (line_diagonal / downscale + buffer )
306- minimap_surface = pygame .Surface (minimap_surface_size )
307- minimap_surface .fill ('white' )
308- minimap_surface_pos = pygame .Vector2 (
309- self .size .x - minimap_surface_size .x ,
310- 0
311- )
312- minimap_upper_left = pygame .Vector2 (0 ,0 )
313- draw_position = minimap_upper_left - self .line_bounds ['upper_left' ] / downscale + buffer / 2
314- minimap_size = pygame .Vector2 (self .size / downscale )
315- pygame .draw .rect (
316- minimap_surface ,
317- 'blue' ,
318- pygame .Rect (minimap_upper_left , minimap_surface_size ),
319- width = 2
320- )
321-
292+ minimap_size = pygame .Vector2 (line_diagonal / downscale + buffer )
293+ minimap = pygame .Surface (minimap_size )
294+ minimap .fill ('white' )
295+ minimap_pos = pygame .Vector2 (self .size .x - minimap_size .x , 0 )
296+ draw_position = - self .line_bounds ['upper_left' ] / downscale + buffer / 2
297+ pygame .draw .rect (minimap , 'black' , pygame .Rect ((0 ,0 ), minimap_size ), width = 2 )
298+
299+ #draw on minimap
322300 for connector in self .connectors :
323301 pygame .draw .line (
324- minimap_surface ,
302+ minimap ,
325303 'gray' ,
326304 draw_position + connector ['start' ] / downscale ,
327305 draw_position + connector ['end' ] / downscale ,
328306 )
329307 for station in self .stations :
330308 color = self .get_station_color (station )
331309 pygame .draw .circle (
332- minimap_surface ,
310+ minimap ,
333311 color ,
334312 draw_position + station ['position' ] / downscale ,
335313 5
336314 )
337315 for carrier in self .carriers :
338316 pygame .draw .circle (
339- minimap_surface ,
317+ minimap ,
340318 'orange' ,
341319 draw_position + carrier ['position' ] / downscale ,
342320 3
343321 )
344322
323+ #draw outline of current view and crosshair
345324 view_outline = pygame .Rect (
346325 draw_position - self .view / downscale - self .size / downscale * self .viewpoint .z / 2 ,
347326 self .size / downscale * self .viewpoint .z
348327 )
349328 pygame .draw .line (
350- minimap_surface ,
329+ minimap ,
351330 'red' ,
352331 draw_position - self .view / downscale + (3 ,0 ),
353332 draw_position - self .view / downscale - (3 ,0 )
354333 )
355334 pygame .draw .line (
356- minimap_surface ,
335+ minimap ,
357336 'red' ,
358337 draw_position - self .view / downscale + (0 ,3 ),
359338 draw_position - self .view / downscale - (0 ,3 )
360339 )
340+ pygame .draw .rect (minimap , 'red' , view_outline , width = 1 )
361341
362- pygame . draw . rect ( minimap_surface , 'red' , view_outline , width = 1 )
363- self .screen .blit (minimap_surface , minimap_surface_pos )
342+ #blit minimap onto screen
343+ self .screen .blit (minimap , minimap_pos )
364344
365345 def check_user_input (self ):
366346 for event in pygame .event .get ():
@@ -428,7 +408,7 @@ def run(self):
428408 self .draw_user_input ()
429409 self .draw_info ()
430410 self .draw_actions ()
431- self .draw_cursor ()
411+ self .draw_crosshair ()
432412
433413 if self .viewpoint_is_set and self .show_minimap :
434414 self .draw_minimap ()
0 commit comments